-
Notifications
You must be signed in to change notification settings - Fork 0
32 lines (31 loc) · 955 Bytes
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
name: Test Application
on:
push:
jobs:
run-tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.19
- uses: golangci/golangci-lint-action@v6
with:
version: v1.59.0
- run: go test ./...
name: Run All Tests
- run: go test ./... -coverprofile=coverage.out
name: Run Tests with Coverage
- run: go tool cover -func=coverage.out
name: Display Coverage
- name: Coverage Quality Check
env:
REQUIRED_COVERAGE: 90
run: |
totalCoverage=$(go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+')
echo "Total Coverage: $totalCoverage %"
if (( $(echo "$totalCoverage < $REQUIRED_COVERAGE" | bc -l) )); then
echo "Coverage is less than $REQUIRED_COVERAGE %"
exit 1
fi