From 1d3a0771c7a5a194d747bbc2f8e2c5a3ffe123b1 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 20:15:11 +0100 Subject: [PATCH 01/10] ci: add first ci --- .github/CODEOWNERS | 1 + .github/workflows/ci.yaml | 129 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/workflows/ci.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..0d42758 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @Firestar99 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..ee37d1e --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,129 @@ +on: + push: + branches: + - main + pull_request: + merge_group: + +name: CI + +# Cancel PR actions on new commits +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + test: + name: Test + strategy: + fail-fast: false + matrix: + os: [ ubuntu-24.04, windows-2022, macOS-latest ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: install nextest + uses: taiki-e/install-action@v2 + with: + tool: nextest + - name: Install Vulkan SDK + uses: jakoch/install-vulkan-sdk-action@v1 + with: + vulkan_version: 1.4.321.0 + install_runtime: true + cache: true + stripdown: true + + # FIXME(eddyb) consider using lavapipe instead, or even trying both. + install_swiftshader: true + # install_lavapipe: true + - if: ${{ runner.os == 'Linux' }} + name: Linux - Install native dependencies + run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev + # just need a random command that forces the installation of rust-toolchain + # figure out native target triple while we're at it + - name: install rust-toolchain + run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" + - name: xtask cargo fetch --locked + run: cd xtask && cargo fetch --locked --target $TARGET + - name: xtask build + run: cd xtask && cargo build + - name: xtask generate + run: cargo xtask generate + - name: cargo fetch --locked + run: cargo xtask generate -x "cargo fetch --locked --target $TARGET" + - name: cargo build + run: cargo xtask generate -x "cargo build" + - name: cargo test + run: cargo xtask generate -x "cargo nextest run" + + # This allows us to have a single job we can branch protect on, rather than needing + # to update the branch protection rules when the test matrix changes + test_success: + runs-on: ubuntu-24.04 + needs: [test, lint] + # Hack for buggy GitHub Actions behavior with skipped checks: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks + if: ${{ always() }} + steps: + # Another hack is to actually check the status of the dependencies or else it'll fall through + - run: | + echo "Checking statuses..." + [[ "${{ needs.test.result }}" == "success" ]] || exit 1 + [[ "${{ needs.xtask-test.result }}" == "success" ]] || exit 1 + [[ "${{ needs.lint.result }}" == "success" ]] || exit 1 + + xtask-test: + name: xtask test + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: install nextest + uses: taiki-e/install-action@v2 + with: + tool: nextest + - if: ${{ runner.os == 'Linux' }} + name: Linux - Install native dependencies + run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev + # just need a random command that forces the installation of rust-toolchain + # figure out native target triple while we're at it + - name: install rust-toolchain + run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" + - name: xtask cargo fetch --locked + run: cd xtask && cargo fetch --locked --target $TARGET + - name: xtask build + run: cd xtask && cargo build + - name: xtask test + run: cd xtask && cargo nextest run + - name: xtask fmt + run: cd xtask && cargo fmt --all -- --check + - name: xtask clippy + run: cd xtask && cargo clippy --all-targets -- -D warnings + + lint: + name: Lint + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - if: ${{ runner.os == 'Linux' }} + name: Linux - Install native dependencies + run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev + # just need a random command that forces the installation of rust-toolchain + # figure out native target triple while we're at it + - name: install rust-toolchain + run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" + - name: xtask cargo fetch --locked + run: cd xtask && cargo fetch --locked + - name: xtask build + run: cd xtask && cargo build + - name: xtask generate + run: cargo xtask generate + - name: cargo fetch --locked + run: cargo xtask generate -x "cargo fetch --locked" + - name: fmt + run: cargo xtask generate -x "cargo fmt --all -- --check" + - name: clippy + run: cargo xtask generate -x "cargo clippy --all-targets -- -D warnings" + +defaults: + run: + shell: bash From 444dab52ca76c620b9017299f34c832480887e35 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 20:30:48 +0100 Subject: [PATCH 02/10] ci: don't use `fetch --locked` on templates --- .github/workflows/ci.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ee37d1e..3bf813f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,8 +50,9 @@ jobs: run: cd xtask && cargo build - name: xtask generate run: cargo xtask generate - - name: cargo fetch --locked - run: cargo xtask generate -x "cargo fetch --locked --target $TARGET" + # no --locked, templates need to generate their lockfile + - name: cargo fetch + run: cargo xtask generate -x "cargo fetch --target $TARGET" - name: cargo build run: cargo xtask generate -x "cargo build" - name: cargo test @@ -117,8 +118,9 @@ jobs: run: cd xtask && cargo build - name: xtask generate run: cargo xtask generate - - name: cargo fetch --locked - run: cargo xtask generate -x "cargo fetch --locked" + # no --locked, templates need to generate their lockfile + - name: cargo fetch + run: cargo xtask generate -x "cargo fetch" - name: fmt run: cargo xtask generate -x "cargo fmt --all -- --check" - name: clippy From 5b3d7b23c0ac6bf08e5a9e4d9131886f94b805fc Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 20:31:27 +0100 Subject: [PATCH 03/10] ci: install rustfmt and clippy --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3bf813f..f0fd067 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -89,6 +89,8 @@ jobs: # figure out native target triple while we're at it - name: install rust-toolchain run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" + - name: Install rustup components + run: rustup component add rustfmt clippy - name: xtask cargo fetch --locked run: cd xtask && cargo fetch --locked --target $TARGET - name: xtask build @@ -112,6 +114,8 @@ jobs: # figure out native target triple while we're at it - name: install rust-toolchain run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" + - name: Install rustup components + run: rustup component add rustfmt clippy - name: xtask cargo fetch --locked run: cd xtask && cargo fetch --locked - name: xtask build From 8aa5a30568e460a7d95ce949a7c42ac50659bf30 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 21:01:35 +0100 Subject: [PATCH 04/10] ci: split `spirv-builder` and `cargo-gpu` into separate jobs --- .github/workflows/ci.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f0fd067..8f02e63 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -19,6 +19,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-24.04, windows-2022, macOS-latest ] + integration: [ "cargo-gpu", "spirv-builder" ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -49,14 +50,14 @@ jobs: - name: xtask build run: cd xtask && cargo build - name: xtask generate - run: cargo xtask generate + run: cargo xtask generate ${{ matrix.integration }} # no --locked, templates need to generate their lockfile - name: cargo fetch - run: cargo xtask generate -x "cargo fetch --target $TARGET" + run: cargo xtask generate ${{ matrix.integration }} -x "cargo fetch --target $TARGET" - name: cargo build - run: cargo xtask generate -x "cargo build" + run: cargo xtask generate ${{ matrix.integration }} -x "cargo build" - name: cargo test - run: cargo xtask generate -x "cargo nextest run" + run: cargo xtask generate ${{ matrix.integration }} -x "cargo nextest run" # This allows us to have a single job we can branch protect on, rather than needing # to update the branch protection rules when the test matrix changes From 13b11c91bff3e239a4212d064e2a22e2bb603c76 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 21:03:01 +0100 Subject: [PATCH 05/10] ci: allow no tests to be present --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8f02e63..9e45be8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,8 +56,9 @@ jobs: run: cargo xtask generate ${{ matrix.integration }} -x "cargo fetch --target $TARGET" - name: cargo build run: cargo xtask generate ${{ matrix.integration }} -x "cargo build" + # graphics templates have no tests by default - name: cargo test - run: cargo xtask generate ${{ matrix.integration }} -x "cargo nextest run" + run: cargo xtask generate ${{ matrix.integration }} -x "cargo nextest run --no-tests warn" # This allows us to have a single job we can branch protect on, rather than needing # to update the branch protection rules when the test matrix changes From 8a0f38ef864a6852416daefa81d32ff794c0ff27 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 21:10:59 +0100 Subject: [PATCH 06/10] fix clippy --- ash-graphics/ash-graphics/src/main.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ash-graphics/ash-graphics/src/main.rs b/ash-graphics/ash-graphics/src/main.rs index 74976a7..9dc0595 100644 --- a/ash-graphics/ash-graphics/src/main.rs +++ b/ash-graphics/ash-graphics/src/main.rs @@ -134,19 +134,17 @@ pub fn main() -> anyhow::Result<()> { WindowEvent::KeyboardInput { event: winit::event::KeyEvent { - logical_key: winit::keyboard::Key::Named(key), + logical_key: + winit::keyboard::Key::Named(winit::keyboard::NamedKey::Escape), state: winit::event::ElementState::Pressed, .. }, .. - } => match key { - winit::keyboard::NamedKey::Escape => event_loop_window_target.exit(), - _ => {} - }, + } + | WindowEvent::CloseRequested => event_loop_window_target.exit(), WindowEvent::Resized(_) => { swapchain.should_recreate(); } - WindowEvent::CloseRequested => event_loop_window_target.exit(), _ => {} } From 826604876331f6baf2050dbaf9bf6a65725efb35 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 21:14:32 +0100 Subject: [PATCH 07/10] add build script optimizations from rust-gpu for spirv-builder variant --- ash-graphics/Cargo.toml.liquid | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ash-graphics/Cargo.toml.liquid b/ash-graphics/Cargo.toml.liquid index 1e9e81b..70d7058 100644 --- a/ash-graphics/Cargo.toml.liquid +++ b/ash-graphics/Cargo.toml.liquid @@ -33,3 +33,32 @@ raw-window-handle = "0.6.2" winit = "0.30.0" cfg-if = "1.0.0" anyhow = "1.0.98" + +{% if integration_type == "spirv-builder" -%} +# Optimize build scripts, copied from rust-gpu's repo +# Enable incremental by default in release mode. +[profile.release] +incremental = true +# HACK(eddyb) this is the default but without explicitly specifying it, Cargo +# will treat the identical settings in `[profile.release.build-override]` below +# as different sets of `rustc` flags and will not reuse artifacts between them. +codegen-units = 256 + +# Compile build-dependencies in release mode with the same settings +# as regular dependencies (including the incremental enabled above). +[profile.release.build-override] +opt-level = 3 +incremental = true +codegen-units = 256 + +# HACK(eddyb) reduce the number of linker exports and/or imports, by avoiding +# inter-CGU linkage, to stay under the 64Ki MSVC limit for `rustc_codegen_spirv` +# when building it in "debug mode" (only relevant to CI for now, realistically), +# i.e. working around this issue: https://github.com/rust-lang/rust/issues/53014. +[profile.dev] +# HACK(eddyb) fewer inter-crate exports/imports (not just inter-CGU), but sadly +# not configurable w/o breaking `Cargo.toml` parsing from non-nightly Cargo. +# +# rustflags = ["-Zshare-generics=off"] +codegen-units = 1 +{% endif -%} From 74754ec515abdb5d88c4e82fffd4ad29f57300f1 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Tue, 2 Dec 2025 23:58:50 +0100 Subject: [PATCH 08/10] ci: add `-Zshare-generics=off` on windows --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9e45be8..742e00e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -41,6 +41,9 @@ jobs: - if: ${{ runner.os == 'Linux' }} name: Linux - Install native dependencies run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev + - if: ${{ runner.os == 'Windows' && matrix.integration == 'spirv-builder' }} + name: Windows - set rustflags to make it compile + run: echo "RUSTFLAGS=-Zshare-generics=off" >> "$GITHUB_ENV" # just need a random command that forces the installation of rust-toolchain # figure out native target triple while we're at it - name: install rust-toolchain From 233813fb3151c5c8e52176e7e2c2d163f801f77d Mon Sep 17 00:00:00 2001 From: firestar99 Date: Wed, 3 Dec 2025 10:42:31 +0100 Subject: [PATCH 09/10] ci: fix test_success check --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 742e00e..fd18f5a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -67,7 +67,7 @@ jobs: # to update the branch protection rules when the test matrix changes test_success: runs-on: ubuntu-24.04 - needs: [test, lint] + needs: [test, xtask-test, lint] # Hack for buggy GitHub Actions behavior with skipped checks: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks if: ${{ always() }} steps: From 1331d11cc1121cbf8d396e7715f8c26ebf14d3a1 Mon Sep 17 00:00:00 2001 From: firestar99 Date: Wed, 3 Dec 2025 10:44:26 +0100 Subject: [PATCH 10/10] ci: split lint into cargo-gpu and spirv-builder variants --- .github/workflows/ci.yaml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fd18f5a..3760faf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ concurrency: jobs: test: - name: Test + name: test strategy: fail-fast: false matrix: @@ -79,7 +79,7 @@ jobs: [[ "${{ needs.lint.result }}" == "success" ]] || exit 1 xtask-test: - name: xtask test + name: xtask test & lint runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -108,7 +108,11 @@ jobs: run: cd xtask && cargo clippy --all-targets -- -D warnings lint: - name: Lint + name: lint + strategy: + fail-fast: false + matrix: + integration: [ "cargo-gpu", "spirv-builder" ] runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -126,14 +130,14 @@ jobs: - name: xtask build run: cd xtask && cargo build - name: xtask generate - run: cargo xtask generate + run: cargo xtask generate ${{ matrix.integration }} # no --locked, templates need to generate their lockfile - name: cargo fetch - run: cargo xtask generate -x "cargo fetch" + run: cargo xtask generate ${{ matrix.integration }} -x "cargo fetch" - name: fmt - run: cargo xtask generate -x "cargo fmt --all -- --check" + run: cargo xtask generate ${{ matrix.integration }} -x "cargo fmt --all -- --check" - name: clippy - run: cargo xtask generate -x "cargo clippy --all-targets -- -D warnings" + run: cargo xtask generate ${{ matrix.integration }} -x "cargo clippy --all-targets -- -D warnings" defaults: run: