build_test_cross.yml (9968B)
1 # Copyright (c) the JPEG XL Project Authors. All rights reserved. 2 # 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 # Workflow for building and running tests. 7 8 name: Build/Test Cross 9 on: 10 merge_group: 11 push: 12 branches: 13 - main 14 - v*.*.x 15 pull_request: 16 types: [opened, reopened, labeled, synchronize] 17 18 permissions: 19 contents: read 20 21 concurrency: 22 group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} 23 cancel-in-progress: ${{ github.event_name == 'pull_request' }} 24 25 jobs: 26 compile: 27 name: Cross-compiling ${{ matrix.identifier }} 28 runs-on: [ubuntu-latest] 29 container: 30 image: debian:bookworm 31 strategy: 32 fail-fast: false 33 matrix: 34 identifier: [arm64, arm64-sve, arm64-lowprecision, armhf, i386] 35 include: 36 - arch: arm64 37 identifier: arm64 38 build_target: aarch64-linux-gnu 39 cmake_args: 40 - -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static 41 42 - arch: arm64 43 identifier: arm64-sve 44 build_target: aarch64-linux-gnu 45 cmake_args: 46 - -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static 47 - -DJPEGXL_ENABLE_OPENEXR=off 48 - -DJPEGXL_ENABLE_SIZELESS_VECTORS=on 49 - -DJPEGXL_WARNINGS_AS_ERRORS=off 50 cmake_flags: -march=armv8-a+sve 51 c_compiler: aarch64-linux-gnu-gcc 52 cxx_compiler: aarch64-linux-gnu-g++ 53 disable_tests: true 54 55 - arch: arm64 56 identifier: arm64-lowprecision 57 build_target: aarch64-linux-gnu 58 cmake_args: 59 - -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-aarch64-static 60 - -DCMAKE_CXX_FLAGS=-DJXL_HIGH_PRECISION=0 61 62 - arch: armhf 63 identifier: armhf 64 build_target: arm-linux-gnueabihf 65 cmake_args: [-DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/qemu-arm-static] 66 67 - arch: i386 68 identifier: i386 69 test_in_pr: true 70 build_target: i686-linux-gnu 71 72 env: 73 BUILD_DIR: build 74 WILL_RUN_TESTS: ${{ (github.event_name == 'push' || (github.event_name == 'pull_request' && (matrix.test_in_pr || contains(github.event.pull_request.labels.*.name, 'CI:full')))) }} 75 76 steps: 77 - name: Harden Runner 78 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 79 with: 80 egress-policy: audit 81 82 - name: Warmup apt 83 shell: bash 84 run: | 85 set -x 86 rm -f /var/lib/man-db/auto-update 87 apt-get update -y 88 apt-get install -y ca-certificates debian-ports-archive-keyring git python3 89 90 - name: Checkout the source 91 uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 92 with: 93 submodules: true 94 fetch-depth: 1 95 96 - name: Setup apt 97 shell: bash 98 run: | 99 set -x 100 dpkg --add-architecture "${{ matrix.arch }}" 101 102 python3 ./tools/scripts/transform_sources_list.py "amd64,${{ matrix.arch }}" 103 104 - name: Install build deps 105 shell: bash 106 run: | 107 set -x 108 apt update 109 pkgs=( 110 # Build dependencies 111 cmake 112 doxygen 113 graphviz 114 ninja-build 115 pkg-config 116 qemu-user-static 117 unzip 118 xdg-utils 119 xvfb 120 121 # Toolchain for cross-compiling. 122 clang-14 123 g++-aarch64-linux-gnu 124 libc6-dev-${{ matrix.arch }}-cross 125 libstdc++-12-dev-${{ matrix.arch }}-cross 126 libstdc++-12-dev:${{ matrix.arch }} 127 128 # Dependencies 129 libbrotli-dev:${{ matrix.arch }} 130 libgif-dev:${{ matrix.arch }} 131 libjpeg-dev:${{ matrix.arch }} 132 libpng-dev:${{ matrix.arch }} 133 libwebp-dev:${{ matrix.arch }} 134 135 # For OpenEXR: 136 libilmbase-dev:${{ matrix.arch }} 137 libopenexr-dev:${{ matrix.arch }} 138 139 # GTK plugins 140 libgdk-pixbuf2.0-dev:${{ matrix.arch }} 141 libgtk2.0-dev:${{ matrix.arch }} 142 ) 143 if [[ "${{ matrix.build_target }}" != "x86_64-linux-gnu" ]]; then 144 pkgs+=( 145 binutils-${{ matrix.build_target }} 146 gcc-${{ matrix.build_target }} 147 ) 148 fi 149 if [[ "${{ matrix.arch }}" != "i386" ]]; then 150 pkgs+=( 151 # TCMalloc 152 libgoogle-perftools-dev:${{ matrix.arch }} 153 libgoogle-perftools4:${{ matrix.arch }} 154 libtcmalloc-minimal4:${{ matrix.arch }} 155 libunwind-dev:${{ matrix.arch }} 156 ) 157 fi 158 DEBIAN_FRONTEND=noninteractive apt install -y "${pkgs[@]}" 159 echo "CC=${{ matrix.c_compiler || 'clang-14' }}" >> $GITHUB_ENV 160 echo "CXX=${{ matrix.cxx_compiler || 'clang++-14' }}" >> $GITHUB_ENV 161 162 - name: Build 163 run: | 164 CMAKE_FLAGS="${{ matrix.cmake_flags }}" ./ci.sh release \ 165 -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \ 166 -DJPEGXL_ENABLE_JNI=OFF \ 167 ${{ join(matrix.cmake_args, ' ') }} 168 env: 169 SKIP_TEST: 1 170 BUILD_TARGET: ${{ matrix.build_target }} 171 TARGETS: ${{ env.WILL_RUN_TESTS == 'true' && 'all_tests cjxl djxl libjxl.so libjxl_dec.so' || 'all' }} 172 173 - name: Build stats 174 run: | 175 tools/scripts/build_stats.py --save build/stats.json \ 176 --binutils ${{ matrix.build_target }}- \ 177 --max-stack ${{ matrix.max_stack || '0' }} \ 178 cjxl djxl libjxl.so libjxl_dec.so 179 180 - name: Prepare artefacts 181 if: env.WILL_RUN_TESTS == 'true' 182 run: | 183 find ./build -regextype egrep -type f -regex '.*\.(a|h|jar|log|o)' 184 find ./build -type f -executable > executable.lst 185 cp /etc/apt/sources.list.d/debian.sources ./ 186 187 - name: Test ranging 188 if: ${{ !matrix.disable_tests }} 189 run: | 190 mkdir -p ./build/Testing/Temporary 191 unzip ./tools/scripts/test_cost-${{ matrix.identifier }}.zip -d ./build/Testing/Temporary 192 193 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 194 if: env.WILL_RUN_TESTS == 'true' 195 with: 196 name: cross_binary-${{ matrix.identifier }} 197 path: | 198 build/ 199 ci.sh 200 debian.sources 201 executable.lst 202 testdata/ 203 retention-days: 1 204 205 test: 206 name: Testing ${{ matrix.identifier }} shard ${{ matrix.shard_number }} 207 needs: compile 208 runs-on: [ubuntu-latest] 209 container: 210 image: debian:bookworm 211 strategy: 212 fail-fast: false 213 matrix: 214 shard_number: [0, 1, 2, 3, 4, 5, 6, 7] 215 identifier: [arm64, arm64-lowprecision, armhf, i386] 216 include: 217 - arch: arm64 218 - identifier: arm64 219 last_shard: 8 220 221 #- arch: arm64 222 #- identifier: arm64-sve 223 # last_shard: 8 224 225 - arch: arm64 226 identifier: arm64-lowprecision 227 last_shard: 8 228 229 - arch: armhf 230 identifier: armhf 231 last_shard: 8 232 233 - arch: i386 234 identifier: i386 235 test_in_pr: true 236 last_shard: 4 237 238 env: 239 BUILD_DIR: build 240 UPLOAD_TEST_COST: false 241 LAST_SHARD: ${{ false && 1 || matrix.last_shard}} 242 # Run the tests on push and when requested in pull_request. 243 WILL_RUN_TESTS: ${{ (github.event_name == 'push' || (github.event_name == 'pull_request' && (matrix.test_in_pr || contains(github.event.pull_request.labels.*.name, 'CI:full')))) }} 244 245 steps: 246 - name: Harden Runner 247 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 248 with: 249 egress-policy: audit 250 251 - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 252 if: (matrix.shard_number < env.LAST_SHARD) && (env.WILL_RUN_TESTS == 'true') 253 with: 254 name: cross_binary-${{ matrix.identifier }} 255 256 - name: Setup apt 257 if: (matrix.shard_number < env.LAST_SHARD) && (env.WILL_RUN_TESTS == 'true') 258 shell: bash 259 run: | 260 set -x 261 rm -f /var/lib/man-db/auto-update 262 apt-get update -y 263 apt-get install -y ca-certificates debian-ports-archive-keyring 264 265 dpkg --add-architecture "${{ matrix.arch }}" 266 267 cp ./debian.sources /etc/apt/sources.list.d/ 268 269 - name: Install build deps 270 if: (matrix.shard_number < env.LAST_SHARD) && (env.WILL_RUN_TESTS == 'true') 271 shell: bash 272 run: | 273 set -x 274 apt update 275 pkgs=( 276 # Build dependencies 277 cmake 278 qemu-user-static 279 280 # Dependencies 281 libbrotli-dev:${{ matrix.arch }} 282 libgif-dev:${{ matrix.arch }} 283 libjpeg-dev:${{ matrix.arch }} 284 libpng-dev:${{ matrix.arch }} 285 libwebp-dev:${{ matrix.arch }} 286 287 # For OpenEXR: 288 libilmbase-dev:${{ matrix.arch }} 289 libopenexr-dev:${{ matrix.arch }} 290 ) 291 DEBIAN_FRONTEND=noninteractive apt install -y "${pkgs[@]}" 292 293 - name: Prepare 294 if: (env.UPLOAD_TEST_COST == 'true') && (matrix.shard_number == 0) && (env.WILL_RUN_TESTS == 'true') 295 run: | 296 rm build/Testing/Temporary/CTestCostData.txt 297 298 - name: Test 299 if: (matrix.shard_number < env.LAST_SHARD) && (env.WILL_RUN_TESTS == 'true') 300 run: | 301 chmod +x ./ci.sh 302 chmod +x `cat executable.lst` 303 ./ci.sh test \ 304 -I ${{ matrix.shard_number }},,${{ env.LAST_SHARD }} \ 305 -E '(bash_test|conformance_tooling_test|test_jxl_jni_wrapper)' 306 307 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 308 name: Upload test cost 309 if: (env.UPLOAD_TEST_COST == 'true') && (matrix.shard_number == 0) && (env.WILL_RUN_TESTS == 'true') 310 with: 311 name: test_cost-${{ matrix.identifier }} 312 path: | 313 build/Testing/Temporary/CTestCostData.txt 314 retention-days: 1