From 75dacda36d9482d99c753ca9aa91fbe2a5279d89 Mon Sep 17 00:00:00 2001 From: Guy Garcia Date: Mon, 30 Jun 2025 22:18:49 -0400 Subject: [PATCH 1/2] ci --- .github/workflows/ci.yml | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ed14c54 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,91 @@ +name: CI +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + +env: + # Reduce compile time and cache size. + RUSTFLAGS: -Dwarnings -Zshare-generics=y -Zthreads=0 + RUSTDOCFLAGS: -Dwarnings -Zshare-generics=y -Zthreads=0 + # Use the same Rust toolchain across jobs so they can share a cache. + toolchain: nightly-2025-04-03 + +jobs: + # Check formatting. + format: + name: Format + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.toolchain }} + components: rustfmt + + - name: Check formatting + run: cargo fmt --all -- --check + + # Run Clippy lints. + clippy-lints: + name: Clippy lints + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.toolchain }} + components: clippy + + - name: Restore Rust cache + id: cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: ci + save-if: ${{ github.ref == 'refs/heads/main' }} + + - name: Install build dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev + + - name: Run Clippy lints + run: cargo clippy --locked --all-targets --all-features + + # Run Bevy lints. + bevy-lints: + name: Bevy lints + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust toolchain (plus bevy_lint) + uses: TheBevyFlock/bevy_cli/bevy_lint@lint-v0.3.0 + + - name: Restore Rust cache + id: cache + uses: Swatinem/rust-cache@v2 + with: + shared-key: ci + save-if: false + + - name: Install build dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev + + - name: Run Bevy lints + run: bevy_lint --locked --all-targets --all-features \ No newline at end of file From 4196974a29cd5c0e2fddb5295076b5adde7aeb25 Mon Sep 17 00:00:00 2001 From: Guy Garcia Date: Mon, 30 Jun 2025 22:23:00 -0400 Subject: [PATCH 2/2] formatting --- examples/config_extension.rs | 2 +- examples/load_part.rs | 2 +- examples/replace_mesh.rs | 2 +- src/lib.rs | 2 +- src/part_loader.rs | 4 +++- src/part_path.rs | 8 ++++---- src/parts_map.rs | 3 ++- src/plugin.rs | 3 ++- 8 files changed, 15 insertions(+), 11 deletions(-) diff --git a/examples/config_extension.rs b/examples/config_extension.rs index 383ac28..1080e03 100644 --- a/examples/config_extension.rs +++ b/examples/config_extension.rs @@ -4,7 +4,7 @@ use bevy::prelude::{ App, AppExtStates, Camera3d, Commands, NextState, OnEnter, PointLight, Reflect, Res, ResMut, States, Transform, Vec3, default, }; -use bevy_runtime_gltf_loader::{RuntimeGlftLoaderPlugin, PartsMap}; +use bevy_runtime_gltf_loader::{PartsMap, RuntimeGlftLoaderPlugin}; use serde::Deserialize; #[derive(States, Default, Copy, Clone, Debug, PartialEq, Eq, Hash)] diff --git a/examples/load_part.rs b/examples/load_part.rs index 7b4c843..e2076c6 100644 --- a/examples/load_part.rs +++ b/examples/load_part.rs @@ -4,7 +4,7 @@ use bevy::prelude::{ App, AppExtStates, Camera3d, Commands, NextState, OnEnter, PointLight, Res, ResMut, States, Transform, Vec3, default, }; -use bevy_runtime_gltf_loader::{SimpleRuntimeGltfLoaderPlugin, SimplePartsMap}; +use bevy_runtime_gltf_loader::{SimplePartsMap, SimpleRuntimeGltfLoaderPlugin}; #[derive(States, Default, Copy, Clone, Debug, PartialEq, Eq, Hash)] enum RuntimeState { diff --git a/examples/replace_mesh.rs b/examples/replace_mesh.rs index 0a5fa3a..2435902 100644 --- a/examples/replace_mesh.rs +++ b/examples/replace_mesh.rs @@ -6,7 +6,7 @@ use bevy::prelude::{ Reflect, Res, ResMut, StandardMaterial, States, Transform, Vec3, default, }; use bevy::render::render_resource::{AsBindGroup, ShaderRef}; -use bevy_runtime_gltf_loader::{SimpleRuntimeGltfLoaderPlugin, SimplePartsMap}; +use bevy_runtime_gltf_loader::{SimplePartsMap, SimpleRuntimeGltfLoaderPlugin}; #[derive(States, Default, Copy, Clone, Debug, PartialEq, Eq, Hash)] enum RuntimeState { diff --git a/src/lib.rs b/src/lib.rs index 2e184e5..ddb0587 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ mod plugin; pub use config_singleton::*; pub use extend_gltf_material::*; -pub use part_path::*; pub use part_loader::*; +pub use part_path::*; pub use parts_map::*; pub use plugin::*; diff --git a/src/part_loader.rs b/src/part_loader.rs index 25157ca..83d6a77 100644 --- a/src/part_loader.rs +++ b/src/part_loader.rs @@ -1,7 +1,9 @@ use crate::{EmptyMaterialExtension, WithMaterialExtension}; use bevy::asset::AssetServer; use bevy::pbr::MaterialExtension; -use bevy::prelude::{BuildChildrenTransformExt, Commands, Entity, GltfAssetLabel, Res, SceneRoot, Transform}; +use bevy::prelude::{ + BuildChildrenTransformExt, Commands, Entity, GltfAssetLabel, Res, SceneRoot, Transform, +}; use std::marker::PhantomData; pub struct PartLoader<'a, EXTENSION, MATERIAL = EmptyMaterialExtension> { diff --git a/src/part_path.rs b/src/part_path.rs index c9ee2d4..30cb536 100644 --- a/src/part_path.rs +++ b/src/part_path.rs @@ -1,8 +1,8 @@ -use std::error::Error; -use std::fmt::Display; -use bevy::prelude::BevyError; use crate::part_loader::PartLoader; +use bevy::prelude::BevyError; use serde::{Deserialize, Serialize}; +use std::error::Error; +use std::fmt::Display; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PartPath { @@ -29,4 +29,4 @@ impl Display for MissingData { } } -impl Error for MissingData {} \ No newline at end of file +impl Error for MissingData {} diff --git a/src/parts_map.rs b/src/parts_map.rs index a29061e..b50ecdb 100644 --- a/src/parts_map.rs +++ b/src/parts_map.rs @@ -17,7 +17,8 @@ impl Default for PartsMap { impl PartsMap { pub fn load_part(&self, name: &str) -> Result<&PartPath, BevyError> { - self.get(name).ok_or(BevyError::from(PartNotFoundError::new(name))) + self.get(name) + .ok_or(BevyError::from(PartNotFoundError::new(name))) } } diff --git a/src/plugin.rs b/src/plugin.rs index 5d4a3c8..3c84b31 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -11,7 +11,8 @@ use std::marker::PhantomData; pub type SimpleRuntimeGltfLoaderPlugin = RuntimeGlftLoaderPlugin; -pub struct RuntimeGlftLoaderPlugin { +pub struct RuntimeGlftLoaderPlugin +{ file_ending: &'static str, // Load a single config as a resource load_single: Option>,