Repository navigation
ci: fix the native builds #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
61a4fdd
ci: fix the native builds
triniwiz fdb10b6
ci: check out Oboe for the AudioContext Android build
triniwiz 9e150d3
ci: bindgen uses the NDK's libclang for the Android Skia build
triniwiz 67cfbdf
test(canvas-napi): skip device removal on the GitHub runners, not by …
triniwiz e4899d0
ci: pin the nightly the Apple and Android builds use
triniwiz 57f9567
Revert "ci: pin the nightly the Apple and Android builds use"
triniwiz 4b083ca
ci: rustfmt for the Android Skia bindings; skip device-lost on the Gi…
triniwiz 48e28bd
ci: Canvas SVG Android fetches the V8 headers and libNativeScript.so …
triniwiz 601700a
ci: the Canvas SVG Apple job builds tvOS too; say so in its name
triniwiz 5723115
Apply batched suggestions from code review
triniwiz 0ae2f62
Potential fix for pull request finding 'CodeQL / Cache Poisoning via …
triniwiz d44c178
Potential fix for pull request finding 'CodeQL / Cache Poisoning via …
triniwiz ae23d16
Merge remote-tracking branch 'origin/master' into fix/ci-native-builds
triniwiz 6e41e85
ci: build the Linux and canvas-gamepad Node-API modules
triniwiz 1e2fb0f
ci: npm Release publishes the native artifacts CI builds from the tag
triniwiz 797fb52
ci: pin the nightly the Apple and Android builds use
triniwiz 37b812e
ci: cache Skia per target; npm Release runs on the tag; publish canva…
triniwiz c04b6c2
chore: stop tracking the plugin AARs the NativeScript CLI builds
triniwiz 5747708
ci(temporary): PR #183 saves its own Skia cache, to verify restores; …
triniwiz d2c9787
ci(linux): drop the image's libunwind-14-dev, which conflicts with gs…
triniwiz bd18df6
ci(skia-cache): the shim runs the cargo that was on PATH before it, n…
triniwiz 8ec98ae
test(audio-context-napi): the realtime state test is a known failure …
triniwiz 02d6624
ci: cargo registry caches are restored everywhere and saved only by m…
triniwiz a4debc8
Revert "ci(temporary): PR #183 saves its own Skia cache, to verify re…
triniwiz 7ec7344
ci(skia-cache): key on the setup actions only
triniwiz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,13 +2,17 @@ name: Setup Apple native build environment | |
| description: > | ||
| Selects Xcode, installs the visionOS platform (SDK + simulator runtime, not | ||
| preinstalled on GitHub macOS runners), and optionally installs the Rust | ||
| nightly toolchain (with rust-src for -Z build-std) plus a cargo cache. | ||
| nightly toolchain (with rust-src for -Z build-std), cbindgen and a cargo cache. | ||
|
|
||
| inputs: | ||
| xcode-version: | ||
| description: Xcode version spec passed to setup-xcode | ||
| required: false | ||
| default: '^16.0' | ||
| rust-toolchain: | ||
| description: Dated nightly the Rust builds use (exported as CANVAS_RUST_TOOLCHAIN), as setup-android-native pins it. | ||
| required: false | ||
| default: 'nightly-2026-01-25' | ||
| install-rust: | ||
| description: Install Rust nightly + cargo cache (set 'false' for xcodebuild-only projects) | ||
| required: false | ||
|
|
@@ -34,19 +38,36 @@ runs: | |
| if: ${{ inputs.install-rust == 'true' }} | ||
| shell: bash | ||
| # rust-src is required: iOS and visionOS release builds go through | ||
| # `cargo +nightly build -Z build-std` (see Makefile). | ||
| # `cargo +$CANVAS_RUST_TOOLCHAIN build -Z build-std` (see Makefile). | ||
| run: | | ||
| rustup toolchain install nightly --profile minimal --component rust-src | ||
| rustup default nightly | ||
| rustup toolchain install ${{ inputs.rust-toolchain }} --profile minimal --component rust-src | ||
| rustup default ${{ inputs.rust-toolchain }} | ||
| echo "CANVAS_RUST_TOOLCHAIN=${{ inputs.rust-toolchain }}" >> "$GITHUB_ENV" | ||
| rustc --version | ||
|
|
||
| - name: Cache cargo | ||
| # The Xcode pre-build phases regenerate the C headers with it. No macOS release binaries. | ||
| - name: Install cbindgen | ||
| if: ${{ inputs.install-rust == 'true' }} | ||
| shell: bash | ||
| run: cargo install [email protected] --locked | ||
|
|
||
| # Restore only: .github/actions/skia-cache saves it, from master only. No Cargo.lock is | ||
| # committed, so the key hashes the manifests. | ||
| - name: Restore cargo registry | ||
| id: cargo-registry | ||
| if: ${{ inputs.install-rust == 'true' }} | ||
| uses: actions/cache@v4 | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-v2-${{ hashFiles('Cargo.toml', 'crates/*/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-cargo- | ||
| ${{ runner.os }}-${{ runner.arch }}-cargo-v2- | ||
|
|
||
| - name: Remember the cargo registry key | ||
| if: ${{ inputs.install-rust == 'true' }} | ||
| shell: bash | ||
| run: | | ||
| echo "CARGO_REGISTRY_CACHE_KEY=${{ steps.cargo-registry.outputs.cache-primary-key }}" >> "$GITHUB_ENV" | ||
| echo "CARGO_REGISTRY_CACHE_HIT=${{ steps.cargo-registry.outputs.cache-hit }}" >> "$GITHUB_ENV" | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| name: Setup Linux native build environment | ||
| description: > | ||
| Installs what tools/scripts/build-linux.sh needs on Ubuntu 22.04 (glibc 2.35, GTK 4.6, the | ||
| baseline the shipped modules target): the GTK 4 / EGL / GLES / ALSA / GStreamer / udev | ||
| development files, clang 18 for Skia (22.04's clang is 14), ninja, Rust stable and a cargo | ||
| cache. Mesa's EGL and lavapipe let the Node-API tests run on the GPU-less runners. | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install packages | ||
| shell: bash | ||
| run: | | ||
| sudo apt-get update | ||
| # gstreamer's -dev needs libunwind-dev, which conflicts with the image's LLVM 14 libunwind | ||
| sudo apt-get remove -y libunwind-14-dev || true | ||
| sudo apt-get install -y --no-install-recommends \ | ||
| libgtk-4-dev libegl-dev libgles-dev libasound2-dev libfontconfig-dev libfreetype-dev \ | ||
| libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libudev-dev \ | ||
| ninja-build pkg-config \ | ||
| libegl-mesa0 mesa-vulkan-drivers | ||
|
|
||
| - name: Install clang 18 | ||
| shell: bash | ||
| run: | | ||
| wget -qO /tmp/llvm.sh https://apt.llvm.org/llvm.sh | ||
| sudo bash /tmp/llvm.sh 18 | ||
| sudo apt-get install -y --no-install-recommends libclang-18-dev | ||
| echo "CANVAS_CLANG_DIR=/usr/lib/llvm-18/bin" >> "$GITHUB_ENV" | ||
| /usr/lib/llvm-18/bin/clang --version | ||
|
|
||
| - name: Install Rust stable | ||
| shell: bash | ||
| run: | | ||
| rustup toolchain install stable --profile minimal | ||
| rustup default stable | ||
| rustc --version | ||
|
|
||
| # Restore only: .github/actions/skia-cache saves it, from master only. No Cargo.lock is | ||
| # committed, so the key hashes the manifests. | ||
| - name: Restore cargo registry | ||
| id: cargo-registry | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: ${{ runner.os }}-${{ runner.arch }}-cargo-v2-${{ hashFiles('Cargo.toml', 'crates/*/Cargo.toml') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-${{ runner.arch }}-cargo-v2- | ||
|
|
||
| - name: Remember the cargo registry key | ||
| shell: bash | ||
| run: | | ||
| echo "CARGO_REGISTRY_CACHE_KEY=${{ steps.cargo-registry.outputs.cache-primary-key }}" >> "$GITHUB_ENV" | ||
| echo "CARGO_REGISTRY_CACHE_HIT=${{ steps.cargo-registry.outputs.cache-hit }}" >> "$GITHUB_ENV" | ||
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| name: Skia binary cache | ||
| description: > | ||
| Caches the Skia libraries skia-bindings builds, per target and feature set, in rust-skia's own | ||
| prebuilt-binaries format, so a job only builds Skia from source when its inputs change. | ||
|
|
||
| Restore (default): with an exact hit, skia-bindings installs Skia from the cache instead of | ||
| building it (FORCE_SKIA_BINARIES_DOWNLOAD + a file:// SKIA_BINARIES_URL). Either way it exports | ||
| what it used into BUILD_ARTIFACTSTAGINGDIRECTORY, and a cargo shim put first on PATH files each | ||
| export under rust-skia's key (fork commit, target, features) after every cargo run. The export | ||
| directory has a fixed name, so it has to be collected per build. These variables stay the same | ||
| for the whole job: skia-bindings rebuilds Skia when one of them changes, and the Xcode pre-build | ||
| phases call cargo directly. | ||
|
|
||
| Save (save: 'true', as the job's last step): only on pushes to master, so pull requests and | ||
| releases read master's entries and never write the ones master restores. Also saves the cargo | ||
| registry the setup-*-native actions restored, under the same rule. | ||
|
|
||
| inputs: | ||
| name: | ||
| description: Cache slot; one per job (and matrix arch) | ||
| required: true | ||
| save: | ||
| description: "'true' to save the cache instead of restoring it" | ||
| required: false | ||
| default: 'false' | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Prepare | ||
| if: inputs.save != 'true' | ||
| shell: bash | ||
| run: | | ||
| tmp="$RUNNER_TEMP" | ||
| command -v cygpath > /dev/null && tmp="$(cygpath -m "$RUNNER_TEMP")" | ||
| real_cargo="$(command -v cargo)" || { echo "skia-cache: no cargo on PATH; run it after the toolchain setup" >&2; exit 1; } | ||
| mkdir -p "$tmp/skia-cache" "$tmp/skia-export" "$tmp/skia-cache-bin" | ||
| cp "$GITHUB_ACTION_PATH/cargo-shim.sh" "$tmp/skia-cache-bin/cargo" | ||
| chmod +x "$tmp/skia-cache-bin/cargo" | ||
| echo "$tmp/skia-cache-bin" >> "$GITHUB_PATH" | ||
| { | ||
| echo "SKIA_CACHE_REAL_CARGO=$real_cargo" | ||
| echo "SKIA_CACHE_DIR=$tmp/skia-cache" | ||
| echo "BUILD_ARTIFACTSTAGINGDIRECTORY=$tmp/skia-export" | ||
| # bump to drop every Skia cache entry | ||
| echo "SKIA_CACHE_KEY=skia-v1-${{ inputs.name }}-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Cargo.lock', 'Cargo.toml', 'crates/*/Cargo.toml', '.cargo/config.toml', 'Makefile', 'tools/scripts/*.sh', 'packages/*/src-native/**/pre-build.sh', '.github/actions/setup-*/action.yml') }}" | ||
| } >> "$GITHUB_ENV" | ||
|
|
||
| # Exact keys only: a partial match could lack a target, and a forced install that finds no | ||
| # archive fails the build. | ||
| - name: Restore | ||
| if: inputs.save != 'true' | ||
| id: restore | ||
| uses: actions/cache/restore@v4 | ||
| with: | ||
| path: ${{ env.SKIA_CACHE_DIR }} | ||
| key: ${{ env.SKIA_CACHE_KEY }} | ||
|
|
||
| - name: Use cached Skia | ||
| if: inputs.save != 'true' && steps.restore.outputs.cache-hit == 'true' | ||
| shell: bash | ||
| run: | | ||
| ls "$SKIA_CACHE_DIR" | ||
| { | ||
| echo "SKIA_CACHE_HIT=true" | ||
| echo "FORCE_SKIA_BINARIES_DOWNLOAD=1" | ||
| echo "SKIA_BINARIES_URL=file://$SKIA_CACHE_DIR/skia-binaries-{key}.tar.gz" | ||
| } >> "$GITHUB_ENV" | ||
|
|
||
| - name: Save | ||
| if: inputs.save == 'true' && env.SKIA_CACHE_KEY != '' && env.SKIA_CACHE_HIT != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: ${{ env.SKIA_CACHE_DIR }} | ||
| key: ${{ env.SKIA_CACHE_KEY }} | ||
|
|
||
| - name: Save cargo registry | ||
| if: inputs.save == 'true' && env.CARGO_REGISTRY_CACHE_KEY != '' && env.CARGO_REGISTRY_CACHE_HIT != 'true' && github.event_name == 'push' && github.ref == 'refs/heads/master' | ||
| uses: actions/cache/save@v4 | ||
| with: | ||
| path: | | ||
| ~/.cargo/registry | ||
| ~/.cargo/git | ||
| key: ${{ env.CARGO_REGISTRY_CACHE_KEY }} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/usr/bin/env bash | ||
| # CI only (installed by the skia-cache action as `cargo`, first on PATH). Runs the real cargo, | ||
| # then files the Skia binaries skia-bindings exported during that run under their rust-skia key, | ||
| # where SKIA_BINARIES_URL finds them on the next run. | ||
| "$SKIA_CACHE_REAL_CARGO" "$@" | ||
| status=$? | ||
|
|
||
| staging="$BUILD_ARTIFACTSTAGINGDIRECTORY" | ||
| cache="$SKIA_CACHE_DIR" | ||
| # GNU tar reads D:/... as host:path | ||
| command -v cygpath > /dev/null && staging="$(cygpath -u "$staging")" && cache="$(cygpath -u "$cache")" | ||
| export_dir="$staging/skia-binaries" | ||
| if [ "$status" -eq 0 ] && [ -f "$export_dir/key.txt" ]; then | ||
| key="$(cat "$export_dir/key.txt")" | ||
| archive="$cache/skia-binaries-$key.tar.gz" | ||
| if [ ! -f "$archive" ]; then | ||
| tar -czf "$archive" -C "$staging" skia-binaries | ||
| echo "skia-cache: stored $(basename "$archive")" | ||
| fi | ||
| rm -rf "$export_dir" | ||
| fi | ||
| exit "$status" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.