Skip to content

ci: add GitHub Actions workflow with Codecov integration #1

ci: add GitHub Actions workflow with Codecov integration

ci: add GitHub Actions workflow with Codecov integration #1

Workflow file for this run

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