From 02373fa500759959f1f69e7222966e6c89cfd432 Mon Sep 17 00:00:00 2001 From: harry Date: Thu, 19 Nov 2026 21:20:04 +0900 Subject: [PATCH 1/2] ci: skip the heavy jobs for documentation, run the XCFramework checks side by side The CI of a pull request took 17 minutes, all of it the XCFramework job, whose library builds in 48 seconds from the cache and whose three checks (the examples, the iPhone app, the Mac measurements) took the rest one after the other; the Linux job spent 250 of its 390 seconds installing the Vulkan driver's packages. - A "what changed" job says whether a pull request changes more than Markdown files and the pictures of docs/. If not, the jobs that build and run the code are skipped (a push to main runs everything, and lint always runs, since it checks the documents' figures and the copies of LICENSE and the notices). - The XCFramework checks are a matrix of three jobs, each building the XCFramework from the shared cache and running one check, so the job takes as long as the longest check. No check is removed or changed. - The Vulkan driver's packages are cached between runs. Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42 --- .github/workflows/ci.yml | 104 +++++++++++++++++++++++++++++++++------ 1 file changed, 90 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe9f3d8..737e582 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,42 @@ env: CARGO_INCREMENTAL: 0 jobs: + # Whether the change is more than documentation. A pull request that only + # changes Markdown files and the pictures under docs/ skips the jobs that + # build and run the code; the lint job still checks the documents' figures and + # copies. A push to main runs everything. + changes: + name: what changed + runs-on: ubuntu-latest + timeout-minutes: 5 + outputs: + code: ${{ steps.diff.outputs.code }} + steps: + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + persist-credentials: false + - id: diff + env: + EVENT: ${{ github.event_name }} + BASE: ${{ github.event.pull_request.base.sha }} + HEAD: ${{ github.event.pull_request.head.sha }} + run: | + if [ "$EVENT" != pull_request ]; then + echo "code=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + # Everything that is not a Markdown file or a picture of docs/. + other=$(git diff --name-only "$BASE...$HEAD" | grep -v -E '(\.md$|^docs/images/)' || true) + if [ -n "$other" ]; then + echo "code=true" >> "$GITHUB_OUTPUT" + echo "changed beyond the documentation:" + echo "$other" + else + echo "code=false" >> "$GITHUB_OUTPUT" + echo "documentation only" + fi + lint: name: fmt + clippy runs-on: ubuntu-latest @@ -41,6 +77,8 @@ jobs: - run: python3 -B scripts/readme_figures.py && git diff --exit-code docs/images msrv: + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} name: oldest Rust (1.87) runs-on: ubuntu-latest timeout-minutes: 30 @@ -58,6 +96,8 @@ jobs: - run: cargo check --workspace --all-targets --locked wasm: + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} name: browser build (wasm32) runs-on: ubuntu-latest timeout-minutes: 30 @@ -92,6 +132,8 @@ jobs: - run: node scripts/check_web.mjs build-test: + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} name: build + test (${{ matrix.os }}) runs-on: ${{ matrix.os }} timeout-minutes: 45 @@ -115,13 +157,25 @@ jobs: - uses: actions/checkout@v7 with: persist-credentials: false + # The packages of the Vulkan driver are downloaded once (LLVM is most of + # them) and kept between runs; installing them still takes the time dpkg + # needs. The key follows this file, so a change of the packages renews it. + - name: Cache the Vulkan driver's packages + if: runner.os == 'Linux' + uses: actions/cache@v6 + with: + path: ~/apt-archives + key: apt-lavapipe-${{ runner.os }}-${{ hashFiles('.github/workflows/ci.yml') }} - name: Install a software Vulkan driver (lavapipe) if: runner.os == 'Linux' run: | + mkdir -p "$HOME/apt-archives/partial" sudo apt-get update # The validation layer checks the Vulkan tests' use of the # client's device, emberwave's and wgpu's included (decision D61). - sudo apt-get install -y --no-install-recommends mesa-vulkan-drivers libvulkan1 vulkan-tools vulkan-validationlayers + sudo apt-get -o Dir::Cache::archives="$HOME/apt-archives" install -y --no-install-recommends mesa-vulkan-drivers libvulkan1 vulkan-tools vulkan-validationlayers + # The cache is saved by the runner's user. + sudo chown -R "$USER" "$HOME/apt-archives" # lavapipe alone: Vulkan loaders 1.3.284 to 1.4.344 unload the # drivers that find no device while other threads may be reading # their list, which crashes tests that create contexts in parallel @@ -148,9 +202,35 @@ jobs: run: scripts/check_c_example.sh target/debug xcframework: - name: XCFramework (iOS Simulator, macOS) + needs: changes + if: ${{ needs.changes.outputs.code == 'true' }} + # The checks are independent of each other and each takes minutes, so they + # run side by side, every one on a Mac of its own with the XCFramework built + # again from the cache (under a minute). + name: XCFramework, ${{ matrix.name }} runs-on: macos-latest timeout-minutes: 45 + strategy: + fail-fast: false + matrix: + include: + # The C and Swift examples, linked with the XCFramework, decode the + # test vectors on this Mac and in an iOS Simulator; for devices they + # are linked only. + - name: examples + build_cli: true + check: scripts/check_xcframework.sh target/debug/emberwave-cli + # The iPhone benchmark app: built for iPhones, and run in an iOS + # Simulator with -autorun, where it also reads a texture of + # emberwave_decoder_decode_texture back through Metal. + - name: iPhone app + build_cli: false + check: scripts/check_ios_app.sh + # The app's measurements on this Mac, emberwave's and HEVC's, by its + # own code built against the XCFramework's library for the Mac. + - name: Mac measurements + build_cli: false + check: scripts/bench_app_on_mac.sh -autorun steps: - uses: actions/checkout@v7 with: @@ -160,16 +240,12 @@ jobs: rustup toolchain install stable --profile minimal --target aarch64-apple-ios --target aarch64-apple-ios-sim --no-self-update rustup default stable - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 + with: + # One cache for the three: they build the same things. + shared-key: xcframework - run: scripts/build_xcframework.sh - - run: cargo build -p emberwave-cli - # The C and Swift examples, linked with the XCFramework, decode the test - # vectors on this Mac and in an iOS Simulator; for devices they are - # linked only. - - run: scripts/check_xcframework.sh target/debug/emberwave-cli - # The iPhone benchmark app: built for iPhones, and run in an iOS - # Simulator with -autorun, where it also reads a texture of - # emberwave_decoder_decode_texture back through Metal. - - run: scripts/check_ios_app.sh - # The app's measurements on this Mac, emberwave's and HEVC's, by its - # own code built against the XCFramework's library for the Mac. - - run: scripts/bench_app_on_mac.sh -autorun + - name: Build the command line tool + if: matrix.build_cli + run: cargo build -p emberwave-cli + - name: Check + run: ${{ matrix.check }} From 7344bbced773b3219c8bf5b32af0926a48c0c212 Mon Sep 17 00:00:00 2001 From: harry Date: Thu, 19 Nov 2026 22:19:52 +0900 Subject: [PATCH 2/2] ci: keep only the documentation skip; the other two changes did not help Measured on this pull request, with cold and warm caches: - Splitting the XCFramework checks into three jobs did not shorten the pull request's CI: 17.1 minutes before, 15.1 cold and 16.7 warm after. Alone, each check takes longer than it did in the shared job (the iPhone app 912 s against 465 s, the examples 657 s against 398 s), since the later checks reuse the builds of the earlier ones there, so the three jobs cost almost twice the Mac minutes for the same wall time. - Caching the Vulkan driver's packages saved nothing visible: the Linux job took 1.8 minutes cold and 2.2 minutes warm; the 250 seconds of the first measurement were the mirror's, not the packages'. Both are taken out again. What stays is the "what changed" job, which skips the jobs that build and run the code for a pull request that changes only Markdown files and the pictures of docs/, which is a gain of about 17 minutes for such a pull request, as the next documentation change will show. Claude-Session: https://claude.ai/code/session_019fJGoCTvP5e7n599q3ZQ42 --- .github/workflows/ci.yml | 60 ++++++++++------------------------------ 1 file changed, 14 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 737e582..3d92537 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -157,25 +157,13 @@ jobs: - uses: actions/checkout@v7 with: persist-credentials: false - # The packages of the Vulkan driver are downloaded once (LLVM is most of - # them) and kept between runs; installing them still takes the time dpkg - # needs. The key follows this file, so a change of the packages renews it. - - name: Cache the Vulkan driver's packages - if: runner.os == 'Linux' - uses: actions/cache@v6 - with: - path: ~/apt-archives - key: apt-lavapipe-${{ runner.os }}-${{ hashFiles('.github/workflows/ci.yml') }} - name: Install a software Vulkan driver (lavapipe) if: runner.os == 'Linux' run: | - mkdir -p "$HOME/apt-archives/partial" sudo apt-get update # The validation layer checks the Vulkan tests' use of the # client's device, emberwave's and wgpu's included (decision D61). - sudo apt-get -o Dir::Cache::archives="$HOME/apt-archives" install -y --no-install-recommends mesa-vulkan-drivers libvulkan1 vulkan-tools vulkan-validationlayers - # The cache is saved by the runner's user. - sudo chown -R "$USER" "$HOME/apt-archives" + sudo apt-get install -y --no-install-recommends mesa-vulkan-drivers libvulkan1 vulkan-tools vulkan-validationlayers # lavapipe alone: Vulkan loaders 1.3.284 to 1.4.344 unload the # drivers that find no device while other threads may be reading # their list, which crashes tests that create contexts in parallel @@ -204,33 +192,9 @@ jobs: xcframework: needs: changes if: ${{ needs.changes.outputs.code == 'true' }} - # The checks are independent of each other and each takes minutes, so they - # run side by side, every one on a Mac of its own with the XCFramework built - # again from the cache (under a minute). - name: XCFramework, ${{ matrix.name }} + name: XCFramework (iOS Simulator, macOS) runs-on: macos-latest timeout-minutes: 45 - strategy: - fail-fast: false - matrix: - include: - # The C and Swift examples, linked with the XCFramework, decode the - # test vectors on this Mac and in an iOS Simulator; for devices they - # are linked only. - - name: examples - build_cli: true - check: scripts/check_xcframework.sh target/debug/emberwave-cli - # The iPhone benchmark app: built for iPhones, and run in an iOS - # Simulator with -autorun, where it also reads a texture of - # emberwave_decoder_decode_texture back through Metal. - - name: iPhone app - build_cli: false - check: scripts/check_ios_app.sh - # The app's measurements on this Mac, emberwave's and HEVC's, by its - # own code built against the XCFramework's library for the Mac. - - name: Mac measurements - build_cli: false - check: scripts/bench_app_on_mac.sh -autorun steps: - uses: actions/checkout@v7 with: @@ -240,12 +204,16 @@ jobs: rustup toolchain install stable --profile minimal --target aarch64-apple-ios --target aarch64-apple-ios-sim --no-self-update rustup default stable - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3 - with: - # One cache for the three: they build the same things. - shared-key: xcframework - run: scripts/build_xcframework.sh - - name: Build the command line tool - if: matrix.build_cli - run: cargo build -p emberwave-cli - - name: Check - run: ${{ matrix.check }} + - run: cargo build -p emberwave-cli + # The C and Swift examples, linked with the XCFramework, decode the test + # vectors on this Mac and in an iOS Simulator; for devices they are + # linked only. + - run: scripts/check_xcframework.sh target/debug/emberwave-cli + # The iPhone benchmark app: built for iPhones, and run in an iOS + # Simulator with -autorun, where it also reads a texture of + # emberwave_decoder_decode_texture back through Metal. + - run: scripts/check_ios_app.sh + # The app's measurements on this Mac, emberwave's and HEVC's, by its + # own code built against the XCFramework's library for the Mac. + - run: scripts/bench_app_on_mac.sh -autorun