Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
comment:
layout: "header, diff, flags, files" # show flag info in the PR comment
flag_management:
default_rules: # default rules that will be inherited by all flags
statuses:
- type: project # in this case every flag that doens't have a status defined will have a project type
target: auto
threshold: 5%
branches:
- master
individual_flags:
- name: backend-apis # only Golang backend APIs
paths:
- "webv2/**"
- "!webv2/webCmd.go"
statuses: # each component has its own status and corresponding configuration
- type: project
target: auto
- name: backend-library # only library code
paths:
- "!webv2/**"
- "!ui/**"
- "!cmd/**"
statuses: # each component has its own status and corresponding configuration
- type: project
target: auto
- name: cli # only the CLI
paths:
- "cmd/**"
- "webv2/webCmd.go"
statuses: # each component has its own status and corresponding configuration
- type: project
target: auto
- name: frontend # only frontend components
paths:
- ui/**
statuses: # the core component has its own statuses
- type: project
target: auto
ignore:
- ".docker"
- ".github"
- "docs"
50 changes: 27 additions & 23 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,37 @@ on:
branches:
- master
pull_request:
name: code-coverage-check
name: code-coverage-check
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: '1.19'
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: "1.19"

- name: Unit tests
run: |
go test ./... -coverprofile coverage.out -covermode count
go tool cover -func coverage.out
- name: Unit tests
run: |
go test ./... -coverprofile coverage.out -covermode count
go tool cover -func coverage.out

- name: Quality Gate - Test coverage should be above threshold
env:
- name: Quality Gate - Test coverage should be above threshold
env:
TESTCOVERAGE_THRESHOLD: 50
run: |
echo "Quality Gate: checking if test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "OK"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Failed"
exit 1
fi
run: |
echo "Quality Gate: checking if test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
totalCoverage=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'`
echo "Current test coverage : $totalCoverage %"
if (( $(echo "$totalCoverage $TESTCOVERAGE_THRESHOLD" | awk '{print ($1 > $2)}') )); then
echo "OK"
else
echo "Current test coverage is below threshold. Please add more unit tests or adjust threshold to a lower value."
echo "Failed"
exit 1
fi
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}