template: move enable_debug_layer to new mod util
#41
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
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| merge_group: | |
| workflow_dispatch: | |
| 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 ] | |
| integration: [ "cargo-gpu", "spirv-builder" ] | |
| 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 | |
| - 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 | |
| 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 | |
| # generate all variants, since `--clean` deletes `generated/`, not generating all of them will cause changes | |
| run: cargo xtask generate --clean | |
| - name: check generated files are up-to-date | |
| run: | | |
| git add . | |
| git diff --cached | |
| # if this fails, the files committed don't match what should have been generated | |
| git diff --quiet && git diff --cached --quiet | |
| # no --locked, templates need to generate their lockfile | |
| - name: cargo fetch | |
| 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 --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 | |
| test_success: | |
| runs-on: ubuntu-24.04 | |
| 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: | |
| # 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 & lint | |
| 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: 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 | |
| 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 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| integration: [ "cargo-gpu", "spirv-builder" ] | |
| 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: Install rustup components | |
| run: rustup component add rustfmt clippy | |
| - 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 ${{ matrix.integration }} | |
| # no --locked, templates need to generate their lockfile | |
| - name: cargo fetch | |
| run: cargo xtask generate ${{ matrix.integration }} -x "cargo fetch" | |
| - name: fmt | |
| run: cargo xtask generate ${{ matrix.integration }} -x "cargo fmt --all -- --check" | |
| - name: clippy | |
| run: cargo xtask generate ${{ matrix.integration }} -x "cargo clippy --all-targets -- -D warnings" | |
| defaults: | |
| run: | |
| shell: bash |