| env: | |
| # We aim to always test with the latest stable Rust toolchain, however we pin to a specific | |
| # version like 1.70. Note that we only specify MAJOR.MINOR and not PATCH so that bugfixes still | |
| # come automatically. If the version specified here is no longer the latest stable version, | |
| # then please feel free to submit a PR that adjusts it along with the potential clippy fixes. | |
| RUST_STABLE_VER: "1.95" # In quotes because otherwise (e.g.) 1.70 would be interpreted as 1.7 | |
| # The purpose of checking with the minimum supported Rust toolchain is to detect its staleness. | |
| # If the compilation fails, then the version specified here needs to be bumped up to reality. | |
| # Be sure to also update the rust-version property in the workspace Cargo.toml file, | |
| # plus all the README.md files of the affected packages. | |
| RUST_MIN_VER: "1.88" | |
| # List of packages that will be checked with the minimum supported Rust version. | |
| # This should be limited to packages that are intended for publishing. | |
| RUST_MIN_VER_PKGS: "-p vello -p vello_encoding -p vello_shaders -p vello_common -p vello_cpu -p vello_hybrid -p glifo" | |
| # List of packages that will be checked for `no_std` builds. | |
| # This should be limited to packages that are intended for publishing. | |
| RUST_NO_STD_PKGS: "-p vello_common -p vello_cpu -p glifo" | |
| # List of features that depend on the standard library and will be excluded from no_std checks. | |
| FEATURES_DEPENDING_ON_STD: "std,default,png,pico_svg,multithreading,probe" | |
| # List of packages that can not target Wasm. | |
| # `vello_tests` uses `nv-flip`, which doesn't support Wasm. | |
| NO_WASM_PKGS: "--exclude vello_tests --exclude xtask" | |
| # The files stored in LFS the tests need to access, in JSON format | |
| LFS_FILES: '["vello_tests/snapshots/*.png", "sparse_strips/vello_sparse_tests/snapshots/*.png"]' | |
| # Rationale | |
| # | |
| # We don't run clippy with --all-targets because then even --lib and --bins are compiled with | |
| # dev dependencies enabled, which does not match how they would be compiled by users. | |
| # A dev dependency might enable a feature that we need for a regular dependency, | |
| # and checking with --all-targets would not find our feature requirements lacking. | |
| # This problem still applies to cargo resolver version 2. | |
| # Thus we split all the targets into two steps, one with --lib --bins | |
| # and another with --tests --benches --examples. | |
| # Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages. | |
| # Luckily the default behavior of cargo with no explicit targets is the same but without the error. | |
| # | |
| # We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across | |
| # the whole workspace. While cargo-hack will instead check each workspace package separately. | |
| # | |
| # Using cargo-hack also allows us to more easily test the feature matrix of our packages. | |
| # We use --each-feature & --optional-deps which will run a separate check for every feature. | |
| # | |
| # We use cargo-nextest, which has a faster concurrency model for running tests. | |
| # However cargo-nextest does not support running doc tests, so we also have a cargo test --doc step. | |
| # For more information see https://github.com/nextest-rs/nextest/issues/16 | |
| # | |
| # The MSRV jobs run only cargo check because different clippy versions can disagree on goals and | |
| # running tests introduces dev dependencies which may require a higher MSRV than the bare package. | |
| # | |
| # For no_std checks we target x86_64-unknown-none, because this target doesn't support std | |
| # and as such will error out if our dependency tree accidentally tries to use std. | |
| # https://doc.rust-lang.org/stable/rustc/platform-support/x86_64-unknown-none.html | |
| # | |
| # We don't save caches in the merge-group cases, because those caches will never be re-used (apart | |
| # from the very rare cases where there are multiple PRs in the merge queue). | |
| # This is because GitHub doesn't share caches between merge queues and the main branch. | |
| name: CI | |
| on: | |
| pull_request: | |
| merge_group: | |
| # We run on push, even though the commit is the same as when we ran in merge_group. | |
| # This allows the cache to be primed. | |
| # See https://github.com/orgs/community/discussions/66430 | |
| push: | |
| branches: | |
| - main | |
| # Cancel superseded CI runs for the same PR to save runner time. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| fmt: | |
| name: formatting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| components: rustfmt | |
| - name: cargo fmt | |
| run: cargo fmt --all --check | |
| - name: Install Taplo | |
| uses: uncenter/setup-taplo@09968a8ae38d66ddd3d23802c44bf6122d7aa991 # v1 | |
| with: | |
| version: "0.9.3" | |
| - name: Run taplo fmt | |
| run: taplo fmt --check --diff | |
| - name: install ripgrep | |
| run: | | |
| sudo apt update | |
| sudo apt install ripgrep | |
| - name: check copyright headers | |
| run: bash .github/copyright.sh | |
| - name: Install cargo-rdme | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-rdme@1.4.8 | |
| - name: Run cargo rdme (vello_cpu) | |
| run: cargo rdme --check --workspace-project=vello_cpu | |
| - name: Run cargo rdme (vello_common) | |
| run: cargo rdme --check --workspace-project=vello_common | |
| - name: Run cargo rdme (vello_hybrid) | |
| run: cargo rdme --check --workspace-project=vello_hybrid | |
| - name: Run cargo rdme (glifo) | |
| run: cargo rdme --check --workspace-project=glifo | |
| clippy-stable: | |
| name: cargo clippy | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, macos-latest, ubuntu-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| targets: x86_64-unknown-none | |
| components: clippy | |
| - name: install cargo-hack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-hack | |
| - name: install native dependencies | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libfontconfig-dev | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| cache-bin: ${{ matrix.os != 'macos-latest' }} # works around https://github.com/Swatinem/rust-cache/issues/341 | |
| - name: cargo clippy (no_std) | |
| run: cargo hack clippy ${{ env.RUST_NO_STD_PKGS }} --locked --optional-deps --each-feature --ignore-unknown-features --features libm,u8_pipeline,f32_pipeline --exclude-features ${{ env.FEATURES_DEPENDING_ON_STD }} --target x86_64-unknown-none -- -D warnings | |
| - name: cargo clippy | |
| run: cargo hack clippy --workspace --locked --optional-deps --each-feature --ignore-unknown-features --features std,u8_pipeline,f32_pipeline -- -D warnings | |
| - name: cargo clippy (vello_cpu - u8 pipeline) | |
| run: cargo clippy -p vello_cpu --locked --no-default-features --features std,text,png,u8_pipeline | |
| - name: cargo clippy (vello_cpu - f32 pipeline) | |
| run: cargo clippy -p vello_cpu --locked --no-default-features --features std,text,png,f32_pipeline | |
| - name: cargo clippy (auxiliary) | |
| run: cargo hack clippy --workspace --locked --optional-deps --each-feature --ignore-unknown-features --features std,u8_pipeline,f32_pipeline --tests --benches --examples -- -D warnings | |
| clippy-stable-wasm: | |
| name: cargo clippy (wasm32) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| targets: wasm32-unknown-unknown | |
| components: clippy | |
| - name: install cargo-hack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-hack | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| - name: cargo clippy (no_std) | |
| run: cargo hack clippy ${{ env.RUST_NO_STD_PKGS }} --locked --target wasm32-unknown-unknown --optional-deps --each-feature --ignore-unknown-features --features libm,u8_pipeline,f32_pipeline --exclude-features ${{ env.FEATURES_DEPENDING_ON_STD }} -- -D warnings | |
| - name: cargo clippy | |
| run: cargo hack clippy --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --optional-deps --each-feature --ignore-unknown-features --features std,u8_pipeline,f32_pipeline -- -D warnings | |
| - name: cargo clippy (auxiliary) | |
| run: cargo hack clippy --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --optional-deps --each-feature --ignore-unknown-features --features std,u8_pipeline,f32_pipeline --tests --benches --examples -- -D warnings | |
| wasm-size: | |
| name: sparse strips wasm size | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| targets: wasm32-unknown-unknown | |
| - name: install wasm-bindgen | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: wasm-bindgen@0.2.114 | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| - name: check sparse strips wasm sizes | |
| run: ./sparse_strips/web/check_wasm_sizes.sh | |
| prime-lfs-cache: | |
| name: Prime LFS Cache | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| outputs: | |
| lfs-hash: ${{ steps.calc-hash.outputs.result }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - id: calc-hash | |
| name: Calculate LFS hash | |
| # GitHub's expression context doesn't support either a literal newline or an escaped newline. We have to use the JSON parser to get a newline character. | |
| run: echo "result=${{ hashFiles(join(fromJson(env.LFS_FILES), fromJson('"\n"'))) }}" | tee -a "$GITHUB_OUTPUT" | |
| - name: Cache git lfs | |
| id: lfs-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: .git/lfs | |
| # The files targeted with git lfs | |
| key: vello-lfs-${{ steps.calc-hash.outputs.result }} | |
| restore-keys: vello-lfs- | |
| enableCrossOsArchive: true | |
| - name: Fetch lfs data | |
| if: ${{ steps.lfs-cache.outputs.cache-hit != 'true' }} | |
| run: git lfs fetch --include '${{ join(fromJson(env.LFS_FILES), ',') }}' | |
| test-stable: | |
| name: cargo test | |
| needs: prime-lfs-cache | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [windows-latest, macos-latest, ubuntu-latest] | |
| include: | |
| - os: ubuntu-latest | |
| gpu: 'yes' | |
| - os: macos-latest | |
| gpu: 'yes' | |
| - os: windows-latest | |
| # TODO: The windows runners theoretically have CPU fallback for GPUs, but | |
| # this failed in initial testing | |
| gpu: 'no' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| # We intentionally do not use lfs: true here, instead using the caching method to save LFS bandwidth. | |
| - name: Restore lfs cache | |
| id: lfs-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .git/lfs | |
| # The files targeted with git lfs | |
| key: vello-lfs-${{ needs.prime-lfs-cache.outputs.lfs-hash }} | |
| enableCrossOsArchive: true | |
| - name: Checkout LFS files | |
| # `git lfs checkout` requires that each individual glob is a separate command line argument. | |
| # The string `''' '''` is how you write `' '` in GitHub's expression context (i.e. two quotes separated by a space) | |
| # The quotes are to avoid the shell from evaluating the globs itself. | |
| run: git lfs checkout '${{ join(fromJson(env.LFS_FILES), ''' ''') }}' | |
| continue-on-error: true | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| - name: install native dependencies | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libfontconfig-dev | |
| # Adapted from https://github.com/bevyengine/bevy/blob/b446374392adc70aceb92621b080d1a6cf7a7392/.github/workflows/validation-jobs.yml#L74-L79 | |
| - name: install xvfb, llvmpipe and lavapipe | |
| if: matrix.os == 'ubuntu-latest' | |
| # https://launchpad.net/~kisak/+archive/ubuntu/turtle | |
| run: | | |
| sudo apt-get update -y -qq | |
| sudo add-apt-repository ppa:kisak/turtle -y | |
| sudo apt-get update | |
| sudo apt install -y xvfb libegl-mesa0 libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers | |
| - name: install cargo-nextest | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-nextest | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| cache-bin: ${{ matrix.os != 'macos-latest' }} # works around https://github.com/Swatinem/rust-cache/issues/341 | |
| - name: cargo nextest | |
| # TODO: Maybe use --release; the CPU shaders are extremely slow when unoptimised | |
| run: cargo nextest run --workspace --locked --all-features --no-fail-fast --release | |
| env: | |
| CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS: "true" | |
| VELLO_CI_GPU_SUPPORT: ${{ matrix.gpu }} | |
| # We are experimenting with git lfs, and we don't expect to run out of bandwidth. | |
| # However, if we do, the tests are designed to be robust against that, if this environment variable is set. | |
| # If we do run out of bandwidth, uncomment the following line and inform @DJMcNab. | |
| # VELLO_SKIP_LFS_SNAPSHOTS: all | |
| - name: Upload test results due to failure | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: vello-snapshot-tests-${{ matrix.os }} | |
| path: | | |
| vello_tests/comparisons | |
| vello_tests/current | |
| sparse_strips/vello_sparse_tests/diffs | |
| - name: cargo test --doc | |
| run: cargo test --doc --workspace --locked --all-features --no-fail-fast | |
| test-stable-wasm: | |
| name: cargo test (wasm32, ${{ matrix.name }}) | |
| needs: prime-lfs-cache | |
| # We use MacOS because for some reason the Ubuntu-based runners | |
| # have trouble handling things like `requestAnimationFrame` or | |
| # `setTimeout` in our testing code. | |
| runs-on: macos-latest | |
| strategy: | |
| matrix: | |
| include: | |
| - name: default | |
| rustflags: "" | |
| - name: simd128 | |
| rustflags: "-Ctarget-feature=+simd128" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| # We intentionally do not use lfs: true here, instead using the caching method to save LFS bandwidth. | |
| - name: Restore lfs cache | |
| id: lfs-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .git/lfs | |
| # The files targeted with git lfs | |
| key: vello-lfs-${{ needs.prime-lfs-cache.outputs.lfs-hash }} | |
| enableCrossOsArchive: true | |
| - name: Checkout LFS files | |
| # `git lfs checkout` requires that each individual glob is a separate command line argument. | |
| # The string `''' '''` is how you write `' '` in GitHub's expression context (i.e. two quotes separated by a space) | |
| # The quotes are to avoid the shell from evaluating the globs itself. | |
| run: git lfs checkout '${{ join(fromJson(env.LFS_FILES), ''' ''') }}' | |
| continue-on-error: true | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| targets: wasm32-unknown-unknown | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| - name: cargo test compile | |
| run: cargo test --workspace ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --all-features --no-run | |
| - name: install wasm-pack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: wasm-pack | |
| - name: Run vello_sparse_tests on Chrome | |
| # We need to run in release mode, because otherwise wasm_parser can't read the | |
| # blob, see <https://github.com/linebender/vello/pull/1078#issuecomment-3029336905> | |
| run: wasm-pack test --headless --chrome --features webgl --release | |
| working-directory: sparse_strips/vello_sparse_tests | |
| env: | |
| RUSTFLAGS: ${{ matrix.rustflags }} | |
| check-stable-wasm-webgl-examples: | |
| name: cargo check (wasm32 webgl examples) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| targets: wasm32-unknown-unknown | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| - name: install wasm-pack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: wasm-pack | |
| - name: check vello_hybrid is wgpu webgl compatible | |
| run: wasm-pack test --headless --chrome | |
| working-directory: sparse_strips/vello_hybrid/examples/wgpu_webgl | |
| - name: check vello_hybrid is native webgl compatible | |
| run: wasm-pack test --headless --chrome | |
| working-directory: sparse_strips/vello_hybrid/examples/native_webgl | |
| check-stable-android: | |
| name: cargo check (aarch64-android) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install stable toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_STABLE_VER }} | |
| targets: aarch64-linux-android | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| - name: install cargo apk | |
| run: cargo install cargo-apk | |
| - name: cargo apk check (android) | |
| run: cargo apk check -p with_winit --lib | |
| env: | |
| # This is a bit of a hack, but cargo apk doesn't seem to allow customising this | |
| RUSTFLAGS: '-D warnings' | |
| check-msrv: | |
| name: cargo check (msrv) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [windows-latest, macos-latest, ubuntu-latest] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install msrv toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_MIN_VER }} | |
| targets: x86_64-unknown-none | |
| - name: install cargo-hack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-hack | |
| - name: install native dependencies | |
| if: matrix.os == 'ubuntu-latest' | |
| run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libfontconfig-dev | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| cache-bin: ${{ matrix.os != 'macos-latest' }} # works around https://github.com/Swatinem/rust-cache/issues/341 | |
| - name: cargo check (no_std) | |
| run: cargo hack check ${{ env.RUST_NO_STD_PKGS }} --locked --optional-deps --each-feature --ignore-unknown-features --features libm,u8_pipeline,f32_pipeline --exclude-features ${{ env.FEATURES_DEPENDING_ON_STD }} --target x86_64-unknown-none | |
| - name: cargo check | |
| run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --optional-deps --each-feature --ignore-unknown-features --features std,u8_pipeline,f32_pipeline | |
| check-msrv-wasm: | |
| name: cargo check (msrv) (wasm32) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install msrv toolchain | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ env.RUST_MIN_VER }} | |
| targets: wasm32-unknown-unknown | |
| - name: install cargo-hack | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: cargo-hack | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| - name: cargo check | |
| run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} ${{ env.NO_WASM_PKGS }} --locked --target wasm32-unknown-unknown --optional-deps --each-feature --ignore-unknown-features --features std,u8_pipeline,f32_pipeline | |
| doc: | |
| name: cargo doc | |
| # NOTE: We don't have any platform specific docs in this workspace, so we only run on Ubuntu. | |
| # If we get per-platform docs (win/macos/linux/wasm32/..) then doc jobs should match that. | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install nightly toolchain | |
| uses: dtolnay/rust-toolchain@nightly | |
| - name: install native dependencies | |
| run: sudo apt-get update; sudo apt-get install --no-install-recommends libfontconfig-dev | |
| - name: restore cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.event_name != 'merge_group' }} | |
| # We test documentation using nightly to match docs.rs. | |
| - name: cargo doc | |
| run: cargo doc --workspace --locked --all-features --no-deps --document-private-items | |
| env: | |
| RUSTDOCFLAGS: '--cfg docsrs -D warnings' | |
| # If this fails, consider changing your text or adding something to .typos.toml. | |
| typos: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: check typos | |
| uses: crate-ci/typos@v1.45.0 |