-
Notifications
You must be signed in to change notification settings - Fork 57
310 lines (274 loc) · 11.3 KB
/
packgen.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
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
name: packgen
on:
workflow_call:
push:
branches:
- main
paths:
- '.github/workflows/packgen.yml'
- '.github/matrix_includes_packgen.json'
- 'CMakeLists.txt'
- 'libs/crossplatform/**'
- 'libs/rtefsutils/**'
- 'libs/xmlreader/**'
- 'libs/xmltree/**'
- 'libs/xmltreeslim/**'
- 'tools/packgen/**'
- '!**/docs/**/*'
- '!**/*.md'
pull_request:
paths:
- '.github/workflows/packgen.yml'
- '.github/matrix_includes_packgen.json'
- 'CMakeLists.txt'
- 'libs/crossplatform/**'
- 'libs/rtefsutils/**'
- 'libs/xmlreader/**'
- 'libs/xmltree/**'
- 'libs/xmltreeslim/**'
- 'tools/packgen/**'
- '!**/*.md'
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
setup:
uses: Open-CMSIS-Pack/devtools/.github/workflows/shared_setup_env.yml@main
with:
run_if: ${{ fromJSON((github.event_name == 'pull_request') || (github.event_name == 'workflow_dispatch') || (github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/packgen/')) || ((github.event.schedule != '') && (!github.event.repository.private))) }}
matrix_prep:
needs: setup
uses: Open-CMSIS-Pack/devtools/.github/workflows/shared_matrix_prep.yml@main
with:
workflow_name: packgen
build:
needs: [ setup, matrix_prep ]
runs-on: ${{ matrix.runs_on }}
timeout-minutes: 15
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }}
steps:
- name: Harden Runner
if: ${{ !github.event.repository.private }}
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout devtools
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
fetch-depth: 0
# https://github.com/Open-CMSIS-Pack/devtools-build-action
- name: Build
uses: Open-CMSIS-Pack/devtools-build-action@79c0fc7d7bc834eb12aa1e319756deab0dda773f # arm64
id: devtools-build
with:
target: packgen
arch: ${{ matrix.arch }}
- name: Archive packgen
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: packgen-${{ matrix.target }}-${{ matrix.arch }}
path: ./build/tools/packgen/${{ matrix.target }}-${{ matrix.arch }}/Release/${{ matrix.binary }}
retention-days: ${{ needs.setup.outputs.retention_days }}
if-no-files-found: error
release:
if: |
github.event_name == 'release' &&
startsWith(github.ref, 'refs/tags/tools/packgen/')
needs: [ build, unittest ]
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Checkout devtools
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Create distribution folders
run: |
mkdir -p tools/packgen/distribution/bin tools/packgen/distribution/doc/examples
cp tools/packgen/docs/LICENSE.txt tools/packgen/distribution/
cp tools/packgen/docs/packgen.md tools/packgen/distribution/doc/
cp -r tools/packgen/test/data/CMakeTestProject/ tools/packgen/distribution/doc/examples/
cp -r tools/packgen/test/data/CMakeTestMultipleBuilds/ tools/packgen/distribution/doc/examples/
- name: Download packgen linux-amd64
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packgen-linux-amd64
path: tools/packgen/distribution/bin/linux-amd64/
- name: Download packgen linux arm64
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packgen-linux-arm64
path: tools/packgen/distribution/bin/linux-arm64/
- name: Download packgen macos-amd64
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packgen-darwin-amd64
path: tools/packgen/distribution/bin/darwin-amd64/
- name: Download packgen macos-arm64
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packgen-darwin-arm64
path: tools/packgen/distribution/bin/darwin-arm64/
- name: Download packgen windows-amd64
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packgen-windows-amd64
path: tools/packgen/distribution/bin/windows-amd64/
- name: Download packgen windows-arm64
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: packgen-windows-arm64
path: tools/packgen/distribution/bin/windows-arm64/
- name: Zip distribution folder
run: zip -r packgen.zip *
working-directory: tools/packgen/distribution
- name: Attach zip archive to release assets
uses: svenstaro/upload-release-action@04733e069f2d7f7f0b4aebc4fbdbce8613b03ccd # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: tools/packgen/distribution/packgen.zip
tag: ${{ github.ref }}
overwrite: true
asset_name: packgen.zip
unittest:
needs: [ setup, matrix_prep ]
runs-on: ${{ matrix.runs_on }}
timeout-minutes: 15
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.matrix_prep.outputs.matrix) }}
steps:
- name: Harden Runner
if: ${{ !github.event.repository.private }}
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Checkout devtools
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
# https://github.com/Open-CMSIS-Pack/devtools-build-action
- name: Build PackGenUnitTests
uses: Open-CMSIS-Pack/devtools-build-action@79c0fc7d7bc834eb12aa1e319756deab0dda773f # arm64
with:
target: PackGenUnitTests
build_type: Debug
arch: ${{ matrix.arch }}
- name: Run packgen unit tests
if: (matrix.arch != 'arm64')
run: |
ctest -C Debug -R PackGenUnitTests
working-directory: ./build
- name: Archive unit tests results
if: always() && (matrix.arch != 'arm64')
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: unit_test_result_packgen-${{ matrix.target }}-${{ matrix.arch }}
path: ./build/test_reports/packgenunittests-*.xml
retention-days: ${{ needs.setup.outputs.retention_days }}
if-no-files-found: error
coverage:
if: |
(github.event_name == 'pull_request') ||
(github.event_name == 'workflow_dispatch') ||
(github.event_name == 'push') ||
(github.event_name == 'release' && startsWith(github.ref, 'refs/tags/tools/packgen/')) ||
((github.event.schedule != '') && (!github.event.repository.private))
env:
lcov_base: https://github.com/linux-test-project/lcov/releases/download/v1.15/
lcov_installer: lcov-1.15.tar.gz
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Harden Runner
if: ${{ !github.event.repository.private }}
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Install linux deps
run: |
sudo apt-get update
sudo apt-get install \
lcov
- name: Checkout devtools
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
# https://github.com/Open-CMSIS-Pack/devtools-build-action
- name: Build PackGenUnitTests
uses: Open-CMSIS-Pack/devtools-build-action@79c0fc7d7bc834eb12aa1e319756deab0dda773f # arm64
with:
add_cmake_variables: -DCOVERAGE=ON
arch: amd64
build_type: Debug
target: PackGenUnitTests
- name: Run PackGenUnitTests
run: |
ctest -V -C Debug -R PackGenUnitTests
working-directory: ./build
- name: Get retention days
id: var
run: |
echo "retention_days=$(echo '${{ (!github.event.repository.private && (github.event_name == 'push' || github.event.schedule != '')) && '7' || '1' }}')" >> $GITHUB_OUTPUT
- name: Archive unit tests results
if: (github.event_name == 'push')
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: unit_test_result_packgen-linux-amd64
path: ./build/test_reports/packgenunittests-*.xml
retention-days: ${{ steps.var.outputs.retention_days }}
if-no-files-found: error
# Needs to be removed once the bug is resolved
# lcov reporting 1.14 on 1.15 version
# https://groups.google.com/g/linux.debian.bugs.dist/c/a9SZGCENJ2s?pli=1
- name: Setup lcov1.15
run: |
wget -q ${{ env.lcov_base }}/${{ env.lcov_installer }}
tar -xvf ${{ env.lcov_installer }}
working-directory: ./build/tools/packgen
- name: Generate coverage report
run: |
lcov-1.15/bin/lcov --rc lcov_branch_coverage=1 --rc geninfo_no_exception_branch=1 -c --directory . --output-file full_coverage.info
lcov-1.15/bin/lcov --rc lcov_branch_coverage=1 --rc geninfo_no_exception_branch=1 -e full_coverage.info '/tools/packgen/include/*' '*/tools/packgen/src/*' -o coverage_packgen.info
genhtml coverage_packgen.info --output-directory coverage_packgen --branch-coverage
working-directory: ./build/tools/packgen/
- name: Upload Report to Codecov
if: ${{ !github.event.repository.private }}
uses: Wandalen/wretry.action@6feedb7dedadeb826de0f45ff482b53b379a7844 # v3.5.0
with:
action: codecov/codecov-action@v4
with: |
files: ./build/tools/packgen/coverage_packgen.info
fail_ci_if_error: true
flags: packgen-cov
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
attempt_limit: 3
attempt_delay: 5000
- name: Archive coverage report
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: coverage-report-packgen
path: |
./build/tools/packgen/coverage_packgen/
./build/tools/packgen/coverage_packgen.info
retention-days: ${{ steps.var.outputs.retention_days }}
if-no-files-found: error
test-results-preparation:
name: "Publish Tests Results"
needs: [ unittest ]
runs-on: ubuntu-22.04
steps:
- name: Harden Runner
if: ${{ !github.event.repository.private }}
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: Event File
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: Event File packgen
path: ${{ github.event_path }}