diff --git a/.github/actions/prepare/action.yaml b/.github/actions/prepare/action.yaml index 9b08c3a..dfcbc7e 100644 --- a/.github/actions/prepare/action.yaml +++ b/.github/actions/prepare/action.yaml @@ -1,5 +1,9 @@ name: 'Prepare' description: 'Prepare action runner' +inputs: + cache-key: + description: key for the cache + required: true runs: using: "composite" steps: @@ -15,7 +19,7 @@ runs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ - key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} + key: ${{inputs.cache-key}} - uses: dtolnay/rust-toolchain@master with: toolchain: stable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11c7cf7..a36f82e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,11 +13,13 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare/ + with: + cache-key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }} - name: Build & run tests run: cargo test -p bevy_asset_loader - name: Build & run tests for derive package run: cargo test -p bevy_asset_loader_derive - test-2d-3d-dynamic: + dynamic-2d-3d-test: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] @@ -25,6 +27,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare/ + with: + cache-key: ${{ runner.os }}-cargo-dynamic-2d-3d-test-${{ hashFiles('**/Cargo.toml') }} - name: Build & run tests for 2d, 3d, standard run: cargo test --features "2d, 3d, standard_dynamic_assets" -p bevy_asset_loader - name: Build & run tests for derive package @@ -37,6 +41,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare/ + with: + cache-key: ${{ runner.os }}-cargo-progress-tracking-test-${{ hashFiles('**/Cargo.toml') }} - name: Build & run tests progress tracking run: cargo test --features "progress_tracking" -p bevy_asset_loader full-test: @@ -47,12 +53,16 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare/ + with: + cache-key: ${{ runner.os }}-cargo-full-test-${{ hashFiles('**/Cargo.toml') }} - name: Build & run tests progress tracking and 2d,3d,dynamic run: cargo test --features "2d, 3d, standard_dynamic_assets, progress_tracking" -p bevy_asset_loader lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + cache-key: ubuntu-cargo-lint-${{ hashFiles('**/Cargo.toml') }} - uses: ./.github/actions/prepare/ - uses: taiki-e/install-action@v2 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index b7e826a..c7922eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - custom `on_unimplemented` diagnostics for the `AssetCollection` trait - image derive attribute `array_texture_layers` +- wait for dependencies of assets to load ## v0.21.0 - 05.07.2024 - support for Bevy 0.14 diff --git a/bevy_asset_loader/src/loading_state/systems.rs b/bevy_asset_loader/src/loading_state/systems.rs index 29047b6..0040a04 100644 --- a/bevy_asset_loader/src/loading_state/systems.rs +++ b/bevy_asset_loader/src/loading_state/systems.rs @@ -1,4 +1,4 @@ -use bevy::asset::{AssetServer, LoadState}; +use bevy::asset::{AssetServer, RecursiveDependencyLoadState}; use bevy::ecs::system::SystemState; use bevy::ecs::world::{FromWorld, World}; use bevy::log::{debug, info, trace, warn}; @@ -107,15 +107,14 @@ fn count_loaded_handles( let failure = loading_asset_handles.handles.iter().any(|handle| { matches!( - asset_server.get_load_state(handle.id()), - Some(LoadState::Failed(_)) + asset_server.get_recursive_dependency_load_state(handle.id()), + Some(RecursiveDependencyLoadState::Failed) ) }); let done = loading_asset_handles .handles .iter() - .map(|handle| asset_server.get_load_state(handle.id())) - .filter(|state| state == &Some(LoadState::Loaded)) + .filter(|handle| asset_server.is_loaded_with_dependencies(handle.id())) .count(); if done < total && !failure { return (done as u32, total as u32);