-
Notifications
You must be signed in to change notification settings - Fork 27
167 lines (140 loc) · 4.69 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Tests
on:
pull_request:
push:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Test TICS daily
env:
GOCOVERDIR: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && '/home/runner/work/microcluster/microcluster/cover' || '' }}
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
code-tests:
env:
CGO_CFLAGS: -I/home/runner/go/deps/dqlite/include/
CGO_LDFLAGS: -L/home/runner/go/deps/dqlite/.libs/
LD_LIBRARY_PATH: /home/runner/go/deps/dqlite/.libs/
CGO_LDFLAGS_ALLOW: (-Wl,-wrap,pthread_create)|(-Wl,-z,now)
name: Code
runs-on: ubuntu-22.04
strategy:
matrix:
go: ["1.22.x"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Dependency Review
uses: actions/dependency-review-action@v4
if: github.event_name == 'pull_request'
- name: Install Go (${{ matrix.go }})
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
- name: Check compatibility with min Go version (${{ matrix.go }})
run: |
set -eux
GOMIN="$(sed -n 's/^GOMIN=\([0-9.]\+\)$/\1/p' Makefile)"
go mod tidy -go="${GOMIN}"
- name: Install dependencies
run: |
set -eux
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
shellcheck pkg-config autoconf automake libtool make libuv1-dev libsqlite3-dev liblz4-dev
- name: Build dependencies
run: |
set -eux
make deps
- name: Run static analysis
run: |
set -eux
make check-static
make -C example check-static
- name: Make GOCOVERDIR
run: mkdir -p "${GOCOVERDIR}"
if: env.GOCOVERDIR != ''
- name: Unit tests (all)
run: |
set -eux
make check-unit
make -C example check-unit
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-unit
path: ${{env.GOCOVERDIR}}
if: env.GOCOVERDIR != ''
- name: Example system tests
run: |
set -eux
make -C example
cd example/test
CLUSTER_VERBOSE=1 ./main.sh
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-example-system
path: ${{env.GOCOVERDIR}}
if: env.GOCOVERDIR != ''
- name: Upload TIOBE TICS dependencies
uses: actions/upload-artifact@v4
with:
name: system-tiobe-tics-deps
path: |
/home/runner/go/bin/microd
/home/runner/go/bin/microctl
/home/runner/go/bin/dqlite
retention-days: 1
tics:
name: Tiobe TICS
runs-on: ubuntu-22.04
needs: code-tests
if: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && github.ref_name == 'v3' && github.repository == 'canonical/microcluster' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# A non-shallow clone is needed for the Differential ShellCheck
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: ${{env.GOCOVERDIR}}
merge-multiple: true
- name: Download TIOBE TICS dependencies
uses: actions/download-artifact@v4
with:
name: system-tiobe-tics-deps
merge-multiple: true
path: /home/runner/go/bin
- name: Install dependencies
run: |
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
- name: Convert coverage files
run: |
go tool covdata textfmt -i="${GOCOVERDIR}" -o "${GOCOVERDIR}"/coverage.out
gocov convert "${GOCOVERDIR}"/coverage.out > "${GOCOVERDIR}"/coverage.json
gocov-xml < "${GOCOVERDIR}"/coverage.json > "${GOCOVERDIR}"/coverage-go.xml
go tool covdata percent -i="${GOCOVERDIR}"
- name: Run TICS
uses: tiobe/tics-github-action@v3
with:
mode: qserver
project: microcluster
viewerUrl: https://canonical.tiobe.com/tiobeweb/TICS/api/cfg?name=default
branchdir: ${{ github.workspace }}
ticsAuthToken: ${{ secrets.TICS_AUTH_TOKEN }}
installTics: true
calc: ALL
tmpdir: /tmp/tics