do not ignore avif result (#2907) #434
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. | |
# Workflow for building and running tests. | |
name: Build/Test | |
on: | |
merge_group: | |
push: | |
branches: | |
- main | |
- v*.*.x | |
pull_request: | |
types: [opened, reopened, labeled, synchronize] | |
permissions: | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
ubuntu_build: | |
name: Ubuntu Build ${{ matrix.name }} | |
runs-on: ${{ matrix.os || 'ubuntu-latest' }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# We have one job per "name" in the matrix. Attributes are set on the | |
# specific job names. | |
name: [release, debug, asan, msan, scalar] | |
include: | |
- name: release | |
mode: release | |
test_in_pr: true | |
cmake_args: >- | |
-DJPEGXL_TEST_TOOLS=ON | |
-DJPEGLI_LIBJPEG_LIBRARY_VERSION="8.2.2" | |
-DJPEGLI_LIBJPEG_LIBRARY_SOVERSION="8" | |
# Track static stack size on build and check it doesn't exceed 3 kB. | |
env_stack_size: 1 | |
max_stack: 2400 | |
# Conformance tooling test requires numpy. | |
apt_pkgs: graphviz python3-numpy | |
- name: lowprecision | |
mode: release | |
test_in_pr: true | |
cmake_args: -DCMAKE_CXX_FLAGS=-DJXL_HIGH_PRECISION=0 | |
- name: debug | |
# Runs on AVX3 CPUs require more stack than others. Make sure to | |
# test on AVX3-enabled CPUs when changing this value. | |
env_test_stack_size: 4000 | |
# Build scalar-only hwy instructions. | |
- name: scalar | |
mode: release | |
cxxflags: -DHWY_COMPILE_ONLY_SCALAR -DFJXL_ENABLE_AVX2=0 -DFJXL_ENABLE_AVX512=0 | |
# Disabling optional features to speed up msan build a little bit. | |
- name: msan | |
os: ubuntu-20.04 | |
skip_install: true | |
cmake_args: >- | |
-DJPEGXL_ENABLE_DEVTOOLS=OFF -DJPEGXL_ENABLE_PLUGINS=OFF | |
-DJPEGXL_ENABLE_VIEWERS=OFF | |
- name: asan | |
skip_install: true | |
- name: coverage | |
env_test_stack_size: 2048 | |
# Build with support for decoding to JPEG bytes disabled. Produces a | |
# smaller build if only decoding to pixels is needed. | |
- name: release-nojpeg | |
mode: release | |
cxxflags: -DJXL_DEBUG_ON_ABORT=0 | |
cmake_args: >- | |
-DJPEGXL_ENABLE_TRANSCODE_JPEG=OFF | |
-DJPEGXL_ENABLE_PLUGINS=OFF | |
-DJPEGXL_ENABLE_VIEWERS=OFF | |
# Build optimized for binary size, all features not needed for | |
# reconstructing pixels is disabled. | |
- name: release:minimal | |
mode: release | |
cxxflags: -DJXL_DEBUG_ON_ABORT=0 | |
cmake_args: >- | |
-DJPEGXL_ENABLE_TRANSCODE_JPEG=OFF | |
-DJPEGXL_ENABLE_BOXES=OFF | |
-DJPEGXL_ENABLE_PLUGINS=OFF | |
-DJPEGXL_ENABLE_VIEWERS=OFF | |
# Builds with gcc in release mode | |
- name: release:gcc8 | |
os: ubuntu-20.04 | |
mode: release | |
apt_pkgs: gcc-8 g++-8 | |
cmake_args: >- | |
-DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 | |
# Builds with clang-7 in release mode | |
- name: release:clang-7 | |
os: ubuntu-20.04 | |
mode: release | |
skip_install: true | |
apt_pkgs: clang-7 | |
cc: clang-7 | |
cxx: clang++-7 | |
env: | |
CCACHE_DIR: ${{ github.workspace }}/.ccache | |
# Whether we track the stack size. | |
STACK_SIZE: ${{ matrix.env_stack_size }} | |
TEST_STACK_LIMIT: ${{ matrix.env_test_stack_size }} | |
WILL_TEST: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && matrix.name != 'coverage' && (matrix.test_in_pr || contains(github.event.pull_request.labels.*.name, 'CI:full'))) }} | |
WILL_BUILD: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && matrix.name != 'coverage') }} | |
WILL_BENCH: ${{ github.event_name != 'merge_group' && (matrix.name == 'release' || (github.event_name == 'push' && matrix.mode == 'release')) }} | |
WILL_DOC: ${{ github.event_name != 'merge_group' && matrix.name == 'release' }} | |
WILL_COV: ${{ github.event_name == 'push' && matrix.name == 'coverage' }} | |
JPEGXL_OPT_DBG: true | |
FASTER_MSAN_BUILD: 1 | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 | |
with: | |
egress-policy: audit | |
- name: Install build deps | |
run: | | |
sudo rm -f /var/lib/man-db/auto-update | |
sudo apt update | |
sudo apt install -y \ | |
ccache \ | |
clang \ | |
cmake \ | |
doxygen \ | |
graphviz \ | |
imagemagick \ | |
libbenchmark-dev \ | |
libbenchmark-tools \ | |
libbrotli-dev \ | |
libgdk-pixbuf2.0-dev \ | |
libgif-dev \ | |
libgtest-dev \ | |
libgtk2.0-dev \ | |
libjpeg-dev \ | |
libjpeg-turbo-progs \ | |
libopenexr-dev \ | |
libpng-dev \ | |
libwebp-dev \ | |
ninja-build \ | |
pkg-config \ | |
xvfb \ | |
${{ matrix.apt_pkgs }} \ | |
# | |
echo "CC=${{ matrix.cc || 'clang' }}" >> $GITHUB_ENV | |
echo "CXX=${{ matrix.cxx || 'clang++' }}" >> $GITHUB_ENV | |
- name: Checkout the source | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
submodules: true | |
fetch-depth: 2 | |
- name: Setup the LLVM source path | |
if: matrix.name == 'msan' | |
run: | | |
LLVM_ROOT=${GITHUB_WORKSPACE}/llvm_root | |
mkdir -p ${LLVM_ROOT} | |
echo "LLVM_ROOT=${LLVM_ROOT}" >> $GITHUB_ENV | |
- name: Cache LLVM sources | |
if: matrix.name == 'msan' | |
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 | |
with: | |
path: ${{ env.LLVM_ROOT }} | |
key: llvm | |
- name: Checkout the LLVM source | |
if: matrix.name == 'msan' | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
submodules: false | |
repository: llvm/llvm-project | |
ref: llvmorg-7.0.1 | |
path: llvm_root | |
- name: Sphinx dependencies | |
# Dependencies for sphinx HTML documentation | |
if: env.WILL_DOC == 'true' | |
run: | | |
pip3 install -r doc/sphinx/requirements.txt | |
- name: Install gcovr | |
if: env.WILL_COV == 'true' | |
run: pip install gcovr | |
- name: Git environment | |
id: git-env | |
run: | | |
echo "parent=$(git rev-parse ${{ github.sha }}^)" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: ccache | |
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
# When the cache hits the key it is not updated, so if this is a rebuild | |
# of the same Pull Request it will reuse the cache if still around. For | |
# either Pull Requests or new pushes to main, this will use the parent | |
# hash as the starting point from the restore-keys entry. | |
key: build-${{ runner.os }}-${{ github.sha }}-${{ matrix.name }} | |
restore-keys: | | |
build-${{ runner.os }}-${{ steps.git-env.outputs.parent }}-${{ matrix.name }} | |
- name: Build | |
if: env.WILL_BUILD == 'true' | |
run: | | |
mkdir -p ${CCACHE_DIR} | |
echo "max_size = 200M" > ${CCACHE_DIR}/ccache.conf | |
mode="${{ matrix.mode }}" | |
build_tests=$([ "$WILL_TEST" == "true" ] && echo "ON" || echo "OFF") | |
[[ -n "${mode}" ]] || mode="${{ matrix.name }}" | |
./ci.sh ${mode} -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
-DBUILD_TESTING=${build_tests} \ | |
${{ matrix.cmake_args }} | |
env: | |
SKIP_TEST: 1 | |
CMAKE_CXX_FLAGS: ${{ matrix.cxxflags }} | |
- name: Build stats | |
if: env.WILL_BUILD == 'true' | |
run: | | |
awk '!/^#/ {total[$4]+=($2-$1);cntr[$4]+=1} END {for (key in total) print total[key]/cntr[key] " " key}' build/.ninja_log | sort -n | tail -n 25 | |
- name: ccache stats | |
run: ccache --show-stats | |
- name: Build stats ${{ matrix.name }} | |
if: env.WILL_BUILD == 'true' && matrix.mode == 'release' | |
run: | | |
tools/scripts/build_stats.py --save build/stats.json \ | |
--max-stack ${{ matrix.max_stack || '0' }} \ | |
cjxl djxl libjxl.so libjxl_dec.so | |
# Check that we can build the example project against the installed libs. | |
- name: Install and build examples | |
if: env.WILL_BUILD == 'true' && matrix.mode == 'release' && !matrix.skip_install | |
run: | | |
set -x | |
sudo cmake --build build -- install | |
cmake -Bbuild-example -Hexamples -G Ninja | |
cmake --build build-example | |
if ldd build-example/decode_oneshot_static | grep libjxl; then | |
echo "decode_oneshot_static is not using the static lib" >&2 | |
exit 1 | |
fi | |
# Test that the built binaries run. | |
echo -e -n "PF\n1 1\n-1.0\n\0\0\x80\x3f\0\0\x80\x3f\0\0\x80\x3f" > test.pfm | |
build-example/encode_oneshot test.pfm test.jxl | |
build-example/encode_oneshot_static test.pfm test-static.jxl | |
build-example/decode_oneshot test.jxl dec.pfm dec.icc | |
build-example/decode_oneshot_static test.jxl dec-static.pfm dec-static.icc | |
# Run the tests on push and when requested in pull_request. | |
- name: Test ${{ matrix.mode }} | |
if: env.WILL_TEST == 'true' | |
run: | | |
./ci.sh test ${{ matrix.ctest_args }} | |
# Print the running time summary for the slowest tests. | |
- name: Test runtime stats | |
if: env.WILL_TEST == 'true' | |
run: | | |
sort build/Testing/Temporary/CTestCostData.txt -k 3 -n | tail -n 20 || true | |
- name: Build HTML documentation (sphinx/readthetdocs) | |
if: env.WILL_DOC == 'true' | |
run: | | |
cmake --build build -- rtd-html | |
- name: Coverage report | |
if: env.WILL_COV == 'true' | |
run: | | |
./ci.sh coverage_report | |
- name: Coverage upload to Codecov | |
if: env.WILL_COV == 'true' | |
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 | |
with: | |
flags: unittests | |
files: build/coverage.xml | |
- name: Fast benchmark ${{ matrix.mode }} | |
if: env.WILL_BENCH == 'true' | |
run: | | |
STORE_IMAGES=0 ./ci.sh fast_benchmark | |
# Run gbench once, just to make sure it runs, not for actual benchmarking. | |
# This doesn't work on msan because we use gbench library from the system | |
# which is not instrumented by msan. | |
- name: gbench check | |
if: env.WILL_BENCH == 'true' | |
run: | | |
./ci.sh gbench --benchmark_min_time=0 | |
windows_msys: | |
name: Windows MSYS2 / ${{ matrix.msystem }} | |
runs-on: windows-latest | |
continue-on-error: ${{ matrix.faulty || false }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- msystem: mingw64 | |
faulty: true | |
- msystem: clang64 | |
- msystem: mingw32 | |
# TODO(eustas): investigate failures | |
faulty: true | |
disable_tests: | |
- ButteraugliTest.Lossless | |
- ButteraugliTest.Distmap | |
- msystem: clang32 | |
defaults: | |
run: | |
shell: msys2 {0} | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 | |
with: | |
egress-policy: audit | |
- name: Checkout the source | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
submodules: true | |
fetch-depth: 1 | |
- uses: msys2/setup-msys2@07aeda7763550b267746a772dcea5e5ac3340b36 # v2 | |
with: | |
msystem: ${{ matrix.msystem }} | |
update: true | |
path-type: inherit | |
install: >- | |
base-devel | |
git | |
pacboy: >- | |
brotli:p | |
cmake:p | |
giflib:p | |
gtest:p | |
libavif:p | |
libjpeg-turbo:p | |
libpng:p | |
libwebp:p | |
ninja:p | |
toolchain:p | |
- name: CMake configure | |
run: | | |
cmake \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DJPEGXL_ENABLE_JNI=OFF \ | |
-DJPEGXL_ENABLE_MANPAGES=OFF \ | |
-DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ | |
-DJPEGXL_FORCE_SYSTEM_GTEST=ON \ | |
-B build \ | |
-G Ninja | |
- name: CMake build | |
run: cmake --build build | |
- name: Test | |
if: | | |
github.event_name == 'push' || | |
(github.event_name == 'pull_request' && | |
contains(github.event.pull_request.labels.*.name, 'CI:full')) | |
run: ctest --test-dir build --parallel 2 --output-on-failure -E "${{ join(matrix.disable_tests, '|') }}" | |
wasm32_build: | |
name: WASM wasm32/${{ matrix.variant }} | |
runs-on: ubuntu-latest | |
env: | |
CCACHE_DIR: ${{ github.workspace }}/.ccache | |
BUILD_TARGET: wasm32 | |
EM_VERSION: 3.1.1 | |
NODE_VERSION: 18 | |
strategy: | |
matrix: | |
include: | |
- variant: scalar | |
- variant: simd-128 | |
- variant: simd-256 | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 | |
with: | |
egress-policy: audit | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
submodules: true | |
fetch-depth: 1 | |
- name: Install build deps | |
shell: bash | |
run: | | |
set -x | |
sudo rm -f /var/lib/man-db/auto-update | |
sudo apt update | |
pkgs=( | |
# Build dependencies | |
ccache | |
cmake | |
doxygen | |
graphviz | |
ninja-build | |
pkg-config | |
) | |
DEBIAN_FRONTEND=noninteractive sudo apt install -y "${pkgs[@]}" | |
- name: Git environment | |
id: git-env | |
run: | | |
echo "parent=$(git rev-parse ${{ github.sha }}^)" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: ccache | |
uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
key: build-wasm-${{ runner.os }}-${{ github.sha }}-${{ matrix.variant }} | |
restore-keys: | | |
build-wasm-${{ runner.os }}-${{ steps.git-env.outputs.parent }}-${{ matrix.variant }} | |
- name: Install node | |
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 | |
with: | |
node-version: ${{env.NODE_VERSION}} | |
- name: Get non-EMSDK node path | |
run: which node >> $HOME/.base_node_path | |
- name: Install emsdk | |
uses: mymindstorm/setup-emsdk@ab889da2abbcbb280f91ec4c215d3bb4f3a8f775 # v12 | |
# TODO(deymo): We could cache this action but it doesn't work when running | |
# in a matrix. | |
with: | |
version: ${{env.EM_VERSION}} | |
no-cache: true | |
- name: Set EMSDK node version | |
run: | | |
echo "NODE_JS='$(cat $HOME/.base_node_path)'" >> $EMSDK/.emscripten | |
emsdk construct_env | |
# TODO(deymo): Build and install other dependencies like libpng, libjpeg, | |
# etc. | |
- name: Build | |
run: | | |
mkdir -p ${CCACHE_DIR} | |
echo "max_size = 200M" > ${CCACHE_DIR}/ccache.conf | |
if [[ "${{ matrix.variant }}" == "simd-128" ]]; then | |
export ENABLE_WASM_SIMD=1 | |
fi | |
if [[ "${{ matrix.variant }}" == "simd-256" ]]; then | |
export ENABLE_WASM_SIMD=2 | |
fi | |
./ci.sh release \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
-DCMAKE_C_COMPILER_LAUNCHER=ccache | |
env: | |
SKIP_TEST: 1 | |
- name: ccache stats | |
run: ccache --show-stats | |
- name: Test | |
if: | | |
github.event_name == 'push' || | |
(github.event_name == 'pull_request' && | |
contains(github.event.pull_request.labels.*.name, 'CI:full')) | |
run: | | |
./ci.sh test | |
bazel: | |
name: Bazel | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@1b05615854632b887b69ae1be8cbefe72d3ae423 # v2.6.0 | |
with: | |
egress-policy: audit | |
- name: Checkout the source | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
submodules: true | |
fetch-depth: 1 | |
- name: Patch | |
run: | | |
cd third_party/highway | |
git fetch origin 31fbbd7ce1e4179a32d86688cd67316556f582bf | |
git checkout 31fbbd7ce1e4179a32d86688cd67316556f582bf | |
git apply ${{ github.workspace }}/.github/workflows/highway.patch | |
- name: Build | |
run: bazel build -c opt ...:all | |
- name: Test | |
if: | | |
github.event_name == 'push' || | |
(github.event_name == 'pull_request' && | |
contains(github.event.pull_request.labels.*.name, 'CI:full')) | |
run: bazel test -c opt --test_output=errors ...:all |