diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..5d7e5ed --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,38 @@ +name: Coverage + +on: + pull_request: + push: + branches: + - master + +permissions: + contents: read + +jobs: + coverage: + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + + steps: + - name: Checkout Repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Set Up Go Environment + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + + - name: Generate Test Coverage + run: go test ./... -covermode=atomic -coverpkg=./... -coverprofile=cover.out + + - name: Upload Coverage + uses: codecov/codecov-action@v7 + with: + files: ./cover.out + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/PROJECT.md b/PROJECT.md index ad07a74..107261e 100644 --- a/PROJECT.md +++ b/PROJECT.md @@ -57,6 +57,8 @@ This repository is configured with these GitHub workflows: - `check`: runs linting, the normal Go test suite, and the showcase end-to-end tests across supported platforms. +- `coverage`: uploads Go coverage to Codecov, where `codecov.yml` requires + 90% patch coverage for pull requests. - `release-binaries`: reads `VERSION`, builds Linux, macOS, and Windows binaries, signs and notarizes the macOS ARM64 and x64 ZIPs, and creates the matching GitHub Release on pushes to `master`. It runs on a self-hosted macOS diff --git a/README.md b/README.md index 614d546..ff149d7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Embed Code +[![Coverage](https://codecov.io/gh/SpineEventEngine/embed-code-go/branch/master/graph/badge.svg)](https://codecov.io/gh/SpineEventEngine/embed-code-go) + Embed Code is a Go command-line tool that keeps documentation snippets in sync with source files. It scans Markdown and HTML documents for `` instructions, resolves the requested source content, and manages the following diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..886a1c5 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,8 @@ +coverage: + status: + project: off + patch: + default: + target: 90% + threshold: 0% + only_pulls: true