|
| 1 | +name: Update Actions Caches |
| 2 | + |
| 3 | +on: |
| 4 | + # Manually |
| 5 | + workflow_dispatch: |
| 6 | + # On PR merge |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + # After nightly release |
| 11 | + schedule: |
| 12 | + - cron: "0 1 * * *" |
| 13 | + |
| 14 | +env: |
| 15 | + CARGO_INCREMENTAL: 0 |
| 16 | + CARGO_PROFILE_TEST_DEBUG: 0 |
| 17 | + CARGO_PROFILE_DEV_DEBUG: 0 |
| 18 | + # If nightly is breaking CI, modify this variable to target a specific nightly version. |
| 19 | + NIGHTLY_TOOLCHAIN: nightly |
| 20 | + |
| 21 | +jobs: |
| 22 | + env: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + outputs: |
| 25 | + NIGHTLY_TOOLCHAIN: ${{ steps.env.outputs.NIGHTLY_TOOLCHAIN }} |
| 26 | + MSRV: ${{ steps.env.outputs.MSRV }} |
| 27 | + steps: |
| 28 | + - uses: actions/checkout@v4 |
| 29 | + - uses: dtolnay/rust-toolchain@stable |
| 30 | + - name: get MSRV |
| 31 | + id: msrv |
| 32 | + run: | |
| 33 | + msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="bevy") | .rust_version'` |
| 34 | + echo "MSRV=$msrv" >> $GITHUB_OUTPUT |
| 35 | + - name: Expose Env |
| 36 | + id: env |
| 37 | + run: | |
| 38 | + echo "NIGHTLY_TOOLCHAIN=${{ env.NIGHTLY_TOOLCHAIN }}" >> $GITHUB_OUTPUT |
| 39 | +
|
| 40 | + build-caches: |
| 41 | + name: Build Caches |
| 42 | + needs: ["env"] |
| 43 | + runs-on: ${{ matrix.os }} |
| 44 | + strategy: |
| 45 | + matrix: |
| 46 | + include: |
| 47 | + - os: ubuntu-latest |
| 48 | + toolchain: stable |
| 49 | + target: "" |
| 50 | + - os: macos-latest |
| 51 | + toolchain: stable |
| 52 | + target: "" |
| 53 | + - os: windows-latest |
| 54 | + toolchain: stable |
| 55 | + target: "" |
| 56 | + - os: ubuntu-latest |
| 57 | + toolchain: ${{ needs.env.outputs.NIGHTLY_TOOLCHAIN }} |
| 58 | + target: "" |
| 59 | + - os: ubuntu-latest |
| 60 | + toolchain: ${{ needs.env.outputs.MSRV }} |
| 61 | + target: "" |
| 62 | + - os: macos-latest |
| 63 | + toolchain: ${{ needs.env.outputs.NIGHTLY_TOOLCHAIN }} |
| 64 | + target: "" |
| 65 | + - os: ubuntu-latest |
| 66 | + toolchain: ${{ needs.env.outputs.NIGHTLY_TOOLCHAIN }} |
| 67 | + target: wasm32-unknown-unknown |
| 68 | + - os: ubuntu-latest |
| 69 | + toolchain: stable |
| 70 | + target: wasm32-unknown-unknown |
| 71 | + - os: ubuntu-latest |
| 72 | + toolchain: stable |
| 73 | + target: x86_64-unknown-none |
| 74 | + - os: ubuntu-latest |
| 75 | + toolchain: stable |
| 76 | + target: thumbv6m-none-eabi |
| 77 | + - os: ubuntu-latest |
| 78 | + toolchain: stable |
| 79 | + target: thumbv6m-none-eabi |
| 80 | + - os: ubuntu-latest |
| 81 | + toolchain: stable |
| 82 | + target: aarch64-linux-android |
| 83 | + - os: macos-latest |
| 84 | + toolchain: stable |
| 85 | + target: aarch64-apple-ios-sim |
| 86 | + |
| 87 | + steps: |
| 88 | + - name: Get Date |
| 89 | + id: get-date |
| 90 | + run: | |
| 91 | + echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT |
| 92 | + shell: bash |
| 93 | + |
| 94 | + - name: Checkout Bevy main branch |
| 95 | + uses: actions/checkout@v4 |
| 96 | + with: |
| 97 | + repository: "bevyengine/bevy" |
| 98 | + |
| 99 | + - name: Setup Rust |
| 100 | + id: rust |
| 101 | + uses: dtolnay/rust-toolchain@main |
| 102 | + with: |
| 103 | + toolchain: ${{ matrix.toolchain }} |
| 104 | + target: ${{ matrix.target }} |
| 105 | + |
| 106 | + - name: Create lock file |
| 107 | + run: cargo update |
| 108 | + |
| 109 | + - name: Install Bevy dependencies |
| 110 | + if: runner.os == 'linux' |
| 111 | + run: | |
| 112 | + sudo apt-get update; |
| 113 | + DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \ |
| 114 | + libasound2-dev libudev-dev libxkbcommon-x11-0; |
| 115 | +
|
| 116 | + - uses: actions/cache/restore@v4 |
| 117 | + id: cache |
| 118 | + with: |
| 119 | + key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ steps.get-date.outputs.date }} |
| 120 | + |
| 121 | + - name: Build dev cache |
| 122 | + if: steps.cache.outputs.cache-hit != 'true' |
| 123 | + run: cargo build --profile dev --package bevy |
| 124 | + |
| 125 | + - name: Build test cache |
| 126 | + if: steps.cache.outputs.cache-hit != 'true' |
| 127 | + run: cargo build --profile test --package bevy |
| 128 | + |
| 129 | + - name: Save cache |
| 130 | + if: steps.cache.outputs.cache-hit != 'true' |
| 131 | + uses: actions/cache/save@v4 |
| 132 | + with: |
| 133 | + path: | |
| 134 | + ~/.cargo/bin/ |
| 135 | + ~/.cargo/registry/index/ |
| 136 | + ~/.cargo/registry/cache/ |
| 137 | + ~/.cargo/git/db/ |
| 138 | + target/ |
| 139 | + key: ${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('Cargo.lock') }}-${{ steps.get-date.outputs.date }} |
0 commit comments