any-sync/.github/workflows/coverage.yml
Grigory Efimov 0f4dd039cd
testbytest
2023-01-11 19:38:44 +03:00

45 lines
1.4 KiB
YAML

on:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
env:
GOPRIVATE: github.com/anytypeio
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.19.0'
- name: git config
run: git config --global url.https://${{ secrets.ANYTYPE_PAT }}@github.com/.insteadOf https://github.com/
- name: test go install
run: |
go install github.com/anytypeio/go-chash@latest
- name: Vet
run: |
make vet
- name: Unit tests
run: |
sudo make test-coverage
- name: Quality Gate - Test coverage shall be above threshold
env:
TESTCOVERAGE_THRESHOLD: 0
run: |
echo "Quality Gate: checking 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