This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sc-102926]: add basic code coverage support (#72)
Signed-off-by: Patrick Stephens <[email protected]>
- Loading branch information
1 parent
f12e042
commit 3aca1d8
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Unit testing and code coverage | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
unit-test: | ||
name: Go unit test and code coverage | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install cmetrics library | ||
run: | | ||
curl -L https://github.com/fluent/cmetrics/releases/download/${CMETRICS_RELEASE}/cmetrics_${CMETRICS_VERSION}_${ARCH}-headers.deb --output cmetrics_${CMETRICS_VERSION}_${ARCH}-headers.deb | ||
curl -L https://github.com/fluent/cmetrics/releases/download/${CMETRICS_RELEASE}/cmetrics_${CMETRICS_VERSION}_${ARCH}.deb --output cmetrics_${CMETRICS_VERSION}_${ARCH}.deb | ||
sudo dpkg -i *.deb | ||
shell: bash | ||
env: | ||
CMETRICS_VERSION: "0.9.1" | ||
CMETRICS_RELEASE: "v0.9.1" | ||
ARCH: "amd64" | ||
|
||
- name: setup-go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.22" | ||
|
||
- name: Test | ||
run: go test -v -race -cover -covermode=atomic -coverprofile=coverage.txt ./... | ||
shell: bash | ||
|
||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
fail_ci_if_error: true | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
file: coverage.txt | ||
flags: unittest | ||
verbose: true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
coverage: | ||
status: | ||
project: | ||
default: | ||
# Each PR must increase coverage | ||
target: auto | ||
# This allows a 2% drop from the previous base commit coverage to cope with any jitter or flakes | ||
threshold: 2% | ||
|
||
github_checks: | ||
annotations: true | ||
|
||
comment: | ||
layout: "header, diff, flags, components, files, footer" # show component info in the PR comment | ||
require_changes: false # if true: only post the comment if coverage changes | ||
require_base: false # [yes :: must have a base report to post] | ||
require_head: true # [yes :: must have a head report to post] | ||
show_carryforward_flags: true | ||
show_critical_paths: true #new option to labeled critical files | ||
hide_comment_details: true #collapse all the "detailed info" for the PR comment | ||
|
||
component_management: | ||
default_rules: # default rules that will be inherited by all components | ||
statuses: | ||
- type: project # in this case every component that does not have a status defined will have a project type one | ||
target: auto | ||
branches: | ||
- "!main" | ||
|
||
ignore: | ||
- '**/*.md' | ||
- '**/*.sh' | ||
- '**/*.rb' | ||
- '.github/**/*' | ||
- 'examples/**/*' | ||
- 'testing/**/*' |