-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (45 loc) · 1.56 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Testing
on:
push:
branches:
- master
pull_request:
jobs:
test:
name: Test and Sanity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: 1.21
cache: false
- uses: golangci/golangci-lint-action@v3
with:
version: v1.55
- run: go test -v ./...
- run: go test ./... -coverprofile=coverage.out
- run: go tool cover -func=coverage.out
- name: Coverage Quality Check
env:
REQUIRED_COVERAGE: 80
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
- name: Prepare/Release Workflows Check
run: |
go install github.com/mikefarah/yq/v4@latest
yq '.jobs.release.steps.[0:9]' .github/workflows/release.yaml > release-steps.yaml
yq '.jobs.prepare.steps' .github/workflows/prepare.yaml > prepare-steps.yaml
if ! diff release-steps.yaml prepare-steps.yaml; then
echo "Prepare and Release workflows are not in sync!"
exit 1
fi
if ! yq '.jobs.release.steps.[9]' .github/workflows/release.yaml | grep -q 'Create Release'; then
echo 'Release has pre-build steps missing from Prepare workflow!'
exit 1
fi