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 workflow_dispatch: env: GOLANGCI_LINT_VERSION: v1.61.0 GOLANGCI_LINT_TIMEOUT: 5m permissions: contents: read 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-latest # if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-ci') }} steps: - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: audit - name: Check out code uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up Go uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 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@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.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@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests file: ./coverage.txt