forked from cairnapp/go-geobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
64 additions
and
9 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,44 @@ | ||
name: Build and test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.21.x' | ||
cache: true | ||
- name: Install dependencies | ||
run: go mod tidy | ||
|
||
- name: Build | ||
run: go build ./... | ||
|
||
- name: Test | ||
run: go test ./... -coverprofile coverage.out -covermode count | ||
|
||
|
||
- name: Unit tests | ||
run: go tool cover -func coverage.out | ||
|
||
- name: Quality Gate - Test coverage shall be above threshold | ||
env: | ||
TESTCOVERAGE_THRESHOLD: 35 | ||
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 |
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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
vendor/ | ||
.idea/ | ||
.idea/ | ||
.fleet/ | ||
tmp | ||
local | ||
.env | ||
coverage.out |
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
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
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
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,12 @@ | ||
run: test cover | ||
|
||
check: | ||
go vet ./... | ||
go fmt ./... | ||
|
||
test: | ||
go test ./... | ||
|
||
cover: | ||
go test -coverprofile=coverage.out ./... | ||
go tool cover -func coverage.out |