.gitlab-ci.yml 14.1 KB
Newer Older
1 2
# Copyright (c) the JPEG XL Project
#
3 4 5 6 7 8 9 10 11 12 13
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

# 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:
  # We need to fetch the third_party dependencies together with the code unless
  # otherwise noted.
  GIT_SUBMODULE_STRATEGY: recursive

# A template for running in the generic cloud builders. These are tagged with
# "linux" and run on shared VMs.
.linux_builder_template: &linux_builder_template
33
  image: &jpegxl-builder gcr.io/jpegxl/[email protected]:e97bb79499eb4f9af4186388a450996b2c27caa6cc873f4175947ae398192bbb
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
  tags:
    - linux
  # By default all the workflows run on master and on request. This can be
  # override by users of this template.
  only:
    - master
    - 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

# A template for building on x86_64 images on the cloud builders.
.linux_x86_64_template: &linux_x86_64_template
  <<: *linux_builder_template
  variables:
    CC: clang-6.0
    CXX: clang++-6.0

.linux_i686_template: &linux_i686_template
  <<: *linux_builder_template
  variables:
    CC: clang-6.0
    CXX: clang++-6.0
    # This makes cross-compiling for i686 the default when calling ci.sh.
    BUILD_TARGET: i686-linux-gnu
    BUILD_DIR: build

# A template for building on aarch64 images on the cloud builders. These may not
# run on actual aarch64 hardware.
.linux_aarch64_template: &linux_aarch64_template
  <<: *linux_builder_template
  variables:
    CC: clang-6.0
    CXX: clang++-6.0
    # This makes cross-compiling for aarch64 the default when calling ci.sh.
    BUILD_TARGET: aarch64-linux-gnu
    BUILD_DIR: build
    # We need to fetch the third_party dependencies together with the code.
    GIT_SUBMODULE_STRATEGY: recursive

# A template for cross-compiling for arm-linux-gnueabihf.
.linux_armhf_template: &linux_armhf_template
  <<: *linux_builder_template
  variables:
    CC: clang-6.0
    CXX: clang++-6.0
    # This makes cross-compiling for armhf the default when calling ci.sh.
    BUILD_TARGET: arm-linux-gnueabihf
    BUILD_DIR: build
    # We need to fetch the third_party dependencies together with the code.
    GIT_SUBMODULE_STRATEGY: recursive

# Common artifacts for the build stage
.default_build_paths: &default_build_paths
  - build/libjpegxl.so*
96
  - build/tools/cbrunsli
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 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
  - build/tools/cjpegxl
  - build/tools/djpegxl
  - 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
  # 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

.linux_x86_64_build_template: &linux_x86_64_build_template
  <<: *linux_x86_64_template
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 week
    paths: *default_build_paths

.linux_i686_build_template: &linux_i686_build_template
  <<: *linux_i686_template
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 week
    paths: *default_build_paths

.linux_aarch64_build_template: &linux_aarch64_build_template
  <<: *linux_aarch64_template
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 week
    paths: *default_build_paths

.linux_armhf_build_template: &linux_armhf_build_template
  <<: *linux_armhf_template
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 week
    paths: *default_build_paths

# The default Release build runs always.
build:x86_64:clang:release:
  <<: *linux_x86_64_build_template
  stage: build
  only:
    - master
    - merge_requests
    - schedules
    - tags
  script:
    - SKIP_TEST=1 PACK_TEST=1 ./ci.sh release -DCMAKE_INSTALL_PREFIX=`pwd`/prefix
    # Test that the package can be installed.
    - ninja -C build install

test:x86_64:clang:release:
  <<: *linux_x86_64_template
  stage: test
  only:
    - master
    - merge_requests
    - schedules
    - tags
  dependencies:
    - build:x86_64:clang:release
  script:
    - ./ci.sh test
  variables:
    GIT_SUBMODULE_STRATEGY: none

# x86_84 test coverage build
build:x86_64:clang:coverage:
  <<: *linux_x86_64_build_template
  stage: build
  only:
    - master
    - schedules
    - tags
  script:
    - SKIP_TEST=1 PACK_TEST=1 ./ci.sh coverage

test:x86_64:clang:coverage:
  <<: *linux_x86_64_template
  stage: test
  only:
    - master
    - schedules
    - tags
  dependencies:
    - build:x86_64:clang:coverage
  script:
    - ./ci.sh test
    - ./ci.sh coverage_report
  variables:
    CC: clang-6.0
    CXX: clang++-6.0
    # Headers from submodules might be needed when generating the HTML reports.
    GIT_SUBMODULE_STRATEGY: recursive
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 year
    paths:
      - build/coverage.txt
      - build/coverage*.html
      - build/coverage.xml

# Updates the "Pages" section in GitLab with the latest coverage report from
# master.
pages:
  <<: *linux_x86_64_template
  stage: deploy
  only:
    - master
  dependencies:
    - test:x86_64:clang:coverage
  script:
    - mkdir public
    - mv build/coverage* public/
    - mv public/coverage.html public/index.html
    - 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/index.html
  artifacts:
    paths:
      - public


# x86_64 Scalar-only release runs only on master and on request.
build:x86_64:clang:scalar:
  <<: *linux_x86_64_build_template
  stage: build
  only:
    - master
    - merge_requests
    - schedules
    - tags
  script:
    - SKIP_TEST=1 PACK_TEST=1 CMAKE_CXX_FLAGS="-DHWY_STATIC_TARGETS=0 -DHWY_RUNTIME_TARGETS=0" ./ci.sh release

test:x86_64:clang:scalar:
  <<: *linux_x86_64_template
  stage: test
  dependencies:
    - build:x86_64:clang:scalar
  script:
    - ./ci.sh test
  variables:
    GIT_SUBMODULE_STRATEGY: none

# i686 (x86 32-bit) builders
build:i686:clang:release:
  <<: *linux_i686_build_template
  stage: build
  only:
    - master
    - merge_requests
    - schedules
    - tags
  script:
    # AVX2 on 32-bit binaries hits clang compiler bugs.
    - CMAKE_FLAGS="-DHWY_DISABLE_AVX2" SKIP_TEST=1 PACK_TEST=1
        ./ci.sh release -DJPEGXL_ENABLE_TCMALLOC=OFF -DJPEGXL_ENABLE_FUZZERS=OFF

test:i686:clang:release:
  <<: *linux_i686_template
  stage: test
  dependencies:
    - build:i686:clang:release
  script:
    - ./ci.sh test
  variables:
    GIT_SUBMODULE_STRATEGY: none

# aarch64 release runs only on master and on request.
build:aarch64:clang:release:
  <<: *linux_aarch64_build_template
  stage: build
  only:
    - master
    - merge_requests
    - schedules
    - tags
    - web
  script:
    - CMAKE_CXX_FLAGS="-DJXL_DISABLE_SLOW_TESTS" SKIP_TEST=1 PACK_TEST=1
        ./ci.sh release

test:aarch64:clang:release:
  <<: *linux_aarch64_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

# arm release
build:armhf:clang:release:
  <<: *linux_armhf_build_template
  stage: build
  only:
    - master
    - merge_requests
    - schedules
    - tags
    - web
  script:
    - CMAKE_CXX_FLAGS="-DJXL_DISABLE_SLOW_TESTS" SKIP_TEST=1 PACK_TEST=1
        ./ci.sh release

test:armhf:clang:release:
  <<: *linux_armhf_template
  stage: test
  dependencies:
    - build:armhf:clang:release
  script:
    - ./ci.sh test

# arm debug
build:armhf:clang:debug:
  <<: *linux_armhf_build_template
  stage: build
  only:
    - merge_requests
  script:
    - SKIP_TEST=1 ./ci.sh debug

# "debug" build enabled for merge_requests. This is here to check that
# debug-only statements still compile.
build:x86_64:clang:debug:
  <<: *linux_x86_64_build_template
  stage: build
  only:
    - merge_requests
  script:
    - SKIP_TEST=1 ./ci.sh debug

# "asan", "tsan" and "msan" builds only run on master, tags and when requested
# from the web. Only supported in x86_64 for now.
build:x86_64:clang:asan:
  <<: *linux_x86_64_build_template
  stage: build
  script:
    - SKIP_TEST=1 PACK_TEST=1 ./ci.sh asan

test:x86_64:clang:asan:
  <<: *linux_x86_64_template
  stage: test
  dependencies:
    - build:x86_64:clang:asan
  script:
    - ./ci.sh test
  variables:
    GIT_SUBMODULE_STRATEGY: none

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

test:aarch64:clang:asan:
  <<: *linux_aarch64_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_x86_64_build_template
  stage: build
  script:
    - SKIP_TEST=1 PACK_TEST=1 ./ci.sh tsan

test:x86_64:clang:tsan:
  <<: *linux_x86_64_template
  stage: test
  dependencies:
    - build:x86_64:clang:tsan
  script:
    - ./ci.sh test
  variables:
    GIT_SUBMODULE_STRATEGY: none

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

test:x86_64:clang:msan:
  <<: *linux_x86_64_template
  stage: test
  dependencies:
    - build:x86_64:clang:msan
  script:
    - ./ci.sh test
  variables:
    GIT_SUBMODULE_STRATEGY: none

# Merge request linter checks.
build:lint:
  <<: *linux_x86_64_template
  stage: build
  variables:
    GIT_SUBMODULE_STRATEGY: none
  only:
    - merge_requests
  script:
    - LINT_OUTPUT=clang-format.patch ./ci.sh lint
  allow_failure: true
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 month
    when: on_failure
    paths:
      - clang-format.patch

# Most clang-tidy checks are currently informational only since these are
# currently broken, however several are marked as errors.
build:tidy:
  <<: *linux_x86_64_template
  stage: build
  only:
    - merge_requests
  script:
    - CMAKE_BUILD_TYPE="Release" ./ci.sh tidy
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 month
    when: always
    paths:
      - build/clang-tidy.txt

# Faster benchmark over a smaller set of images.
.benchmark_x86_64_template: &benchmark_x86_64_template
  <<: *linux_x86_64_template
  stage: test
  variables:
    GIT_SUBMODULE_STRATEGY: none
  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
  only:
    - master
    - merge_requests
    - schedules
    - tags
  dependencies:
    - build:x86_64:clang:release
  script:
    - STORE_IMAGES=0 ./ci.sh fast_benchmark

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

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

# This template runs on actual aarch64 hardware.
.benchmark_aarch64_template: &benchmark_aarch64_template
  <<: *linux_builder_template
475
  image: gcr.io/jpegxl/[email protected]:6d218aaf961c3e0591a7a0852cb8d30524811c8f9ed7327bb886e6d7e8294c1c
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
  stage: test
  tags:
    - aarch64
  variables:
    GIT_SUBMODULE_STRATEGY: none
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 year
    paths:
      - build/benchmark_results/

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

# Benchmark test that runs separately on the big and little CPUs of the runner.
test:aarch64:arm_benchmark:release:
  <<: *benchmark_aarch64_template
  only:
    - web
    - master
  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_x86_64_template
  stage: build
  only:
    - master
  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_x86_64_template
  stage: build
544 545 546 547 548
  only:
    - master
    - merge_requests
    - schedules
    - tags
549 550 551 552 553 554 555 556 557 558 559 560 561 562
  variables:
    CC: emcc
    CXX: em++
    EMSDK: /opt/emsdk
    EM_CONFIG: /opt/emsdk/.emscripten
    CMAKE_TOOLCHAIN_FILE: /opt/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    expire_in: 1 week
    paths:
      - build/jpegxl_emcc.*
  script:
    - source "${EMSDK}/emsdk_env.sh"
    - SKIP_TEST=1 ./ci.sh release