forked from akvorado/akvorado
-
Notifications
You must be signed in to change notification settings - Fork 1
283 lines (269 loc) Β· 7.84 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
---
name: CI
on:
push:
branches:
- main
tags:
- v*
pull_request:
schedule:
- cron: 0 7 1 * *
jobs:
dependabot:
name: π€ Check dependabot status
runs-on: ubuntu-latest
permissions: {}
if: "!startsWith(github.event.head_commit.message, 'build: update flake.nix')"
steps:
- name: Fetch dependabot metadata
if: ${{ github.actor == 'dependabot[bot]' && github.event_name == 'pull_request' }}
id: metadata
uses: dependabot/[email protected]
outputs:
package-ecosystem: ${{ steps.metadata.outputs.package-ecosystem }}
build-linux:
name: π§ Build and test on Linux
runs-on: ubuntu-latest
needs:
- dependabot
if: needs.dependabot.outputs.package-ecosystem != 'npm_and_yarn'
permissions:
contents: read
actions: write
services:
zookeeper:
image: bitnami/zookeeper:3.8
env:
ALLOW_ANONYMOUS_LOGIN: "yes"
ports:
- 2181:2181
kafka:
image: bitnami/kafka:3.5
env:
KAFKA_ZOOKEEPER_PROTOCOL: PLAINTEXT
KAFKA_CFG_BROKER_ID: "1"
KAFKA_CFG_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_CFG_LISTENERS: CLIENT://:9092,EXTERNAL://:9093
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CLIENT:PLAINTEXT,EXTERNAL:PLAINTEXT
KAFKA_CFG_ADVERTISED_LISTENERS: CLIENT://kafka:9092,EXTERNAL://localhost:9092
KAFKA_CFG_INTER_BROKER_LISTENER_NAME: CLIENT
ports:
- 9092:9093
redis:
image: bitnami/redis:7.0
env:
ALLOW_EMPTY_PASSWORD: "yes"
ports:
- 6379:6379
clickhouse:
image: clickhouse/clickhouse-server:23.8
ports:
- 9000:9000
env:
CI_AKVORADO_FUNCTIONAL_TESTS: "true"
steps:
# Setup
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
# Install dependencies
- name: Install dependencies
run: sudo apt-get install -qqy shared-mime-info curl
# Build and test
- name: Build
run: make && ./bin/akvorado version
- name: Go race tests
run: make test-race
- name: Run benchmark tests
run: make test-bench
- name: JS tests
run: make test-js
- name: Run coverage tests
run: make test-coverage
- uses: actions/upload-artifact@v3
with:
name: linux-coverage
if-no-files-found: error
path: |
test/go/coverage.xml
test/js/cobertura-coverage.xml
- name: Upload binary
uses: actions/upload-artifact@v3
with:
name: binary
path: bin/akvorado
if-no-files-found: error
build-macos:
name: π Build and test on MacOS
runs-on: macos-latest
needs:
- dependabot
if: needs.dependabot.outputs.package-ecosystem != 'npm_and_yarn'
permissions:
contents: read
steps:
# Setup
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
# Build and test
- name: Build
run: make && ./bin/akvorado version
- name: Tests
run: make test-coverage-go
- uses: actions/upload-artifact@v3
with:
name: macos-coverage
if-no-files-found: error
path: |
test/go/coverage.xml
test/js/cobertura-coverage.xml
coverage:
name: π Upload code coverage
needs:
- build-linux
- build-macos
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: linux-coverage
path: test/linux
- uses: actions/download-artifact@v3
with:
name: macos-coverage
path: test/macos
- name: Upload coverage
uses: codecov/codecov-action@v3
with:
token: bab8d6d9-e90c-4e37-b156-38a9a4c2108e # not ideal, but limited risk
files: ./test/linux/go/coverage.xml,./test/linux/js/cobertura-coverage.xml, ./test/macos/go/coverage.xml,./test/macos/js/cobertura-coverage.xml
flags: unittests
fail_ci_if_error: true
build-go:
name: π Build Go backend
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.20', 'stable' ]
needs:
- dependabot
if: needs.dependabot.outputs.package-ecosystem != 'npm_and_yarn'
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
go-version: ${{ matrix.go-version }}
- name: Build
run: make && ./bin/akvorado version
- name: Tests
run: make test || make test
build-js:
name: π Build JS frontend
runs-on: ubuntu-latest
needs:
- dependabot
if: needs.dependabot.outputs.package-ecosystem != 'go_modules'
permissions:
contents: read
strategy:
matrix:
node-version: [16, 18, 20]
steps:
- uses: actions/checkout@v4
- name: Setup
uses: ./.github/actions/setup
with:
setup-go: false
node-version: ${{ matrix.node-version }}
- name: Build and test JS frontend
run: make console/data/frontend test-js
docker:
name: π Build Docker images
needs:
- build-linux
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=schedule,pattern=main
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
platforms: ${{ startsWith(github.ref, 'refs/tags/') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:main
cache-to: type=inline
release:
name: π Publish release
needs:
- build-linux
- build-macos
- build-go
- build-js
- docker
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: write
actions: read
steps:
# Changelog
- uses: actions/checkout@v4
- name: Generate changelog
run: make changelog.md
# Get binary from build step
- name: Download binary
uses: actions/download-artifact@v3
with:
name: binary
# Build tarball for docker compose
- name: Build docker-compose "quick start"
run: |
sed -i s,akvorado:latest,akvorado:${GITHUB_REF_NAME#v}, docker/docker-compose*.yml
tar zcvf docker-compose-quickstart.tar.gz \
.env docker/* \
orchestrator/clickhouse/data/docker-entrypoint.sh \
config/*.yaml
# Publish release
- name: Publish release
uses: softprops/action-gh-release@v1
with:
body_path: changelog.md
draft: true
fail_on_unmatched_files: true
files: |
akvorado
docker-compose-quickstart.tar.gz