From f1fbe7081209b18a1fb2294638731bc7cbbfac6e Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:24:53 -0400 Subject: [PATCH 01/16] feat: create cache action --- .github/actions/cache/action.yml | 102 +++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/actions/cache/action.yml diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml new file mode 100644 index 0000000000000..82366ab2ab7f3 --- /dev/null +++ b/.github/actions/cache/action.yml @@ -0,0 +1,102 @@ +name: Cache +description: Save and restore the cache, to speed up build times! +inputs: + kind: + description: > + The type of cache to use. This will affect what files are cached and the overall size. + Possible options: `build`, `check`, and `doc`. + required: true + toolchain: + description: > + The Rust toolchain to use. Stable and nightly caches are incompatible with each other. + Possible options: `stable` and `nightly`. + required: false + default: stable + target: + description: > + The target to use. `default` refers to the current platform. + Possible options: `default`, `wasm`, and `wasm-atomics`. + required: false + default: default + action: + description: > + Whether to save or restore a cache. You likely want `restore` for most occassions. + Possible options: `save` and `restore`. + required: false + default: restore +runs: + using: composite + steps: + # The cache key includes the current date, so that each day we get a new cache. This is to ensure that + # dependencies are up-to-date that the incremental compiler does not need to do much more work. + - name: Retrieve current date + id: date + shell: bash + run: echo date=$(date +'%Y-%m-%d') >> $GITHUB_OUTPUT + + # The cache key is the identifier that differentiates multiple caches. We include lots of data in the key + # to optimize what we are caching and prevent issues. + # + # The cache `kind` specifies what "level" of cache we want. Different commands such as `cargo check` and + # `cargo build` generate different amounts of data. We specify these levels so our workflows do not end up + # downloading unused data. + # + # The cache `toolchain` specifies whether we are using stable or nightly Rust. You usually cannot use a + # nightly cache on stable Rust, which is why we need two separate ones. + # + # The cache `os` specifies which of the three operating systems we are using: Ubuntu, Windows, or MacOS. + # The cached files can be platform-dependent (especially with `cargo build`), which is why we need to + # differentiate between OS's. + # + # The cache `target` specifies which target we are building for. By default it is the target of the current + # platform, but for some cases like WASM we need to differentiate between them. Targets usually store files + # in subfolders such as `target/wasm32-unknown-unknown`, so using the default is pointless. + - name: Calculate restore key + id: restore-key + shell: bash + run: echo key=${{ inputs.kind }}-${{ inputs.toolchain }}-${{ runner.os }}-${{ inputs.target }} + + # But wait, I thought we were calculating the cache key in the previous step? What are we doing here? + # + # `actions/cache` supports a feature known as restore keys, which are *fallback* keys in case the requested + # key does not exist. Our preferred cache key includes the date, but sometimes these daily jobs may fail. + # Instead of leaving all jobs for the day cache-less, we use a restore key to fallback to a previous day's + # cache. + # + # In this case, we calculate the restore key first then append on the date afterwords, so we have access to + # both. + - name: Calculate cache key + id: cache-key + shell: bash + run: echo key=${{ steps.restore-key.outputs.key }}-${{ steps.date.outputs.date }} + + # Either save a new cache... + - name: Save cache + if: ${{ inputs.action == 'save' }} + uses: actions/cache/save@v4 + with: + path: | + # Cache the incremental build information. This is arguably the most important part. + target/ + # Cache all of the downloaded dependencies. + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + # Cache all of the installed binaries. + ~/.cargo/bin/ + key: ${{ steps.cache-key.outputs.key }} + + # ...or restore an existing cache. + - name: Restore cache + if: ${{ inputs.action == 'restore' }} + uses: actions/cache/restore@v4 + with: + path: | + # Please keep this in sync with the previous step. :) + target/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.cargo/bin/ + key: ${{ steps.cache-key.outputs.key }} + restore-keys: ${{ steps.restore-key.outputs.key }} From 9798709ad1c3c21b5826c49a8c8e79792e10e984 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:50:35 -0400 Subject: [PATCH 02/16] feat: create caches workflow --- .github/workflows/create-caches.yml | 100 ++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 .github/workflows/create-caches.yml diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml new file mode 100644 index 0000000000000..d2cab3dccfee4 --- /dev/null +++ b/.github/workflows/create-caches.yml @@ -0,0 +1,100 @@ +name: Create Caches + +on: + schedule: + # Run at 0:00 daily. (Basically as early as possible.) + - cron: 0 0 * * * + workflow_dispatch: + # TODO: Remove this. It is for testing purposes only. + pull_request: + +jobs: + build: + name: Build + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + toolchain: [stable] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + + - name: Build workspace + run: cargo build --workspace + + - name: Save cache + uses: ./.github/actions/cache + with: + kind: build + toolchain: ${{ matrix.toolchain }} + action: save + + check: + name: Check + strategy: + matrix: + include: + - os: ubuntu-latest + toolchain: nightly + target: default + - os: macos-latest + toolchain: nightly + target: default + - os: ubuntu-latest + toolchain: stable + target: wasm + - os: ubuntu-latest + toolchain: nightly + target: wasm-atomics + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + + - name: Build workspace + run: cargo check --workspace + + - name: Save cache + uses: ./.github/actions/cache + with: + kind: check + toolchain: ${{ matrix.toolchain }} + target: ${{ matrix.target }} + action: save + + doc: + name: Doc + strategy: + matrix: + os: [ubuntu-latest] + toolchain: [nightly] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + + - name: Build workspace + run: cargo doc -p bevy --no-deps + + - name: Save cache + uses: ./.github/actions/cache + with: + kind: doc + toolchain: ${{ matrix.toolchain }} + action: save From 47d7144d0fab249b13810d6554f72e9eb59f9ac7 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Fri, 19 Apr 2024 23:02:22 -0400 Subject: [PATCH 03/16] feat: more improvements Add a concurrency group, disable fail-fast, and install dependencies on Linux. --- .github/workflows/create-caches.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml index d2cab3dccfee4..45b0022799ba7 100644 --- a/.github/workflows/create-caches.yml +++ b/.github/workflows/create-caches.yml @@ -8,10 +8,16 @@ on: # TODO: Remove this. It is for testing purposes only. pull_request: +# Prevent this workflow from being run more than once at a time. +concurrency: + group: ${{ github.workflow }} + jobs: build: name: Build strategy: + # Don't cancel everything if one configuration happens to fail. + fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] toolchain: [stable] @@ -25,6 +31,9 @@ jobs: with: toolchain: ${{ matrix.toolchain }} + - name: Install Linux dependencies + uses: ./.github/actions/install-linux-deps + - name: Build workspace run: cargo build --workspace @@ -38,6 +47,8 @@ jobs: check: name: Check strategy: + # Don't cancel everything if one configuration happens to fail. + fail-fast: false matrix: include: - os: ubuntu-latest @@ -62,6 +73,9 @@ jobs: with: toolchain: ${{ matrix.toolchain }} + - name: Install Linux dependencies + uses: ./.github/actions/install-linux-deps + - name: Build workspace run: cargo check --workspace @@ -76,6 +90,8 @@ jobs: doc: name: Doc strategy: + # Don't cancel everything if one configuration happens to fail. + fail-fast: false matrix: os: [ubuntu-latest] toolchain: [nightly] @@ -89,6 +105,9 @@ jobs: with: toolchain: ${{ matrix.toolchain }} + - name: Install Linux dependencies + uses: ./.github/actions/install-linux-deps + - name: Build workspace run: cargo doc -p bevy --no-deps From 142a50441283b13dba98989a581bc46a5bc8c85c Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:15:20 -0400 Subject: [PATCH 04/16] feat: even more improvements Actually export cache keys to Github output, only use a cache when not in a merge group, customize Rust installation for WASM, and use proper command for docs. --- .github/actions/cache/action.yml | 7 +++--- .github/workflows/create-caches.yml | 35 ++++++++++++++++++++++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index 82366ab2ab7f3..d648e0c9be4d8 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -54,7 +54,7 @@ runs: - name: Calculate restore key id: restore-key shell: bash - run: echo key=${{ inputs.kind }}-${{ inputs.toolchain }}-${{ runner.os }}-${{ inputs.target }} + run: echo key=${{ inputs.kind }}-${{ inputs.toolchain }}-${{ runner.os }}-${{ inputs.target }} >> $GITHUB_OUTPUT # But wait, I thought we were calculating the cache key in the previous step? What are we doing here? # @@ -68,7 +68,7 @@ runs: - name: Calculate cache key id: cache-key shell: bash - run: echo key=${{ steps.restore-key.outputs.key }}-${{ steps.date.outputs.date }} + run: echo key=${{ steps.restore-key.outputs.key }}-${{ steps.date.outputs.date }} >> $GITHUB_OUTPUT # Either save a new cache... - name: Save cache @@ -88,7 +88,8 @@ runs: # ...or restore an existing cache. - name: Restore cache - if: ${{ inputs.action == 'restore' }} + # We do not use the cache when in the merge queue. + if: ${{ inputs.action == 'restore' && github.event_name == 'merge_group' }} uses: actions/cache/restore@v4 with: path: | diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml index 45b0022799ba7..5440cbd7fb2cd 100644 --- a/.github/workflows/create-caches.yml +++ b/.github/workflows/create-caches.yml @@ -69,16 +69,43 @@ jobs: uses: actions/checkout@v4 - name: Install Rust + if: ${{ matrix.target == 'default' }} uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} + + - name: Install Rust (WASM) + if: ${{ matrix.target == 'wasm' }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + target: wasm32-unknown-unknown + + - name: Install Rust (WASM Atomics) + if: ${{ matrix.target == 'wasm-atomics' }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + target: wasm32-unknown-unknown + components: rust-src - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - - name: Build workspace + - name: Check workspace + if: ${{ matrix.target == 'default' }} run: cargo check --workspace + - name: Check workspace + if: ${{ matrix.target == 'wasm' }} + run: cargo check --workspace --target wasm32-unknown-unknown + + - name: Check workspace + if: ${{ matrix.target == 'wasm-atomics' }} + run: cargo check --workspace --target wasm32-unknown-unknown -Z build-std=std,panic_abort + env: + RUSTFLAGS: "-C target-feature=+atomics,+bulk-memory" + - name: Save cache uses: ./.github/actions/cache with: @@ -108,8 +135,10 @@ jobs: - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - - name: Build workspace - run: cargo doc -p bevy --no-deps + - name: Document workspace + run: | + cargo doc --workspace --all-features --no-deps --document-private-items + cargo test --workspace --doc - name: Save cache uses: ./.github/actions/cache From 2800287b4af05c1f0b726b1a4d70ceb199765963 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:22:39 -0400 Subject: [PATCH 05/16] fix: install wayland dependencies in docs --- .github/workflows/create-caches.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml index 5440cbd7fb2cd..7837da811df78 100644 --- a/.github/workflows/create-caches.yml +++ b/.github/workflows/create-caches.yml @@ -134,6 +134,9 @@ jobs: - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps + with: + wayland: true + xkb: true - name: Document workspace run: | From 4fe21141cff19343939a7bed7d6bafe8c41bae72 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:30:34 -0400 Subject: [PATCH 06/16] fix: don't check workspace in wasm Also split it out into a separate job. --- .github/workflows/create-caches.yml | 47 ++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml index 7837da811df78..80208c0445aef 100644 --- a/.github/workflows/create-caches.yml +++ b/.github/workflows/create-caches.yml @@ -57,6 +57,36 @@ jobs: - os: macos-latest toolchain: nightly target: default + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.toolchain }} + + - name: Install Linux dependencies + uses: ./.github/actions/install-linux-deps + + - name: Check workspace + if: ${{ matrix.target == 'default' }} + run: cargo check --workspace + + - name: Save cache + uses: ./.github/actions/cache + with: + kind: check + toolchain: ${{ matrix.toolchain }} + target: ${{ matrix.target }} + action: save + + check-wasm: + name: Check WASM + strategy: + matrix: + include: - os: ubuntu-latest toolchain: stable target: wasm @@ -68,12 +98,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Install Rust - if: ${{ matrix.target == 'default' }} - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.toolchain }} - - name: Install Rust (WASM) if: ${{ matrix.target == 'wasm' }} uses: dtolnay/rust-toolchain@master @@ -89,20 +113,13 @@ jobs: target: wasm32-unknown-unknown components: rust-src - - name: Install Linux dependencies - uses: ./.github/actions/install-linux-deps - - - name: Check workspace - if: ${{ matrix.target == 'default' }} - run: cargo check --workspace - - name: Check workspace if: ${{ matrix.target == 'wasm' }} - run: cargo check --workspace --target wasm32-unknown-unknown + run: cargo check --target wasm32-unknown-unknown - name: Check workspace if: ${{ matrix.target == 'wasm-atomics' }} - run: cargo check --workspace --target wasm32-unknown-unknown -Z build-std=std,panic_abort + run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort env: RUSTFLAGS: "-C target-feature=+atomics,+bulk-memory" From 30cde58e4ccc163ef614a0a21dbffdf973f6d7a4 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:41:04 -0400 Subject: [PATCH 07/16] fix: exclude `bevy_dylib` from build --- .github/workflows/create-caches.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml index 80208c0445aef..84c7e6c3d913f 100644 --- a/.github/workflows/create-caches.yml +++ b/.github/workflows/create-caches.yml @@ -35,7 +35,8 @@ jobs: uses: ./.github/actions/install-linux-deps - name: Build workspace - run: cargo build --workspace + # Exclude bevy_dylib because it causes a linker error on Windows due to exporting more than 65k objects. + run: cargo build --workspace --exclude bevy_dylib - name: Save cache uses: ./.github/actions/cache From 7a99df5514416a93944f7a43d7d76ec617a8287e Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:43:49 -0400 Subject: [PATCH 08/16] feat: test first in doc This should hopefully speed up the doc job by ~3 minutes. Since `cargo test` needs to build the entire workspace but `cargo doc` only needs to check it, `cargo doc` can take advantage of the work that `cargo test` has already done. --- .github/workflows/create-caches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml index 84c7e6c3d913f..ff2e816742a83 100644 --- a/.github/workflows/create-caches.yml +++ b/.github/workflows/create-caches.yml @@ -158,8 +158,8 @@ jobs: - name: Document workspace run: | - cargo doc --workspace --all-features --no-deps --document-private-items cargo test --workspace --doc + cargo doc --workspace --all-features --no-deps --document-private-items - name: Save cache uses: ./.github/actions/cache From 427046ba0f0e38b639b2c7404581c72225f22a3b Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:51:07 -0400 Subject: [PATCH 09/16] feat: use new cache action in `ci.yml` A few other driveby fixes too. I removed the unecessary `components: rustfmt, clippy` specification. I also made the doc job use nightly Rust. --- .github/workflows/ci.yml | 117 +++++++++++---------------------------- 1 file changed, 32 insertions(+), 85 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb377b64cb3e9..029bc5850e05f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,16 +24,10 @@ 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: ./.github/actions/cache + with: + kind: build - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Build & run tests @@ -48,18 +42,10 @@ 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: ./.github/actions/cache with: - components: rustfmt, clippy + kind: check - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -74,19 +60,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: ./.github/actions/cache + with: + kind: check + toolchain: nightly - 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 @@ -106,20 +87,10 @@ 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: ./.github/actions/cache with: - toolchain: stable + kind: build - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Check Compile @@ -132,18 +103,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: ./.github/actions/cache + with: + kind: check + target: wasm - name: Check wasm run: cargo check --target wasm32-unknown-unknown @@ -153,20 +119,16 @@ 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: ./.github/actions/cache + with: + kind: check + toolchain: nightly + target: wasm-atomics - name: Check wasm run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort env: @@ -233,6 +195,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable + # TODO: Cache? - 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 @@ -276,16 +239,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: ./.github/actions/cache + with: + kind: doc + toolchain: nightly - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -378,15 +338,7 @@ 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') }} + # TODO: Cache with Rust version? - name: get MSRV run: | msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="bevy") | .rust_version'` @@ -436,18 +388,13 @@ 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 }}-check-doc-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} + - uses: ./.github/actions/cache + with: + kind: check + toolchain: nightly - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: From f9d6a94c4cd254e694ece6ced85377f9188b118d Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 11:53:00 -0400 Subject: [PATCH 10/16] fix: *not* merge group This bug caused the cache to never be restored. --- .github/actions/cache/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index d648e0c9be4d8..323d6a0364ac2 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -89,7 +89,7 @@ runs: # ...or restore an existing cache. - name: Restore cache # We do not use the cache when in the merge queue. - if: ${{ inputs.action == 'restore' && github.event_name == 'merge_group' }} + if: ${{ inputs.action == 'restore' && github.event_name != 'merge_group' }} uses: actions/cache/restore@v4 with: path: | From ec17d1db184b213843ac5f3dc51de8a0bb78e6a9 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Apr 2024 12:06:38 -0400 Subject: [PATCH 11/16] fix: don't save caches from merge queues This is a just in case, and likely will never become a problem. Github's cache isolation policy prevents caches created in merge queues from being used by any other branch. --- .github/actions/cache/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index 323d6a0364ac2..2f00abf774710 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -72,7 +72,8 @@ runs: # Either save a new cache... - name: Save cache - if: ${{ inputs.action == 'save' }} + # We don't save caches from the merge queue either, due to Github's cache isolation policy. + if: ${{ inputs.action == 'save' && github.event_name != 'merge_group' }} uses: actions/cache/save@v4 with: path: | From b32c80a695b823cb8693acb3afe7de323d9974fb Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:19:02 -0400 Subject: [PATCH 12/16] feat!: use Leafwing-Studios/cargo-cache instead This may prove easier to setup and maintain than the homespun implementation used earlier. --- .github/actions/cache/action.yml | 104 ----------------- .github/workflows/ci.yml | 42 ++----- .github/workflows/create-caches.yml | 169 ---------------------------- 3 files changed, 10 insertions(+), 305 deletions(-) delete mode 100644 .github/actions/cache/action.yml delete mode 100644 .github/workflows/create-caches.yml diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml deleted file mode 100644 index 2f00abf774710..0000000000000 --- a/.github/actions/cache/action.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: Cache -description: Save and restore the cache, to speed up build times! -inputs: - kind: - description: > - The type of cache to use. This will affect what files are cached and the overall size. - Possible options: `build`, `check`, and `doc`. - required: true - toolchain: - description: > - The Rust toolchain to use. Stable and nightly caches are incompatible with each other. - Possible options: `stable` and `nightly`. - required: false - default: stable - target: - description: > - The target to use. `default` refers to the current platform. - Possible options: `default`, `wasm`, and `wasm-atomics`. - required: false - default: default - action: - description: > - Whether to save or restore a cache. You likely want `restore` for most occassions. - Possible options: `save` and `restore`. - required: false - default: restore -runs: - using: composite - steps: - # The cache key includes the current date, so that each day we get a new cache. This is to ensure that - # dependencies are up-to-date that the incremental compiler does not need to do much more work. - - name: Retrieve current date - id: date - shell: bash - run: echo date=$(date +'%Y-%m-%d') >> $GITHUB_OUTPUT - - # The cache key is the identifier that differentiates multiple caches. We include lots of data in the key - # to optimize what we are caching and prevent issues. - # - # The cache `kind` specifies what "level" of cache we want. Different commands such as `cargo check` and - # `cargo build` generate different amounts of data. We specify these levels so our workflows do not end up - # downloading unused data. - # - # The cache `toolchain` specifies whether we are using stable or nightly Rust. You usually cannot use a - # nightly cache on stable Rust, which is why we need two separate ones. - # - # The cache `os` specifies which of the three operating systems we are using: Ubuntu, Windows, or MacOS. - # The cached files can be platform-dependent (especially with `cargo build`), which is why we need to - # differentiate between OS's. - # - # The cache `target` specifies which target we are building for. By default it is the target of the current - # platform, but for some cases like WASM we need to differentiate between them. Targets usually store files - # in subfolders such as `target/wasm32-unknown-unknown`, so using the default is pointless. - - name: Calculate restore key - id: restore-key - shell: bash - run: echo key=${{ inputs.kind }}-${{ inputs.toolchain }}-${{ runner.os }}-${{ inputs.target }} >> $GITHUB_OUTPUT - - # But wait, I thought we were calculating the cache key in the previous step? What are we doing here? - # - # `actions/cache` supports a feature known as restore keys, which are *fallback* keys in case the requested - # key does not exist. Our preferred cache key includes the date, but sometimes these daily jobs may fail. - # Instead of leaving all jobs for the day cache-less, we use a restore key to fallback to a previous day's - # cache. - # - # In this case, we calculate the restore key first then append on the date afterwords, so we have access to - # both. - - name: Calculate cache key - id: cache-key - shell: bash - run: echo key=${{ steps.restore-key.outputs.key }}-${{ steps.date.outputs.date }} >> $GITHUB_OUTPUT - - # Either save a new cache... - - name: Save cache - # We don't save caches from the merge queue either, due to Github's cache isolation policy. - if: ${{ inputs.action == 'save' && github.event_name != 'merge_group' }} - uses: actions/cache/save@v4 - with: - path: | - # Cache the incremental build information. This is arguably the most important part. - target/ - # Cache all of the downloaded dependencies. - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - # Cache all of the installed binaries. - ~/.cargo/bin/ - key: ${{ steps.cache-key.outputs.key }} - - # ...or restore an existing cache. - - name: Restore cache - # We do not use the cache when in the merge queue. - if: ${{ inputs.action == 'restore' && github.event_name != 'merge_group' }} - uses: actions/cache/restore@v4 - with: - path: | - # Please keep this in sync with the previous step. :) - target/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - ~/.cargo/bin/ - key: ${{ steps.cache-key.outputs.key }} - restore-keys: ${{ steps.restore-key.outputs.key }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 029bc5850e05f..493642a61dc85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,9 +25,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: ./.github/actions/cache - with: - kind: build + - uses: Leafwing-Studios/cargo-cache@v1 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Build & run tests @@ -43,9 +41,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: ./.github/actions/cache - with: - kind: check + - uses: Leafwing-Studios/cargo-cache@v1 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -64,10 +60,7 @@ jobs: with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} components: miri - - uses: ./.github/actions/cache - with: - kind: check - toolchain: nightly + - uses: Leafwing-Studios/cargo-cache@v1 - 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 @@ -88,9 +81,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: ./.github/actions/cache - with: - kind: build + - uses: Leafwing-Studios/cargo-cache@v1 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Check Compile @@ -106,10 +97,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown - - uses: ./.github/actions/cache - with: - kind: check - target: wasm + - uses: Leafwing-Studios/cargo-cache@v1 - name: Check wasm run: cargo check --target wasm32-unknown-unknown @@ -124,11 +112,7 @@ jobs: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} targets: wasm32-unknown-unknown components: rust-src - - uses: ./.github/actions/cache - with: - kind: check - toolchain: nightly - target: wasm-atomics + - uses: Leafwing-Studios/cargo-cache@v1 - name: Check wasm run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort env: @@ -195,7 +179,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - # TODO: Cache? + - uses: Leafwing-Studios/cargo-cache@v1 - 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 @@ -242,10 +226,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} - - uses: ./.github/actions/cache - with: - kind: doc - toolchain: nightly + - uses: Leafwing-Studios/cargo-cache@v1 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -338,7 +319,6 @@ jobs: needs: build steps: - uses: actions/checkout@v4 - # TODO: Cache with Rust version? - name: get MSRV run: | msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="bevy") | .rust_version'` @@ -346,6 +326,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.MSRV }} + - uses: Leafwing-Studios/cargo-cache@v1 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Run cargo check @@ -391,10 +372,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} - - uses: ./.github/actions/cache - with: - kind: check - toolchain: nightly + - uses: Leafwing-Studios/cargo-cache@v1 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: diff --git a/.github/workflows/create-caches.yml b/.github/workflows/create-caches.yml deleted file mode 100644 index ff2e816742a83..0000000000000 --- a/.github/workflows/create-caches.yml +++ /dev/null @@ -1,169 +0,0 @@ -name: Create Caches - -on: - schedule: - # Run at 0:00 daily. (Basically as early as possible.) - - cron: 0 0 * * * - workflow_dispatch: - # TODO: Remove this. It is for testing purposes only. - pull_request: - -# Prevent this workflow from being run more than once at a time. -concurrency: - group: ${{ github.workflow }} - -jobs: - build: - name: Build - strategy: - # Don't cancel everything if one configuration happens to fail. - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - toolchain: [stable] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.toolchain }} - - - name: Install Linux dependencies - uses: ./.github/actions/install-linux-deps - - - name: Build workspace - # Exclude bevy_dylib because it causes a linker error on Windows due to exporting more than 65k objects. - run: cargo build --workspace --exclude bevy_dylib - - - name: Save cache - uses: ./.github/actions/cache - with: - kind: build - toolchain: ${{ matrix.toolchain }} - action: save - - check: - name: Check - strategy: - # Don't cancel everything if one configuration happens to fail. - fail-fast: false - matrix: - include: - - os: ubuntu-latest - toolchain: nightly - target: default - - os: macos-latest - toolchain: nightly - target: default - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.toolchain }} - - - name: Install Linux dependencies - uses: ./.github/actions/install-linux-deps - - - name: Check workspace - if: ${{ matrix.target == 'default' }} - run: cargo check --workspace - - - name: Save cache - uses: ./.github/actions/cache - with: - kind: check - toolchain: ${{ matrix.toolchain }} - target: ${{ matrix.target }} - action: save - - check-wasm: - name: Check WASM - strategy: - matrix: - include: - - os: ubuntu-latest - toolchain: stable - target: wasm - - os: ubuntu-latest - toolchain: nightly - target: wasm-atomics - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Rust (WASM) - if: ${{ matrix.target == 'wasm' }} - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.toolchain }} - target: wasm32-unknown-unknown - - - name: Install Rust (WASM Atomics) - if: ${{ matrix.target == 'wasm-atomics' }} - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.toolchain }} - target: wasm32-unknown-unknown - components: rust-src - - - name: Check workspace - if: ${{ matrix.target == 'wasm' }} - run: cargo check --target wasm32-unknown-unknown - - - name: Check workspace - if: ${{ matrix.target == 'wasm-atomics' }} - run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort - env: - RUSTFLAGS: "-C target-feature=+atomics,+bulk-memory" - - - name: Save cache - uses: ./.github/actions/cache - with: - kind: check - toolchain: ${{ matrix.toolchain }} - target: ${{ matrix.target }} - action: save - - doc: - name: Doc - strategy: - # Don't cancel everything if one configuration happens to fail. - fail-fast: false - matrix: - os: [ubuntu-latest] - toolchain: [nightly] - runs-on: ${{ matrix.os }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.toolchain }} - - - name: Install Linux dependencies - uses: ./.github/actions/install-linux-deps - with: - wayland: true - xkb: true - - - name: Document workspace - run: | - cargo test --workspace --doc - cargo doc --workspace --all-features --no-deps --document-private-items - - - name: Save cache - uses: ./.github/actions/cache - with: - kind: doc - toolchain: ${{ matrix.toolchain }} - action: save From 04e7bd53bf0cfa5e9deea1a310d26db7c6f93260 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:29:21 -0400 Subject: [PATCH 13/16] feat: remove caching from validation jobs --- .github/workflows/validation-jobs.yml | 54 --------------------------- 1 file changed, 54 deletions(-) diff --git a/.github/workflows/validation-jobs.yml b/.github/workflows/validation-jobs.yml index 34bc3f3e4ad6c..36f04872f7260 100644 --- a/.github/workflows/validation-jobs.yml +++ b/.github/workflows/validation-jobs.yml @@ -26,12 +26,6 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: actions/cache@v4 - with: - path: | - target - key: ${{ runner.os }}-ios-install-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }} - - name: Add iOS targets run: rustup target add aarch64-apple-ios x86_64-apple-ios @@ -47,16 +41,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 @@ -79,15 +63,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 @@ -179,17 +154,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 @@ -264,15 +228,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 }} @@ -289,15 +244,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: Installs cargo-udeps run: cargo install --force cargo-udeps From e9e2426b1119b28082c998c69d973f6b2a6c3e92 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Wed, 17 Jul 2024 09:22:40 -0400 Subject: [PATCH 14/16] feat: bump to `cargo-cache@v2` --- .github/workflows/ci.yml | 20 ++++++++++---------- .github/workflows/validation-jobs.yml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6c0e6f363898..60152bdb6af86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Build & run tests @@ -43,7 +43,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -63,7 +63,7 @@ jobs: with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} components: miri - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - 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 @@ -84,7 +84,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Check Compile @@ -100,7 +100,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: target: wasm32-unknown-unknown - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Check wasm run: cargo check --target wasm32-unknown-unknown @@ -115,7 +115,7 @@ jobs: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} targets: wasm32-unknown-unknown components: rust-src - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Check wasm run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort env: @@ -183,7 +183,7 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - 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 @@ -230,7 +230,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -331,7 +331,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ steps.msrv.outputs.msrv }} - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Run cargo check @@ -377,7 +377,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 - name: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: diff --git a/.github/workflows/validation-jobs.yml b/.github/workflows/validation-jobs.yml index 2484073050b26..05db57affaf54 100644 --- a/.github/workflows/validation-jobs.yml +++ b/.github/workflows/validation-jobs.yml @@ -27,7 +27,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - - uses: Leafwing-Studios/cargo-cache@v1 + - uses: Leafwing-Studios/cargo-cache@v2 # TODO: remove x86 target once it always run on arm GitHub runners - name: Add iOS targets From 9e9f57fe119e3c649b9eb3b1be3ed7be44101ce3 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Sat, 20 Jul 2024 17:13:06 -0400 Subject: [PATCH 15/16] feat: `save-if` to only save on the `main` branch --- .github/workflows/ci.yml | 30 +++++++++++++++++++++++++++ .github/workflows/validation-jobs.yml | 3 +++ 2 files changed, 33 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2b06c5c7c12a..69cc76dbf8ac0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,9 @@ jobs: - 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: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Build & run tests @@ -44,6 +47,9 @@ jobs: - 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: Install Linux dependencies uses: ./.github/actions/install-linux-deps with: @@ -64,6 +70,9 @@ jobs: 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 @@ -85,6 +94,9 @@ jobs: - 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: Install Linux dependencies uses: ./.github/actions/install-linux-deps - name: Check Compile @@ -101,6 +113,9 @@ jobs: 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 @@ -116,6 +131,9 @@ jobs: 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: @@ -184,6 +202,9 @@ jobs: - 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 @@ -231,6 +252,9 @@ jobs: with: 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: @@ -332,6 +356,9 @@ jobs: 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 @@ -378,6 +405,9 @@ jobs: with: 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: diff --git a/.github/workflows/validation-jobs.yml b/.github/workflows/validation-jobs.yml index 07756c7f818c8..2d61a58f2752f 100644 --- a/.github/workflows/validation-jobs.yml +++ b/.github/workflows/validation-jobs.yml @@ -28,6 +28,9 @@ jobs: - 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) }} # TODO: remove x86 target once it always run on arm GitHub runners - name: Add iOS targets From 5f9688154c6640a31dd57df86a478d55676a34f2 Mon Sep 17 00:00:00 2001 From: BD103 <59022059+BD103@users.noreply.github.com> Date: Tue, 13 Aug 2024 15:14:42 -0400 Subject: [PATCH 16/16] fix: remove leftover validation cache --- .github/workflows/validation-jobs.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/validation-jobs.yml b/.github/workflows/validation-jobs.yml index ccdd9214b0fd1..b1aecd4001320 100644 --- a/.github/workflows/validation-jobs.yml +++ b/.github/workflows/validation-jobs.yml @@ -27,11 +27,6 @@ jobs: - 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) }} - # 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