ci: add GitHub Actions workflow with Codecov integration #1
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] | |
| jobs: | |
| test: | |
| name: Test and Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Set up Go | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version: stable | |
| - name: Cache Go modules | |
| uses: actions/cache@v6 | |
| with: | |
| path: | | |
| ~/.cache/go-build | |
| ${{ github.workspace }}/go/pkg/mod | |
| key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go- | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Run tests with coverage | |
| run: | | |
| set -o pipefail | |
| go test ./... -covermode=atomic -coverprofile=coverage.out | |
| - name: Show coverage summary | |
| if: always() | |
| run: go tool cover -func=coverage.out | sed -n '$p' | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.out | |
| fail_ci_if_error: true |