forked from infrahq/infra
-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (99 loc) · 3.15 KB
/
ci-core.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: ci / core
on:
push: {}
jobs:
test-matrix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '1.19'
cache: true
- run: go mod download -x
- run: go install gotest.tools/gotestsum@v1.9.0
- run: mkdir -p /home/runner/reports
- uses: actions/cache@v3
with:
path: /home/runner/reports
key: read-go-test-reports-${{ github.run_number }}
restore-keys: go-test-reports-
- name: build matrix
id: build
run: |
(
echo -n "matrix="
go list ./... | gotestsum tool ci-matrix --debug \
--partitions 3 \
--timing-files '/home/runner/reports/*.log'
) >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.build.outputs.matrix }}
go-test:
needs: test-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.test-matrix.outputs.matrix) }}
name: "test ${{ matrix.description }}"
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_PASSWORD: password123
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports: ["127.0.0.1:5432:5432"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: "1.19"
cache: true
- run: go mod download -x
- run: go install gotest.tools/gotestsum@v1.8.2
- name: go test
run: |
echo Partition
echo '${{ toJson(matrix) }}'
mkdir -p /home/runner/reports
~/go/bin/gotestsum -ftestname \
--jsonfile=/home/runner/reports/test-run-${{github.run_number}}-${{matrix.id}}.log \
-- -race ${{matrix.packages}}
env:
POSTGRESQL_CONNECTION: "host=localhost port=5432 user=postgres dbname=postgres password=password123"
- name: Upload test reports
uses: actions/upload-artifact@v3
with:
name: test-reports
path: /home/runner/reports/*.log
retention-days: 5
- name: go test querylinter
working-directory: ./internal/tools/querylinter
run: ~/go/bin/gotestsum -ftestname ./...
- name: Check that tests leave a clean git checkout
run: |
# show and check changes to committed files
git diff --exit-code
# show and check for uncommitted files
git status --short; [[ "$(git status --short)" == "" ]]
test-collect-reports:
needs: go-test
runs-on: ubuntu-latest
steps:
- uses: actions/cache@v3
with:
path: /home/runner/reports
key: go-test-reports-${{ github.run_number }}
restore-keys: go-test-reports-
- uses: actions/download-artifact@v3
with:
name: test-reports
path: /home/runner/reports
- run: |
ls -lhR /home/runner/reports
find /home/runner/reports/ -mindepth 1 -mtime +3 -delete
ls -lhR /home/runner/reports