-
Notifications
You must be signed in to change notification settings - Fork 6
256 lines (247 loc) · 8.66 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# SPDX-FileCopyrightText: 2023 Siemens AG
#
# SPDX-License-Identifier: Apache-2.0
#
# Author: Michael Adler <[email protected]>
---
name: CI
on: [push, pull_request, workflow_dispatch]
jobs:
build:
name: Build
runs-on: ubuntu-latest
container: golang:1.23.2@sha256:ad5c126b5cf501a8caef751a243bb717ec204ab1aa56dc41dc11be089fafcb4f
strategy:
matrix:
# even though Windows is not officially supported, we want it to at least compile successfully
goos: [linux, windows]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Golang caches
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Disable git security features
run: git config --global safe.directory '*'
- run: .ci/setup-build.sh
- name: build for ${{ matrix.goos }}
run: just build
env:
GOOS: ${{ matrix.goos }}
test:
name: Test
runs-on: ubuntu-latest
container: golang:1.23.2@sha256:ad5c126b5cf501a8caef751a243bb717ec204ab1aa56dc41dc11be089fafcb4f
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Golang caches
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- run: make test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
test-postgres:
runs-on: ubuntu-latest
name: Test PostgreSQL
container: golang:1.23.2@sha256:ad5c126b5cf501a8caef751a243bb717ec204ab1aa56dc41dc11be089fafcb4f
services:
postgres:
image: postgres:17@sha256:8d3be35b184e70d81e54cbcbd3df3c0b47f37d06482c0dd1c140db5dbcc6a808
env:
# see https://hub.docker.com/_/postgres
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_DB: wfx
POSTGRES_USER: wfx
POSTGRES_PASSWORD: secret
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 3s
--health-timeout 5s
--health-retries 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Golang caches
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- run: .ci/setup-postgres.sh
- run: just postgres-integration-test
env:
PGHOST: postgres
PGPORT: 5432
PGDATABASE: wfx
PGUSER: wfx
PGPASSWORD: secret
PGSSLMODE: disable
- name: Upload coverage to Codecov
# note: v4 is buggy and fails to upload this report
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
test-mysql:
runs-on: ubuntu-latest
name: Test MySQL
container: golang:1.23.2@sha256:ad5c126b5cf501a8caef751a243bb717ec204ab1aa56dc41dc11be089fafcb4f
services:
mysql:
image: mysql:8-debian@sha256:49f4fcb0087318aa1c222c7e8ceacbb541cdc457c6307d45e6ee4313f4902e33
env:
# see https://hub.docker.com/_/mysql
MYSQL_DATABASE: wfx
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: wfx
MYSQL_PASSWORD: secret
MYSQL_HOST: mysql
# Set health checks to wait until mysql has started
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval 3s
--health-timeout 5s
--health-retries 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Setup Golang caches
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- run: .ci/setup-mysql.sh
- run: just mysql-integration-test
env:
MYSQL_DATABASE: wfx
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: wfx
MYSQL_PASSWORD: secret
MYSQL_HOST: mysql
- name: Upload coverage to Codecov
# note: v4 is buggy and fails to upload this report
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
cli-tests:
name: CLI Tests
runs-on: ubuntu-latest
container: golang:1.23.2@sha256:ad5c126b5cf501a8caef751a243bb717ec204ab1aa56dc41dc11be089fafcb4f
services:
mysql:
image: mysql:8-debian@sha256:49f4fcb0087318aa1c222c7e8ceacbb541cdc457c6307d45e6ee4313f4902e33
env:
# see https://hub.docker.com/_/mysql
MYSQL_DATABASE: wfx
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: wfx
MYSQL_PASSWORD: secret
MYSQL_HOST: mysql
# Set health checks to wait until mysql has started
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval 3s
--health-timeout 5s
--health-retries 20
postgres:
image: postgres:17@sha256:8d3be35b184e70d81e54cbcbd3df3c0b47f37d06482c0dd1c140db5dbcc6a808
env:
# see https://hub.docker.com/_/postgres
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_DB: wfx
POSTGRES_USER: wfx
POSTGRES_PASSWORD: secret
POSTGRES_HOST_AUTH_METHOD: trust
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 3s
--health-timeout 5s
--health-retries 20
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: "true"
- name: Setup Golang caches
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- run: .ci/setup-cli-tests.sh
- name: Disable git security features
run: git config --global safe.directory '*'
- name: build wfx
run: make
- name: install wfx
run: make install
- name: run tests
env:
PGHOST: postgres
PGPORT: 5432
PGUSER: wfx
PGPASSWORD: secret
PGDATABASE: wfx
MYSQL_DATABASE: wfx
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: wfx
MYSQL_PASSWORD: secret
MYSQL_HOST: mysql
working-directory: test
run: bats .
lint:
runs-on: ubuntu-latest
name: Lint
container: golang:1.23.2@sha256:ad5c126b5cf501a8caef751a243bb717ec204ab1aa56dc41dc11be089fafcb4f
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Disable git security features
run: git config --global safe.directory '*'
- run: .ci/setup-lint.sh
- run: just lint
reuse:
runs-on: ubuntu-latest
name: Reuse
container: fsfe/reuse:4.0.3@sha256:7e0ca22c55f73947d9ebc77deacc79357deff0c6abc63acdd87222f633718919
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- run: reuse lint || true # just a warning
generate:
name: Generate Code
runs-on: ubuntu-latest
container: golang:1.23.2@sha256:ad5c126b5cf501a8caef751a243bb717ec204ab1aa56dc41dc11be089fafcb4f
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install packages
run: .ci/setup-generate.sh
- name: Disable git security features
run: git config --global safe.directory '*'
- run: just generate
- run: git diff --exit-code