summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: b4478888bb15721d765f4b1c8009a9aa0846c42e (plain)
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
# Copyright (c) the JPEG XL Project Authors. All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

# We define only two stages for development. The "build" stage only compiles the
# code and doesn't run any target code. The "test" stage runs the code compiled
# by the previous stage. Stages form dependencies in a block, all the build
# targets in one stage need to be completed before any of the next stage can
# start.
stages:
  - build
  - test
  - deploy

variables:
  # By default we don't fetch any third_party dependencies. Building requires to
  # fetch all the dependencies but many other workflows don't.
  GIT_SUBMODULE_STRATEGY: none
  # Set the default checkout directory to a fixed one so it is the same across
  # multiple jobs. cmake requires that build directory's realpath to not change.
  GIT_CLONE_PATH: $CI_BUILDS_DIR/libjxl

# A template for running in the generic cloud builders. These are tagged with
# "linux" and run on shared VMs.
.linux_host_template: &linux_host_template
  image: &jpegxl-builder gcr.io/jpegxl/jpegxl-builder@sha256:439a05c41f86a82067042fca16d5c9c7cc5836a8a5d8dba7fa0383f3c1e603c2
  tags:
    - linux
  # By default all the workflows run on master and on request. This can be
  # override by users of this template.
  only:
    - main
    - master
    - /^v[0-9]+\.[0-9]+\.x$/
    - tags
    - schedules
  # Retry on system failures. This can be typically caused by the runner or VM
  # being evicted.
  retry:
    max: 2
    when:
      - unknown_failure
      - api_failure
      - stuck_or_timeout_failure
      - runner_system_failure
  # Default variables. Note that adding a "variables:" section to a template
  # using this template will completely discard this section, not just add new
  # variables.
  variables:
    GIT_SUBMODULE_STRATEGY: none
    BUILD_DIR: build
    CC: clang-7
    CXX: clang++-7

# Common artifacts for the build stage
.default_build_paths: &default_build_paths
  - build/libjxl.so*
  - build/libjxl.dll
  # Binary tools like cjxl are "cjxl.exe" in windows builds. These
  # matches will match against either one.
  - build/lib/jxl_gbench*
  - build/tools/cjxl*
  - build/tools/djxl*
  - build/tools/benchmark_xl*
  - build/tools/decode_and_encode*
  - build/tools/comparison_viewer/compare_codecs*
  - build/tools/comparison_viewer/compare_images*
  - build/tools/viewer/viewer*
  # Brotli shared dependencies if built
  - build/third_party/brotli/libbrotli*so*
  - build/third_party/brotli/libbrotli*.dll
  # All the test binaries in the build/ directory and .cmake files used by
  # ctest, compressed into this file together to save space when uploading.
  - build/tests.tar.xz
  # The coverage data produced at compile time.
  - build/gcno.tar.xz
  # The packed html doxygen documentation, only produced by the coverage build.
  - build/htmldoc.tar.gz
  - build/stats.json
  - build/LICENSE*
  # The JNI library + wrapper + test.
  - build/tools/libjxl_jni*so*
  - build/tools/libjxl_jni*.dll
  - build/tools/jxl_jni_wrapper.jar
  - build/tools/jxl_jni_wrapper_test.jar

# Helper template to add the default artifacts paths to all build stages. If
# files in the "paths:" section are not present only a warning is generated.
.linux_host_build_template: &linux_host_build_template
  <<: *linux_host_template
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 week
    paths: *default_build_paths
  variables:
    # Building always requires to fetch all the repositories.
    GIT_SUBMODULE_STRATEGY: recursive
    BUILD_DIR: build
    CC: clang-7
    CXX: clang++-7

# Build from tarball source using README.md instructions.
build:x86_64:clang:tarball:
  <<: *linux_host_build_template
  stage: build
  variables:
    GIT_SUBMODULE_STRATEGY: none
    BUILD_DIR: build
    CC: clang-7
    CXX: clang++-7
  script:
    # Simulate a tarball checkout by removing .git and not fetching any
    # submodule.
    - mv .git .git-ignore || true
    - ./deps.sh
    - apt update
    - apt install -y cmake pkg-config libbrotli-dev
        libgif-dev libjpeg-dev libopenexr-dev libpng-dev libwebp-dev
    - mkdir build
    - cd build
    - cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF ..
    - cmake --build . -- -j

# linux x86_64 default Release mode.
build:x86_64:clang:release:
  <<: *linux_host_build_template
  stage: build
  script:
    # Check that the build files are up to date.
    - tools/build_cleaner.py
    - SKIP_TEST=1 PACK_TEST=1 STACK_SIZE=1
      ./ci.sh release -DCMAKE_INSTALL_PREFIX=`pwd`/prefix
    # Test that the package can be installed.
    - ninja -C build install
    - tools/build_stats.py --save build/stats.json
        cjxl djxl libjxl.so

test:x86_64:clang:release:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:x86_64:clang:release
  script:
    - ./ci.sh test
    # Quick run to make sure it doesn't crash. Not useful for actual benchmarks.
    - ./ci.sh gbench --benchmark_min_time=0

# x86_84 test coverage build
build:x86_64:clang:coverage:
  <<: *linux_host_build_template
  stage: build
  script:
    - SKIP_TEST=1 PACK_TEST=1 ./ci.sh coverage
    - tar -zcf build/htmldoc.tar.gz -C build/html .

test:x86_64:clang:coverage:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:x86_64:clang:coverage
  script:
    - ./ci.sh test
    - ./ci.sh coverage_report
  variables:
    CC: clang-7
    CXX: clang++-7
    # Headers from submodules might be needed when generating the HTML reports.
    GIT_SUBMODULE_STRATEGY: recursive
    # Coverage builds use more stack for coverage tracking.
    TEST_STACK_LIMIT: 1024
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 year
    paths:
      - build/coverage.txt
      - build/coverage*.html
      - build/coverage.xml
      - build/htmldoc.tar.gz

# Updates the "Pages" section in GitLab with the latest coverage report from
# master.
pages:
  <<: *linux_host_template
  stage: deploy
  only:
    - main
  dependencies:
    - test:x86_64:clang:coverage
  script:
    - mkdir public
    # Unpack the doxygen documentation as "pages".
    - tar -zxf build/htmldoc.tar.gz -C public
    # Link from the index to the coverage.html file.
    - sed -E "s,<!--header-->,<!--header--><a href=coverage.html>Coverage for ${CI_COMMIT_SHA}</a><br />," -i public/index.html
    # Copy the coverage files to public/coverage*
    - mv build/coverage* public/
    - sed -E "s,GCC Code Coverage Report,Coverage Report for <a href='${CI_PROJECT_URL}/commit/${CI_COMMIT_SHA}'>${CI_COMMIT_SHORT_SHA}</a>," -i public/coverage.html
  artifacts:
    paths:
      - public


# i686 (x86 32-bit) builders
build:i686:clang:release:
  <<: *linux_host_build_template
  stage: build
  script:
    - BUILD_TARGET=i686-linux-gnu SKIP_TEST=1 PACK_TEST=1 STACK_SIZE=1
        ./ci.sh release -DJPEGXL_ENABLE_TCMALLOC=OFF -DJPEGXL_ENABLE_FUZZERS=OFF
    - tools/build_stats.py --save build/stats.json
        --binutils=i686-linux-gnu-
        cjxl djxl libjxl.so

test:i686:clang:release:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:i686:clang:release
  script:
    - ./ci.sh test

# Windows builders. These are cross-compiled from a linux host.
build:win64:clang:release:
  <<: *linux_host_build_template
  stage: build
  script:
    - BUILD_TARGET=x86_64-w64-mingw32
        SKIP_TEST=1 PACK_TEST=1
        ./ci.sh release -DJPEGXL_ENABLE_TCMALLOC=OFF -DJPEGXL_ENABLE_FUZZERS=OFF
          -DJPEGXL_ENABLE_PLUGINS=OFF

test:win64:clang:release:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:win64:clang:release
  script:
    - BUILD_TARGET=x86_64-w64-mingw32 ./ci.sh test

# aarch64 release runs only on master and on request.
build:aarch64:clang:release:
  <<: *linux_host_build_template
  stage: build
  script:
    - BUILD_TARGET=aarch64-linux-gnu
        CMAKE_CXX_FLAGS="-DJXL_DISABLE_SLOW_TESTS" SKIP_TEST=1 PACK_TEST=1
        STACK_SIZE=1
        ./ci.sh release
    - tools/build_stats.py --save build/stats.json
        --binutils=aarch64-linux-gnu-
        cjxl djxl libjxl.so

test:aarch64:clang:release:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:aarch64:clang:release
  script:
    # LeakSanitizer doesn't work when running under qemu-arm.
    - ASAN_OPTIONS=detect_leaks=0 ./ci.sh test

build:aarch64:clang:release-nhp:
  <<: *linux_host_build_template
  stage: build
  script:
    - BUILD_TARGET=aarch64-linux-gnu
        CMAKE_CXX_FLAGS="-DJXL_DISABLE_SLOW_TESTS -DJXL_HIGH_PRECISION=0"
        SKIP_TEST=1 PACK_TEST=1 STACK_SIZE=1
        ./ci.sh release
    - tools/build_stats.py --save build/stats.json
        --binutils=aarch64-linux-gnu-
        cjxl djxl libjxl.so

test:aarch64:clang:release-nhp:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:aarch64:clang:release-nhp
  script:
    # LeakSanitizer doesn't work when running under qemu-arm.
    - ASAN_OPTIONS=detect_leaks=0 ./ci.sh test

# aarch64 asan build and test.
build:aarch64:clang:asan:
  <<: *linux_host_build_template
  stage: build
  script:
    - SKIP_TEST=1 PACK_TEST=1 ./ci.sh asan

test:aarch64:clang:asan:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:aarch64:clang:asan
  # Disable asan test on arm since they timeout.
  only:
    - tags
  script:
    - ./ci.sh test

build:x86_64:clang:tsan:
  <<: *linux_host_build_template
  stage: build
  script:
    - SKIP_TEST=1 PACK_TEST=1 ./ci.sh tsan

test:x86_64:clang:tsan:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:x86_64:clang:tsan
  script:
    # tsan test runs fail with a small stack.
    - TEST_STACK_LIMIT=1024 ./ci.sh test

# Faster benchmark over a smaller set of images.
.benchmark_x86_64_template: &benchmark_x86_64_template
  <<: *linux_host_template
  stage: test
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 year
    paths:
      - build/benchmark_results/

test:fast_benchmark:release:
  <<: *benchmark_x86_64_template
  dependencies:
    - build:x86_64:clang:release
  script:
    - STORE_IMAGES=0 ./ci.sh fast_benchmark

# This template runs on actual aarch64 hardware.
.benchmark_aarch64_template: &benchmark_aarch64_template
  <<: *linux_host_template
  image: gcr.io/jpegxl/jpegxl-builder-run-aarch64@sha256:27c2bb6319023ab94d66670135a971401869a3275a7e0dda177c9bb247d57e03
  stage: test
  tags:
    - aarch64
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 year
    paths:
      - build/benchmark_results/
      - build/gbench.*

test:aarch64:fast_benchmark:release:
  <<: *benchmark_aarch64_template
  dependencies:
    - build:aarch64:clang:release
  script:
    # Bind to the big CPUs only.
    - ./ci.sh cpuset "${RUNNER_CPU_BIG}"
    - STORE_IMAGES=0 ./ci.sh fast_benchmark
    # Running the gbench in the big CPUs only.
    - ./ci.sh gbench

# Benchmark test that runs separately on the big and little CPUs of the runner.
test:aarch64:arm_benchmark:release:
  <<: *benchmark_aarch64_template
  dependencies:
    - build:aarch64:clang:release
  script:
    - ./ci.sh arm_benchmark

# Benchmark ToT on nightly builds. These are scheduled at midnight UTC.
test:benchmark:release:
  image: *jpegxl-builder
  stage: test
  only:
    - schedules
  variables:
    GIT_SUBMODULE_STRATEGY: none
  dependencies:
    - build:x86_64:clang:release
  script:
    - STORE_IMAGES=0 ./ci.sh benchmark
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 year
    paths:
      - build/benchmark_results/

build:tidy:all:
  <<: *linux_host_build_template
  stage: build
  script:
    - CMAKE_BUILD_TYPE="Release" ./ci.sh tidy all
  allow_failure: true
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 year
    when: always
    paths:
      - build/clang-tidy.txt

# Emscripten (WASM) build.
build:ems:all:
  <<: *linux_host_build_template
  stage: build
  script:
    - export V8=/opt/.jsvu/v8
    - source /opt/emsdk/emsdk_env.sh
    - BUILD_TARGET=wasm32 SKIP_TEST=1 PACK_TEST=1 emconfigure ./ci.sh release

test:ems:all:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:ems:all
  script:
    - export V8=/opt/.jsvu/v8
    - source /opt/emsdk/emsdk_env.sh
    - BUILD_TARGET=wasm32 emconfigure ./ci.sh test

# Emscripten (WASM + SIMD) build.
build:ems_simd:all:
  <<: *linux_host_build_template
  stage: build
  script:
    - export V8=/opt/.jsvu/v8
    - source /opt/emsdk/emsdk_env.sh
    - BUILD_TARGET=wasm32 ENABLE_WASM_SIMD=1 SKIP_TEST=1 PACK_TEST=1 emconfigure ./ci.sh release

test:ems_simd:all:
  <<: *linux_host_template
  stage: test
  dependencies:
    - build:ems_simd:all
  script:
    - export V8=/opt/.jsvu/v8
    - source /opt/emsdk/emsdk_env.sh
    - BUILD_TARGET=wasm32 emconfigure ./ci.sh test