Updating block #77
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| checks: write | |
| pull-requests: write | |
| env: | |
| GOPRIVATE: github.com/0xAtelerix/* | |
| GOFLAGS: -mod=mod | |
| TEST_SHUFFLE_SEED: ${{ github.run_id }} | |
| jobs: | |
| CI: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| # If it's a PR, use the PR's last commit (HEAD). Otherwise use the workflow commit. | |
| ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | |
| fetch-depth: 1 | |
| fetch-tags: false | |
| - name: Fetch main (shallow) | |
| run: | | |
| git fetch --no-tags --depth=1 origin main:refs/remotes/origin/main | |
| - name: Set up Go | |
| id: setup-go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: ./go.mod | |
| cache: true | |
| - name: Capture Go cache paths | |
| run: | | |
| echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_ENV | |
| echo "GOBIN=$(go env GOPATH)/bin" >> $GITHUB_ENV | |
| - name: Add GOBIN to PATH | |
| run: echo "$GOBIN" >> $GITHUB_PATH | |
| - name: Cache GOBIN (tools only) | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.GOBIN }} | |
| key: ${{ runner.os }}-gobin-${{ hashFiles('**/go.sum') }}-v1 | |
| restore-keys: ${{ runner.os }}-gobin- | |
| - name: Git auth for private sdk (read-only) | |
| env: | |
| GH_SDK_TOKEN: ${{ secrets.GH_SDK_TOKEN }} | |
| run: | | |
| test -n "$GH_SDK_TOKEN" || { echo "GH_SDK_TOKEN missing"; exit 1; } | |
| git config --global url."https://x-access-token:${GH_SDK_TOKEN}@github.com/0xAtelerix/sdk".insteadOf "https://github.com/0xAtelerix/sdk" | |
| git config --global url."https://x-access-token:${GH_SDK_TOKEN}@github.com/0xAtelerix/sdk/".insteadOf "https://github.com/0xAtelerix/sdk/" | |
| go env -w GOPRIVATE=github.com/0xAtelerix/* | |
| - name: Deps (modules + golangci-lint) | |
| run: make deps-ci | |
| - name: Lint (golangci-lint-action) | |
| uses: golangci/golangci-lint-action@v8 | |
| with: | |
| version: v2.4.0 | |
| args: -v --timeout=10m | |
| github-token: ${{ github.token }} | |
| - name: Test (no-race) with coverage | |
| run: | | |
| go test -short -timeout 20m -failfast -shuffle=${{ env.TEST_SHUFFLE_SEED }} -v ./... -coverprofile=cover.out -covermode=atomic -coverpkg=./... $(params) | |
| go tool cover -html=cover.out -o coverage.html | |
| - name: PR coverage comment | |
| uses: k1LoW/octocov-action@v1 | |
| - name: Enforce coverage thresholds | |
| uses: vladopajic/go-test-coverage@v2 | |
| with: | |
| config: ./.testcoverage.yml | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage | |
| path: | | |
| cover.out | |
| coverage.html |