-
Notifications
You must be signed in to change notification settings - Fork 15
57 lines (55 loc) · 1.76 KB
/
tests.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
on:
push:
branches:
- main
pull_request:
name: Tests
jobs:
test:
strategy:
matrix:
go:
- version: 1.19
report: true
- version: 1.18
runs-on: ubuntu-latest
steps:
- name: Install code climate
if: matrix.go.report == true && github.ref == 'refs/heads/main'
run: |
wget -O /tmp/cc-test-reporter https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
chmod +x /tmp/cc-test-reporter
/tmp/cc-test-reporter before-build
- name: Checkout code
uses: actions/checkout@v3
- name: Run golangci-lint checks
run: |
docker-compose run lint
- name: Run tests
env:
GO_VERSION: ${{ matrix.go.version }}
run: |
docker-compose run test
echo $? > /tmp/GO_EXIT_CODE
- name: Combine coverage reports
if: matrix.go.report == true && github.ref == 'refs/heads/main'
run: |
modulesFound=$(find . -name 'go.mod' -type f -exec dirname {} \;)
count=0
pwd=$(pwd)
for mod in $modulesFound; do
cd $mod
/tmp/cc-test-reporter format-coverage -t gocov -o /tmp/coverage/$count.json --prefix $(go list) c.out
count=$((count+1))
cd $pwd
done
- name: Send results to code climate
if: matrix.go.report == true && github.ref == 'refs/heads/main'
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
exitCode=`cat /tmp/GO_EXIT_CODE`
if [ $exitCode -eq 0 ]; then
/tmp/cc-test-reporter sum-coverage /tmp/coverage/*.json -p 6
/tmp/cc-test-reporter upload-coverage
fi