Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/build.yml

This file was deleted.

104 changes: 104 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings
RUSTDOCFLAGS: --deny warnings

jobs:
# Check formatting.
format:
name: Format
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt

- name: Check formatting
run: cargo fmt --all -- --check

# Run Clippy lints.
clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Restore Rust cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Run Clippy lints
run: cargo clippy --workspace --all-features --all-targets -- --deny warnings

# Check documentation.
doc:
name: Docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Restore Rust cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Check documentation
run: cargo doc --workspace --document-private-items --no-deps

# Run tests.
test:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Restore Rust cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Run tests
run: |
cargo test --workspace --all-features --all-targets
# TODO: Workaround for https://github.com/rust-lang/cargo/issues/6669
cargo test --workspace --all-features --doc
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ clap = { version = "4.5.16", features = ["derive"] }
iyes_perf_ui = { git = "https://github.com/IyesGames/iyes_perf_ui.git", rev = "8e6dd6072c2e093b5353f62970e55304175dbe8f" }
rand = "0.9"

[profile.test]
inherits = "release"

[lints]
clippy.type_complexity = "allow"
[lints.clippy]
too_many_arguments = "allow"
type_complexity = "allow"
2 changes: 1 addition & 1 deletion examples/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use bevy_spritesheet_animation::prelude::*;
use clap::{Parser, ValueEnum};
use common::random_position;
use iyes_perf_ui::prelude::*;
use rand::{seq::IndexedRandom as _, Rng};
use rand::{Rng, seq::IndexedRandom as _};

#[derive(ValueEnum, Clone)]
enum Mode {
Expand Down
28 changes: 16 additions & 12 deletions src/animator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,26 +228,29 @@ impl Animator {
.sprite
.as_deref_mut()
.and_then(|sprite| sprite.texture_atlas.as_mut())
&& atlas.index != frame.atlas_index {
atlas.index = frame.atlas_index;
}
&& atlas.index != frame.atlas_index
{
atlas.index = frame.atlas_index;
}

#[cfg(feature = "3d")]
if let Some(atlas) = item
.sprite3d
.as_deref_mut()
.and_then(|sprite| sprite.texture_atlas.as_mut())
&& atlas.index != frame.atlas_index {
atlas.index = frame.atlas_index;
}
&& atlas.index != frame.atlas_index
{
atlas.index = frame.atlas_index;
}

if let Some(atlas) = item
.image_node
.as_deref_mut()
.and_then(|image| image.texture_atlas.as_mut())
&& atlas.index != frame.atlas_index {
atlas.index = frame.atlas_index;
}
&& atlas.index != frame.atlas_index
{
atlas.index = frame.atlas_index;
}

#[cfg(feature = "custom_cursor")]
if let Some(atlas) = item
Expand All @@ -267,9 +270,10 @@ impl Animator {
}
})
.and_then(|atlas| atlas.as_mut())
&& atlas.index != frame.atlas_index {
atlas.index = frame.atlas_index;
}
&& atlas.index != frame.atlas_index
{
atlas.index = frame.atlas_index;
}

item.spritesheet_animation.progress = *progress;

Expand Down
2 changes: 1 addition & 1 deletion src/animator/cache.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{
CRATE_NAME,
animation::{AnimationDirection, AnimationDuration, AnimationId, AnimationRepeat},
clip::{Clip, ClipId},
easing::Easing,
events::AnimationMarkerId,
library::AnimationLibrary,
CRATE_NAME,
};
use bevy::{log::warn, reflect::prelude::*};
use std::time::Duration;
Expand Down
4 changes: 2 additions & 2 deletions src/animator/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::{sync::Arc, time::Duration};
use bevy::{log::warn, reflect::prelude::*};

use crate::{
animation::AnimationDirection, clip::ClipId,
components::spritesheet_animation::AnimationProgress, events::AnimationMarkerId, CRATE_NAME,
CRATE_NAME, animation::AnimationDirection, clip::ClipId,
components::spritesheet_animation::AnimationProgress, events::AnimationMarkerId,
};

use super::cache::{AnimationCache, AnimationCacheEvent, CacheFrame};
Expand Down
4 changes: 2 additions & 2 deletions src/components/sprite3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use bevy::{

/// Specifies the rendering properties of a 3D sprite.
///
/// This contains similar fields as Bevy's [Sprite](bevy::sprite::Sprite).
/// This contains similar fields as Bevy's [Sprite].
///
/// # Note
///
Expand Down Expand Up @@ -137,6 +137,6 @@ impl Sprite3d {

pub fn double_sided(mut self, ds: bool) -> Self {
self.double_sided = ds;
self
self
}
}
8 changes: 2 additions & 6 deletions src/library.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::{
collections::{HashMap, HashSet},
sync::{
Arc,
// TODO: Use bevy_platform when updated to Bevy 0.16.
atomic::{AtomicUsize, Ordering},
Arc,
},
};

Expand Down Expand Up @@ -393,11 +393,7 @@ impl AnimationLibrary {
pub fn animation_with_name(&self, name: impl AsRef<str>) -> Option<AnimationId> {
self.animation_names.iter().find_map(
|(k, v)| {
if v == name.as_ref() {
Some(*k)
} else {
None
}
if v == name.as_ref() { Some(*k) } else { None }
},
)
}
Expand Down
18 changes: 10 additions & 8 deletions tests/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,16 @@ fn animations() {

// Name it again, replacing the old name

assert!(ctx
.library()
.name_animation(animation1_id, "first again")
.is_ok());

assert!(ctx
.library()
.is_animation_name(animation1_id, "first again"));
assert!(
ctx.library()
.name_animation(animation1_id, "first again")
.is_ok()
);

assert!(
ctx.library()
.is_animation_name(animation1_id, "first again")
);
assert_eq!(
ctx.library().get_animation_name(animation1_id),
Some("first again")
Expand Down
11 changes: 6 additions & 5 deletions tests/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ fn library_available_as_a_resource() {
fn animation_events_available_as_a_resource() {
let ctx = Context::new();

assert!(ctx
.app
.world()
.get_resource::<Events<AnimationEvent>>()
.is_some());
assert!(
ctx.app
.world()
.get_resource::<Events<AnimationEvent>>()
.is_some()
);
}
Loading