test: Improve test coverage from 72% to 76% (toward 80% target) #183
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 ] | |
| pull_request: | |
| branches: [ main ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go-version: ['1.23.x', '1.24.x'] # Include 1.23 as fallback | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| cache: true | |
| check-latest: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Verify dependencies | |
| run: go mod verify | |
| - name: Build | |
| run: go build -v ./... | |
| - name: Test | |
| run: go test -race -coverprofile=coverage.out -covermode=atomic -v ./... | |
| - name: Upload coverage to Codecov | |
| if: matrix.go-version == '1.24.x' # Only upload once | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.out | |
| fail_ci_if_error: false | |
| token: ${{ secrets.CODECOV_TOKEN }} # Add token for better reliability | |
| benchmark: | |
| name: Benchmark | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Required to push to gh-pages branch | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.24.x' | |
| cache: true | |
| check-latest: true | |
| - name: Download dependencies | |
| run: go mod download | |
| - name: Run benchmarks | |
| run: go test -bench=. -benchmem -benchtime=1s -run=^$$ ./... | tee benchmark-results.txt | |
| - name: Store benchmark result | |
| uses: benchmark-action/github-action-benchmark@v1 | |
| with: | |
| tool: 'go' | |
| output-file-path: benchmark-results.txt | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| auto-push: true | |
| comment-on-alert: true | |
| alert-threshold: '150%' | |
| fail-on-alert: false | |
| summary-always: true |