diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a73d77cc838c8..3dd3f69843bad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,16 +26,11 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable + - uses: Leafwing-Studios/cargo-cache@v2 + with: + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Build & run tests @@ -50,18 +45,11 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-ci-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable + - uses: Leafwing-Studios/cargo-cache@v2 with: - components: rustfmt, clippy + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -77,19 +65,14 @@ jobs: timeout-minutes: 60 steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-miri-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} components: miri + - uses: Leafwing-Studios/cargo-cache@v2 + with: + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: CI job # To run the tests one item at a time for troubleshooting, use # cargo --quiet test --lib -- --list | sed 's/: test$//' | MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-permissive-provenance -Zmiri-disable-weak-memory-emulation" xargs -n1 cargo miri test -p bevy_ecs --lib -- --exact @@ -109,20 +92,11 @@ jobs: needs: ci steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - crates/bevy_ecs_compile_fail_tests/target/ - crates/bevy_reflect_compile_fail_tests/target/ - key: ${{ runner.os }}-cargo-check-compiles-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable + - uses: Leafwing-Studios/cargo-cache@v2 with: - toolchain: stable + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Check Compile @@ -135,18 +109,13 @@ jobs: needs: build steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ubuntu-assets-cargo-build-wasm-stable-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown + - uses: Leafwing-Studios/cargo-cache@v2 + with: + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Check wasm run: cargo check --target wasm32-unknown-unknown @@ -156,20 +125,15 @@ jobs: needs: build steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ubuntu-assets-cargo-build-wasm-nightly-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} targets: wasm32-unknown-unknown components: rust-src + - uses: Leafwing-Studios/cargo-cache@v2 + with: + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Check wasm run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort env: @@ -237,6 +201,10 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable + - uses: Leafwing-Studios/cargo-cache@v2 + with: + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Disable audio # Disable audio through a patch. on github m1 runners, audio timeouts after 15 minutes run: git apply --ignore-whitespace tools/example-showcase/disable-audio.patch @@ -280,16 +248,13 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 + - uses: dtolnay/rust-toolchain@master with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }} - - uses: dtolnay/rust-toolchain@stable + toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} + - uses: Leafwing-Studios/cargo-cache@v2 + with: + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -382,15 +347,6 @@ jobs: needs: build steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.toml') }} - name: get MSRV id: msrv run: | @@ -399,6 +355,10 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ steps.msrv.outputs.msrv }} + - uses: Leafwing-Studios/cargo-cache@v2 + with: + # Only save if we're running on the main branch, so that other branches can also use this cache. + save-if: ${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Run cargo check diff --git a/.github/workflows/validation-jobs.yml b/.github/workflows/validation-jobs.yml index f5fab3f976d6d..b1aecd4001320 100644 --- a/.github/workflows/validation-jobs.yml +++ b/.github/workflows/validation-jobs.yml @@ -27,12 +27,6 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: actions/cache@v4 - with: - path: | - target - key: ${{ runner.os }}-ios-install-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }} - # TODO: remove x86 target once it always run on arm GitHub runners - name: Add iOS targets run: rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim @@ -49,16 +43,6 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-build-android-${{ hashFiles('**/Cargo.toml') }} - - name: Install Android targets run: rustup target add aarch64-linux-android armv7-linux-androideabi @@ -81,15 +65,6 @@ jobs: run: | sudo add-apt-repository ppa:kisak/turtle -y sudo apt-get install --no-install-recommends libxkbcommon-x11-0 xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-run-examples-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable - name: Build bevy # this uses the same command as when running the example to ensure build is reused @@ -181,17 +156,6 @@ jobs: with: target: wasm32-unknown-unknown - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.github/start-wasm-example/node_modules - target/ - key: ${{ runner.os }}-wasm-run-examples-${{ hashFiles('**/Cargo.toml') }} - - name: install xvfb, llvmpipe and lavapipe run: | sudo apt-get update -y -qq @@ -266,15 +230,6 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-check-unused-dependencies-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} @@ -291,15 +246,6 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-check-showcase-patches-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps