* Add staticcheck fixes Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * update golangci-lint version Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> --------- Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
84 lines
2.1 KiB
YAML
84 lines
2.1 KiB
YAML
name: Lint and Unit tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "**.go"
|
|
- go.mod
|
|
- go.sum
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "**.go"
|
|
- go.mod
|
|
- go.sum
|
|
|
|
env:
|
|
GOLANGCI_LINT_VERSION: v2.1.6
|
|
GOLANGCI_LINT_TIMEOUT: 5m
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: fission-lint-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint:
|
|
permissions:
|
|
contents: read # for actions/checkout to fetch code
|
|
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
|
|
runs-on: ubuntu-24.04
|
|
# if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-ci') }}
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Check out code
|
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
|
with:
|
|
go-version-file: "go.mod"
|
|
cache: true
|
|
|
|
- name: Verify dependencies
|
|
run: |
|
|
go mod verify
|
|
go mod download
|
|
|
|
- name: Run golangci-lint
|
|
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
|
with:
|
|
skip-cache: true
|
|
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
|
args: --timeout=${{ env.GOLANGCI_LINT_TIMEOUT }}
|
|
|
|
- name: Detect git changes
|
|
if: always()
|
|
run: |
|
|
if [[ $(git diff --stat) != '' ]]; then
|
|
echo -e '❌ \033[0;31m. Fix lint changes.\033[0m'
|
|
git diff --color
|
|
exit 1
|
|
else
|
|
echo '✔ No issues detected. Have a nice day :-)'
|
|
fi
|
|
|
|
- name: Run unit tests
|
|
run: ./hack/runtests.sh
|
|
|
|
- name: Upload Coverage report to CodeCov
|
|
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
flags: unittests
|
|
file: ./coverage.txt
|