-
Notifications
You must be signed in to change notification settings - Fork 118
459 lines (456 loc) · 20.3 KB
/
CI-linux.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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
on:
workflow_call:
inputs:
os:
required: true
type: string
distro:
required: true
type: string
compiler-family:
required: true
type: string
compiler-version:
required: true
type: string
compiler-CC:
required: true
type: string
compiler-CXX:
required: true
type: string
compiler-GCOV:
type: string
compiler-CLANG_TIDY:
type: string
flavor:
required: true
type: string
enable-sample-based-testing:
type: boolean
default: false
rpuu-cache-key:
type: string
ECO:
type: string
secrets:
SONAR_TOKEN:
SONAR_PROJECT_KEY:
SONAR_ORGANIZATION:
env:
RPUU_DST: ${{ github.workspace }}/raw-camera-samples/raw.pixls.us-unique
COVERAGE_REPORT_PREFIX: rawspeed-coverage # relative to the workspace!
jobs:
linux:
runs-on: ubuntu-latest
env:
SONAR_SCANNER_VERSION: 5.0.1.3006
name: ${{ inputs.distro }}.${{ inputs.compiler-family }}${{ inputs.compiler-version }}.${{ inputs.flavor }}
container:
image: ${{ inputs.distro }}
options: --tmpfs /tmp:exec --tmpfs /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}:exec
steps:
- name: Configure APT
timeout-minutes: 1
run: |
set -xe
tee /etc/dpkg/dpkg.cfg.d/force-unsafe-io > /dev/null <<EOT
force-unsafe-io
EOT
tee /etc/apt/apt.conf.d/tmpfs > /dev/null <<EOT
Dir::Cache::Archives "/tmp/apt/archives";
APT::ExtractTemplates::TempDir "/tmp/apt/temp";
EOT
mkdir -p /tmp/apt/archives
tee /etc/apt/apt.conf.d/80retry > /dev/null <<EOT
Acquire::Retries "10";
EOT
tee /etc/apt/apt.conf.d/80recommends > /dev/null <<EOT
APT::Install-Recommends "false";
EOT
tee /etc/apt/apt.conf.d/80suggests > /dev/null <<EOT
APT::Install-Suggests "false";
EOT
tee /etc/apt/apt.conf.d/80forceyes > /dev/null <<EOT
APT::Get::Assume-Yes "true";
EOT
tee /etc/apt/apt.conf.d/80fixmissing > /dev/null <<EOT
APT::Get::Fix-Missing "true";
EOT
rm -rf /etc/apt/sources.list*
if [ "${{ inputs.distro }}" = "debian:unstable-slim" ]; then
tee /etc/apt/sources.list > /dev/null <<EOT
deb http://debian-archive.trafficmanager.net/debian unstable main
EOT
elif [ "${{ inputs.distro }}" = "debian:trixie-slim" ]; then
tee /etc/apt/sources.list > /dev/null <<EOT
deb http://debian-archive.trafficmanager.net/debian trixie main
deb http://debian-archive.trafficmanager.net/debian trixie-updates main
deb http://debian-archive.trafficmanager.net/debian-security trixie-security main
deb http://debian-archive.trafficmanager.net/debian trixie-backports main
EOT
elif [ "${{ inputs.distro }}" = "debian:bookworm-slim" ]; then
tee /etc/apt/sources.list > /dev/null <<EOT
deb http://debian-archive.trafficmanager.net/debian bookworm main
deb http://debian-archive.trafficmanager.net/debian bookworm-updates main
deb http://debian-archive.trafficmanager.net/debian-security bookworm-security main
deb http://debian-archive.trafficmanager.net/debian bookworm-backports main
EOT
fi
- name: Update base packages
timeout-minutes: 1
env:
DEBIAN_FRONTEND: noninteractive
COMPILER_FAMILY: ${{ inputs.compiler-family }}
FLAVOR: ${{ inputs.flavor }}
run: |
set -xe
rm -rf /var/lib/apt/lists/*
apt update
apt install eatmydata
eatmydata apt upgrade
- name: Install necessary packages
timeout-minutes: 1
env:
DEBIAN_FRONTEND: noninteractive
COMPILER_FAMILY: ${{ inputs.compiler-family }}
FLAVOR: ${{ inputs.flavor }}
ENABLE_SAMPLE_BASED_TESTING: ${{ inputs.enable-sample-based-testing }}
run: |
set -xe
eatmydata apt install ca-certificates \
cmake \
git \
googletest \
libjpeg-dev \
libpugixml-dev \
libxml2-utils \
ninja-build \
zlib1g-dev
if [ "$COMPILER_FAMILY" = "GNU" ]; then
eatmydata apt install g++-${{ inputs.compiler-version }} \
gcc \
gcc-${{ inputs.compiler-version }}
fi
if [ "$COMPILER_FAMILY" = "LLVM" ]; then
eatmydata apt install clang-${{ inputs.compiler-version }} \
libomp-${{ inputs.compiler-version }}-dev
fi
if [ "$ENABLE_SAMPLE_BASED_TESTING" = "true" ]; then
eatmydata apt install zstd
fi
if [ "$FLAVOR" = "ClangTidy" ]; then
eatmydata apt install clang-format-${{ inputs.compiler-version }} clang-tidy-${{ inputs.compiler-version }}
eatmydata apt install curl gpg
echo 'deb https://ftp.gwdg.de//pub/opensuse/repositories/graphics%3A/darktable%3A/master/Debian_Unstable/ /' | tee /etc/apt/sources.list
curl -fsSL https://download.opensuse.org/repositories/graphics:darktable:master/Debian_Unstable/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/graphics_darktable_master.gpg > /dev/null
apt update
eatmydata apt install rawspeed-clang-tidy-module
fi
if [ "$FLAVOR" = "ClangStaticAnalysis" ] || [ "$FLAVOR" = "ClangCTUStaticAnalysis" ]; then
eatmydata apt install clang-tools-${{ inputs.compiler-version }} \
curl \
libxml2-dev \
libxslt1-dev \
make \
python3-dev \
python3-lxml \
python3-pip-whl \
python3-portalocker \
python3-psutil \
python3-setuptools \
python3-venv \
python3-virtualenv \
python3-wheel \
python3-yaml \
xz-utils
fi
eatmydata apt clean
dpkg-divert --add --rename --divert /usr/bin/ld.original /usr/bin/ld
if [ "$FLAVOR" = "ClangStaticAnalysis" ] || [ "$FLAVOR" = "ClangCTUStaticAnalysis" ]; then
ln -s /usr/bin/${{ inputs.compiler-CC }} /usr/local/bin/clang
ln -s /usr/bin/${{ inputs.compiler-CXX }} /usr/local/bin/clang++
ln -s /usr/bin/${{ inputs.compiler-CC }} /usr/local/bin/gcc
ln -s /usr/bin/${{ inputs.compiler-CXX }} /usr/local/bin/g++
ln -s /usr/bin/${{ inputs.compiler-CC }} /usr/local/bin/x86_64-linux-gnu-gcc
ln -s /usr/bin/${{ inputs.compiler-CXX }} /usr/local/bin/x86_64-linux-gnu-g++
fi
ln -s /usr/bin/ld.gold /usr/bin/ld
- name: Configure git
timeout-minutes: 1
run: |
set -xe
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Fetch/Checkout RawSpeed git repo
timeout-minutes: 1
uses: actions/checkout@v4
with:
path: 'rawspeed'
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache raw.pixls.us masterset
timeout-minutes: 1
if: inputs.enable-sample-based-testing
uses: actions/cache/restore@v4
with:
path: ${{ env.RPUU_DST }}
key: ${{ inputs.rpuu-cache-key }}
fail-on-cache-miss: true
- name: Fetch/Checkout CodeChecker git repo (for clang static analysis)
timeout-minutes: 1
if: inputs.flavor == 'ClangStaticAnalysis' || inputs.flavor == 'ClangCTUStaticAnalysis'
uses: actions/checkout@v4
with:
repository: 'Ericsson/codechecker'
path: 'codechecker'
fetch-depth: '1'
- name: Install CodeChecker (for clang static analysis)
timeout-minutes: 1
if: inputs.flavor == 'ClangStaticAnalysis' || inputs.flavor == 'ClangCTUStaticAnalysis'
env:
CC: ${{ inputs.compiler-CC }}
CXX: ${{ inputs.compiler-CXX }}
run: |
set -xe
cd codechecker
make venv
. $PWD/venv/bin/activate
pip install setuptools
BUILD_LOGGER_64_BIT_ONLY=YES BUILD_UI_DIST=NO make package
export PATH="$PWD/build/CodeChecker/bin:$PATH"
- name: Initialize CodeQL (for CodeQL static analysis)
timeout-minutes: 1
if: inputs.flavor == 'CodeQLAnalysis'
uses: github/codeql-action/init@v3
with:
languages: cpp
- name: Set up JDK 11 (for SonarCloud static analysis)
timeout-minutes: 1
if: inputs.flavor == 'SonarCloudStaticAnalysis' && github.repository == 'darktable-org/rawspeed' && github.event_name != 'pull_request' && github.ref_type == 'branch' && (github.ref_name == 'develop' || github.ref_name == 'stable')
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 21
- name: Download and set up sonar-scanner (for SonarCloud static analysis)
timeout-minutes: 1
if: inputs.flavor == 'SonarCloudStaticAnalysis' && github.repository == 'darktable-org/rawspeed' && github.event_name != 'pull_request' && github.ref_type == 'branch' && (github.ref_name == 'develop' || github.ref_name == 'stable')
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
set -xe
rm -rf /var/lib/apt/lists/*
eatmydata apt update
eatmydata apt install curl unzip
eatmydata apt clean
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
- name: Verify that the source code is properly formatted
timeout-minutes: 1
if: inputs.flavor == 'ClangTidy'
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
run: |
set -xe
cd "$SRC_DIR"
git ls-tree -r --name-only HEAD | grep -vf .clang-format-ignore | xargs clang-format-${{ inputs.compiler-version }} --verbose --dry-run -Werror
- name: Configure
timeout-minutes: 1
env:
CC: ${{ inputs.compiler-CC }}
CXX: ${{ inputs.compiler-CXX }}
CLANG_TIDY: ${{ inputs.compiler-CLANG_TIDY }}
GCOV: ${{ inputs.compiler-GCOV }}
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
RPUU_DST: ${{ env.RPUU_DST }}
ECO: ${{ inputs.ECO }} -DALLOW_DOWNLOADING_GOOGLETEST=ON -DALLOW_DOWNLOADING_GOOGLEBENCHMARK=ON -DUSE_CLANG_TIDY=${{ inputs.flavor == 'ClangTidy' }} -DRAWSPEED_ENABLE_SAMPLE_BASED_TESTING=${{ inputs.enable-sample-based-testing }}
FLAVOR: ${{ inputs.flavor }}
TARGET: configure
run: |
set -xe
cmake -E make_directory "${BUILD_DIR}"
cmake -E make_directory "${INSTALL_PREFIX}"
export ECO="${ECO} -DRAWSPEED_REFERENCE_SAMPLE_ARCHIVE=${RPUU_DST}"
"${SRC_DIR}/.ci/ci-script.sh"
- name: Build
timeout-minutes: ${{ inputs.flavor != 'ClangTidy' && (inputs.flavor != 'CodeQLAnalysis' && 7 || 12) || 25 }}
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: build
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
- name: Test (unit tests)
timeout-minutes: 1
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: test
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
- name: Collect source coverage data (unit tests)
timeout-minutes: 1
if: inputs.flavor == 'Coverage'
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
COVERAGE_REPORT_PREFIX: ${{ github.workspace }}/${{ env.COVERAGE_REPORT_PREFIX }}/linux
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: coverage
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
mkdir -p "${COVERAGE_REPORT_PREFIX}"
mv "${BUILD_DIR}/gcov-reports-unittest" "${COVERAGE_REPORT_PREFIX}/unittests"
- name: Test (benchmarks)
timeout-minutes: 1
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: test_benchmarks
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
- name: Collect source coverage data (benchmarks)
timeout-minutes: 1
if: inputs.flavor == 'Coverage'
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
COVERAGE_REPORT_PREFIX: ${{ github.workspace }}/${{ env.COVERAGE_REPORT_PREFIX }}/linux
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: coverage_benchmarks
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
mkdir -p "${COVERAGE_REPORT_PREFIX}"
mv "${BUILD_DIR}/gcov-reports-benchmarks" "${COVERAGE_REPORT_PREFIX}/benchmarks"
- name: Test (integration)
timeout-minutes: ${{ inputs.flavor != 'Coverage' && 2 || 31 }}
if: inputs.enable-sample-based-testing
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: test_integration
OMP_NUM_THREADS: 1
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
- name: Collect source coverage data (integration)
timeout-minutes: 1
if: inputs.flavor == 'Coverage' && inputs.enable-sample-based-testing
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
COVERAGE_REPORT_PREFIX: ${{ github.workspace }}/${{ env.COVERAGE_REPORT_PREFIX }}/linux
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: coverage_integration
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
mkdir -p "${COVERAGE_REPORT_PREFIX}"
mv "${BUILD_DIR}/gcov-reports-rsa" "${COVERAGE_REPORT_PREFIX}/integration"
- if: inputs.flavor == 'Coverage'
timeout-minutes: 1
name: Cache code coverage (linux reports)
uses: actions/cache/save@v4
with:
path: ${{ env.COVERAGE_REPORT_PREFIX }}/linux # relative path!
key: coverage-${{ github.sha }}-linux
enableCrossOsArchive: true
- name: Install
timeout-minutes: 1
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
FLAVOR: ${{ inputs.flavor }}
TARGET: install
run: |
set -xe
"${SRC_DIR}/.ci/ci-script.sh"
- name: Perform clang static analysis (plain mode)
timeout-minutes: 25
if: inputs.flavor == 'ClangStaticAnalysis'
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
CC: ${{ inputs.compiler-CC }}
CXX: ${{ inputs.compiler-CXX }}
run: |
set -xe
. "$PWD/codechecker/venv/bin/activate"
export PATH="$PWD/codechecker/build/CodeChecker/bin:$PATH"
set +e
CodeChecker check --logfile "${BUILD_DIR}/compile_commands.json" --analyzers clangsa --jobs "$(nproc --all)" --file "${SRC_DIR}/*" --disable deadcode.DeadStores -o "${BUILD_DIR}/codechecker_results"
bugs=$?
CodeChecker parse -e html "${BUILD_DIR}/codechecker_results" -o "${BUILD_DIR}/codechecker_report"
set -xe
tar -cvJ -f "$GITHUB_WORKSPACE/codechecker_report.tar.xz" -C "${BUILD_DIR}" "codechecker_report"
[ $bugs -eq 0 ] || exit 1
- name: Upload results of clang static analysis (plain mode)
timeout-minutes: 1
if: failure()
uses: actions/upload-artifact@v4
with:
name: codechecker_report.tar.xz
path: ${{ github.workspace }}/codechecker_report.tar.xz
- name: Perform clang static analysis (CTU mode)
timeout-minutes: 25
if: inputs.flavor == 'ClangCTUStaticAnalysis'
env:
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
CC: ${{ inputs.compiler-CC }}
CXX: ${{ inputs.compiler-CXX }}
run: |
set -xe
. "$PWD/codechecker/venv/bin/activate"
export PATH="$PWD/codechecker/build/CodeChecker/bin:$PATH"
set +e
CodeChecker check --ctu --ctu-reanalyze-on-failure --logfile "${BUILD_DIR}/compile_commands.json" --analyzers clangsa --jobs "$(nproc --all)" --file "${SRC_DIR}/*" --disable deadcode.DeadStores -o "${BUILD_DIR}/codechecker_ctu_results"
bugs=$?
CodeChecker parse -e html "${BUILD_DIR}/codechecker_ctu_results" -o "${BUILD_DIR}/codechecker_ctu_report"
set -xe
tar -cvJ -f "$GITHUB_WORKSPACE/codechecker_ctu_report.tar.xz" -C "${BUILD_DIR}" "codechecker_ctu_report"
[ $bugs -eq 0 ] || exit 1
- name: Upload results of clang static analysis (CTU mode)
timeout-minutes: 1
uses: actions/upload-artifact@v4
if: failure()
with:
name: codechecker_ctu_report.tar.xz
path: ${{ github.workspace }}/codechecker_ctu_report.tar.xz
- name: Perform CodeQL static analysis
timeout-minutes: 11
if: inputs.flavor == 'CodeQLAnalysis'
uses: github/codeql-action/analyze@v3
- name: Perform SonarCloud static analysis
timeout-minutes: 6
if: inputs.flavor == 'SonarCloudStaticAnalysis'
env:
SONAR_SERVER_URL: "https://sonarcloud.io"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SRC_DIR: ${{ github.workspace }}/rawspeed
BUILD_DIR: ${{ github.workspace }}/rawspeed-build
COVERAGE_REPORT_PREFIX: ${{ github.workspace }}/${{ env.COVERAGE_REPORT_PREFIX }}
run: |
set -xe
cd "${SRC_DIR}"
sonar-scanner --define project.settings="${SRC_DIR}/.ci/sonar-project.properties" --define sonar.host.url="${{ env.SONAR_SERVER_URL }}" --define sonar.projectKey="${{ secrets.SONAR_PROJECT_KEY }}" --define sonar.organization="${{ secrets.SONAR_ORGANIZATION }}" --define sonar.cfamily.compile-commands="${BUILD_DIR}/compile_commands.json" --define sonar.cfamily.analysisCache.mode=fs --define sonar.cfamily.analysisCache.path="${BUILD_DIR}/sonar-scanner-cache"