-
Notifications
You must be signed in to change notification settings - Fork 1
326 lines (286 loc) · 10.4 KB
/
ci.yml
File metadata and controls
326 lines (286 loc) · 10.4 KB
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: CI (c++) Build and Test
on:
workflow_dispatch:
inputs:
protocol:
description: 'RPC Protocol to test'
required: true
default: 'rpc_v2'
type: choice
options:
- rpc_v2
- legacy
push:
branches: [ main, next ]
pull_request:
branches: [ main, next ]
defaults:
run:
shell: bash
env:
HUSKY: 0
MOCK_PATH: ${{ github.workspace }}/mock-firebolt
MOCK_BRANCH: topic/changes-for-bidirectional
MOCK_SHA1SUM: 1fec7b75190e75ac8ea8ebf9f3e00c0a070b2566
jobs:
build_docker:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/firebolt-client-ci
tags: type=sha
- name: Checkout Code
uses: actions/checkout@v4
- name: Get Transport Version for Build-Arg
id: transport_version
run: echo "version=$(cat ${{ github.workspace }}/.transport.version)" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: .github/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
DEPS_TRANSPORT_V=${{ steps.transport_version.outputs.version }}
DEPS_TRANSPORT_PROTOCOL=${{ github.event.inputs.protocol || 'rpc_v2' }}
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
format_check:
permissions:
contents: read
packages: read
needs: [build_docker]
runs-on: ubuntu-latest
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Run clang-format check
run: |
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
bash -c " \
set -e \
&& git ls-files -- '*.cpp' '*.h' | xargs clang-format --dry-run --Werror \
"
build_project:
permissions:
contents: read
packages: read
needs: [build_docker]
runs-on: ubuntu-latest
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version
run: |
VERSION=$(git describe --tags --dirty --match "v[0-9]*")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version: $VERSION"
- name: Configure Project
run: |
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
bash -c " \
set -e \
&& cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Debug \
-DENABLE_TESTS=ON \
&& cp docs/openrpc/the-spec/firebolt-open-rpc.json build/test/ \
"
- name: Build Project
run: |
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
bash -c " \
set -e \
&& cmake --build build --parallel \
"
- name: Install Project to build/install
run: |
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
bash -c " \
set -e \
&& cmake --install build --prefix build/install \
"
- name: Upload build directory
uses: actions/upload-artifact@v4
with:
name: build-dir
path: ${{ github.workspace }}/build
unit_tests:
permissions:
contents: read
packages: read
needs: [build_docker, build_project]
runs-on: ubuntu-latest
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Download build directory
uses: actions/download-artifact@v4
with:
name: build-dir
path: ${{ github.workspace }}/build
- name: Run Unit Tests
run: |
chmod +x ${{ github.workspace }}/build/test/utApp
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
bash -c " \
set -e \
&& ctest --test-dir build/test \
"
- name: Generate Coverage Report
run: |
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
bash -c " \
set -e \
&& cd build \
&& mkdir -p coverage \
&& gcovr -r .. \
--exclude '.*/test/.*\.h' \
--exclude '.*/test/.*\.cpp' \
--decisions \
--medium-threshold 50 --high-threshold 75 \
--html-details coverage/index.html \
--cobertura coverage.cobertura.xml \
"
- name: Upload Coverage Report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ${{ github.workspace }}/build/coverage/
- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: build/coverage.cobertura.xml
badge: true
hide_complexity: true
format: markdown
output: both
thresholds: "50 75"
fail_below_min: false
- name: Add coverage summary to job summary
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
component_tests:
permissions:
contents: read
packages: read
needs: [build_docker, build_project]
runs-on: ubuntu-latest
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Download build directory
uses: actions/download-artifact@v4
with:
name: build-dir
path: ${{ github.workspace }}/build
- name: Setup Mock-Firebolt
id: setup-mock
uses: ./.github/actions/setup-mock
- name: Restore Mock-Firebolt Cache
uses: actions/cache@v4
with:
path: ${{ env.MOCK_PATH }}
key: ${{ runner.os }}-mock-${{ steps.setup-mock.outputs.deps_cache_key }}
- name: Run Component Tests
run: |
chmod +x ${{ github.workspace }}/build/test/ctApp
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace -v ${{ env.MOCK_PATH }}:/mock ${{ needs.build_docker.outputs.image_tag }} \
./.github/scripts/run-component-tests.sh \
--mock /mock \
--protocol ${{ github.event.inputs.protocol || 'rpc_v2' }} \
--config /workspace/.github/mock-firebolt/config.json \
--openrpc /workspace/docs/openrpc/the-spec/firebolt-open-rpc.json \
--app-openrpc /workspace/docs/openrpc/the-spec/firebolt-app-open-rpc.json \
--test-exe /workspace/build/test/ctApp
api_test_app:
permissions:
contents: read
packages: read
needs: [build_docker, build_project]
runs-on: ubuntu-latest
steps:
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Code
uses: actions/checkout@v4
- name: Download build directory
uses: actions/download-artifact@v4
with:
name: build-dir
path: ${{ github.workspace }}/build
- name: Build api-test-app standalone
run: |
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace ${{ needs.build_docker.outputs.image_tag }} \
bash -c " \
set -e \
&& cd test/api_test_app \
&& cmake -B build -S . \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH=/workspace/build/install \
&& cmake --build build --parallel \
"
- name: Setup Mock-Firebolt
id: setup-mock
uses: ./.github/actions/setup-mock
- name: Restore Mock-Firebolt Cache
uses: actions/cache@v4
with:
path: ${{ env.MOCK_PATH }}
key: ${{ runner.os }}-mock-${{ steps.setup-mock.outputs.deps_cache_key }}
- name: Run api-test-app with mock server
run: |
chmod +x ${{ github.workspace }}/test/api_test_app/build/api-test-app
docker run --rm --user "$(id -u):$(id -g)" -v ${{ github.workspace }}:/workspace -v ${{ env.MOCK_PATH }}:/mock ${{ needs.build_docker.outputs.image_tag }} \
./.github/scripts/run-api-test-app.sh \
--mock /mock \
--config /workspace/.github/mock-firebolt/config.json \
--openrpc /workspace/docs/openrpc/the-spec/firebolt-open-rpc.json \
--app-openrpc /workspace/docs/openrpc/the-spec/firebolt-app-open-rpc.json \
--test-exe /workspace/test/api_test_app/build/api-test-app