-
-
Notifications
You must be signed in to change notification settings - Fork 55
80 lines (67 loc) · 2.24 KB
/
ci.yml
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
CI:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.0
- name: Dependencies
run: go mod download
- name: Vet
run: |
go vet ./...
- name: Build
run: go build -v ./...
- name: Unit tests
run: |
go test ./... -v -coverprofile coverage.tmp.out -covermode count
go tool cover -func coverage.tmp.out
- name: Quality Gate - Test coverage shall be above threshold
env:
TESTCOVERAGE_THRESHOLD: 65
run: |
echo "Quality Gate: checking test coverage is above threshold ..."
echo "Threshold : $TESTCOVERAGE_THRESHOLD %"
# Excluded the concrete strategy from the unit test coverage, because covered by integration tests
cat coverage.tmp.out | grep -v "ssh.go" | grep -v "http.go" | grep -v "tcp.go" > coverage.out
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 }}
- name: Start integration test dependencies
run: |
make test.dependencies.start
- name: Wait for RabbitMQ to be ready
run: |
sleep 2
count=0
until docker exec rabbitmq rabbitmqctl list_queues > /dev/null 2>&1; do
count=$((count+1))
if [ $count -gt 10 ]; then
echo "RabbitMQ did not start within the specified time"
exit 1
fi
echo "Waiting for RabbitMQ to start..."
sleep 5
done
- name: Integration tests
run: |
make test.integration.verbose
make test.dependencies.down