|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - main |
| 5 | + pull_request: |
| 6 | + merge_group: |
| 7 | + |
| 8 | +name: CI |
| 9 | + |
| 10 | +# Cancel PR actions on new commits |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + test: |
| 17 | + name: Test |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + os: [ ubuntu-24.04, windows-2022, macOS-latest ] |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - name: install nextest |
| 26 | + uses: taiki-e/install-action@v2 |
| 27 | + with: |
| 28 | + tool: nextest |
| 29 | + - name: Install Vulkan SDK |
| 30 | + uses: jakoch/install-vulkan-sdk-action@v1 |
| 31 | + with: |
| 32 | + vulkan_version: 1.4.321.0 |
| 33 | + install_runtime: true |
| 34 | + cache: true |
| 35 | + stripdown: true |
| 36 | + |
| 37 | + # FIXME(eddyb) consider using lavapipe instead, or even trying both. |
| 38 | + install_swiftshader: true |
| 39 | + # install_lavapipe: true |
| 40 | + - if: ${{ runner.os == 'Linux' }} |
| 41 | + name: Linux - Install native dependencies |
| 42 | + run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev |
| 43 | + # just need a random command that forces the installation of rust-toolchain |
| 44 | + # figure out native target triple while we're at it |
| 45 | + - name: install rust-toolchain |
| 46 | + run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" |
| 47 | + - name: xtask build |
| 48 | + run: cd xtask && cargo build |
| 49 | + - name: xtask generate |
| 50 | + run: cargo xtask generate |
| 51 | + - name: cargo fetch --locked |
| 52 | + run: cargo xtask generate cargo fetch --locked --target $TARGET |
| 53 | + - name: cargo build |
| 54 | + run: cargo xtask generate cargo build |
| 55 | + - name: cargo test |
| 56 | + run: cargo xtask generate cargo nextest run |
| 57 | + |
| 58 | + # This allows us to have a single job we can branch protect on, rather than needing |
| 59 | + # to update the branch protection rules when the test matrix changes |
| 60 | + test_success: |
| 61 | + runs-on: ubuntu-24.04 |
| 62 | + needs: [test, lint] |
| 63 | + # 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 |
| 64 | + if: ${{ always() }} |
| 65 | + steps: |
| 66 | + # Another hack is to actually check the status of the dependencies or else it'll fall through |
| 67 | + - run: | |
| 68 | + echo "Checking statuses..." |
| 69 | + [[ "${{ needs.test.result }}" == "success" ]] || exit 1 |
| 70 | + [[ "${{ needs.xtask-test.result }}" == "success" ]] || exit 1 |
| 71 | + [[ "${{ needs.lint.result }}" == "success" ]] || exit 1 |
| 72 | +
|
| 73 | + xtask-test: |
| 74 | + name: xtask test |
| 75 | + runs-on: ubuntu-24.04 |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + - name: install nextest |
| 79 | + uses: taiki-e/install-action@v2 |
| 80 | + with: |
| 81 | + tool: nextest |
| 82 | + - if: ${{ runner.os == 'Linux' }} |
| 83 | + name: Linux - Install native dependencies |
| 84 | + run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev |
| 85 | + # just need a random command that forces the installation of rust-toolchain |
| 86 | + # figure out native target triple while we're at it |
| 87 | + - name: install rust-toolchain |
| 88 | + run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" |
| 89 | + - name: xtask cargo fetch --locked |
| 90 | + run: cd xtask && cargo fetch --locked --target $TARGET |
| 91 | + - name: xtask build |
| 92 | + run: cd xtask && cargo build |
| 93 | + - name: xtask test |
| 94 | + run: cd xtask && cargo nextest run |
| 95 | + - name: xtask fmt |
| 96 | + run: cd xtask && cargo fmt --all -- --check |
| 97 | + - name: xtask clippy |
| 98 | + run: cd xtask && cargo clippy --all-targets -- -D warnings |
| 99 | + |
| 100 | + lint: |
| 101 | + name: Lint |
| 102 | + runs-on: ubuntu-24.04 |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v4 |
| 105 | + - if: ${{ runner.os == 'Linux' }} |
| 106 | + name: Linux - Install native dependencies |
| 107 | + run: sudo apt install libwayland-cursor0 libxkbcommon-dev libwayland-dev |
| 108 | + # just need a random command that forces the installation of rust-toolchain |
| 109 | + # figure out native target triple while we're at it |
| 110 | + - name: install rust-toolchain |
| 111 | + run: echo "TARGET=$(rustc --print host-tuple)" >> "$GITHUB_ENV" |
| 112 | + - name: xtask cargo fetch --locked |
| 113 | + run: cd xtask && cargo fetch --locked --target $TARGET |
| 114 | + - name: xtask build |
| 115 | + run: cd xtask && cargo build |
| 116 | + - name: xtask generate |
| 117 | + run: cargo xtask generate |
| 118 | + - name: cargo fetch --locked |
| 119 | + run: cargo xtask generate cargo fetch --locked --target $TARGET |
| 120 | + - name: fmt |
| 121 | + run: cargo xtask generate cargo fmt --all -- --check |
| 122 | + - name: clippy |
| 123 | + run: cargo xtask generate cargo clippy --all-targets -- -D warnings |
| 124 | + |
| 125 | +defaults: |
| 126 | + run: |
| 127 | + shell: bash |
0 commit comments