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: v1.63.4 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-24.04 # if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-ci') }} steps: - name: Harden Runner uses: step-security/harden-runner@cb605e52c26070c328afc4562f0b4ada7618a84e # v2.10.4 with: egress-policy: audit - name: Check out code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Go uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.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@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # v6.2.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@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests file: ./coverage.txt