fix clippy and check it on ci (#18)
This commit is contained in:
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
branches: ["master"]
|
branches: ["master"]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
debug:
|
ci:
|
||||||
runs-on: [self-hosted, linux]
|
runs-on: [self-hosted, linux]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -23,16 +23,18 @@ jobs:
|
|||||||
packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
|
packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
|
||||||
version: 1.0
|
version: 1.0
|
||||||
|
|
||||||
|
- name: Formatting
|
||||||
|
run: |
|
||||||
|
cargo fmt --check
|
||||||
|
|
||||||
|
- name: Lints
|
||||||
|
run: |
|
||||||
|
cargo clippy
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cargo build --locked --target=x86_64-unknown-linux-gnu
|
cargo build
|
||||||
|
|
||||||
- name: Archive
|
- name: Lints
|
||||||
run: |
|
run: |
|
||||||
cp target/x86_64-unknown-linux-gnu/debug/hedz_reloaded hedz_reloaded
|
cargo test
|
||||||
tar -czf steamos-debug.tar.gz hedz_reloaded
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: steamos-debug.tar.gz
|
|
||||||
path: ./steamos-debug.tar.gz
|
|
||||||
|
|||||||
40
.github/workflows/ci_debug.yml
vendored
Normal file
40
.github/workflows/ci_debug.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: ci_debug
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch: # Enables manual triggers
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
debug:
|
||||||
|
runs-on: [self-hosted, linux]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: cargo-bins/cargo-binstall@main
|
||||||
|
- uses: extractions/setup-just@v1
|
||||||
|
- uses: dtolnay/rust-toolchain@master
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
components: clippy, rustfmt
|
||||||
|
|
||||||
|
- name: "Install and cache dependencies (Linux)"
|
||||||
|
uses: awalsh128/cache-apt-pkgs-action@latest
|
||||||
|
with:
|
||||||
|
packages: libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
|
||||||
|
version: 1.0
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cargo build --locked --target=x86_64-unknown-linux-gnu
|
||||||
|
|
||||||
|
- name: Lints
|
||||||
|
run: |
|
||||||
|
cargo clippy
|
||||||
|
|
||||||
|
- name: Archive
|
||||||
|
run: |
|
||||||
|
cp target/x86_64-unknown-linux-gnu/debug/hedz_reloaded hedz_reloaded
|
||||||
|
tar -czf steamos-debug.tar.gz hedz_reloaded
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: steamos-debug.tar.gz
|
||||||
|
path: ./steamos-debug.tar.gz
|
||||||
@@ -27,3 +27,7 @@ bevy_sprite3d = "4.0.0"
|
|||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
bevy-inspector-egui = { version = "0.30", optional = true }
|
bevy-inspector-egui = { version = "0.30", optional = true }
|
||||||
bevy_polyline = "0.11.0"
|
bevy_polyline = "0.11.0"
|
||||||
|
|
||||||
|
[lints.clippy]
|
||||||
|
too_many_arguments = "allow"
|
||||||
|
type_complexity = "allow"
|
||||||
|
|||||||
6
justfile
6
justfile
@@ -7,3 +7,9 @@ tb_setup_mac:
|
|||||||
|
|
||||||
dbg:
|
dbg:
|
||||||
RUST_BACKTRACE=1 cargo r --features dbg
|
RUST_BACKTRACE=1 cargo r --features dbg
|
||||||
|
|
||||||
|
check:
|
||||||
|
cargo fmt --check
|
||||||
|
cargo b
|
||||||
|
cargo test
|
||||||
|
cargo clippy
|
||||||
|
|||||||
@@ -280,18 +280,14 @@ fn swap_head_inputs(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
if action == BackpackAction::Left {
|
if action == BackpackAction::Left && state.current_slot > 0 {
|
||||||
if state.current_slot > 0 {
|
|
||||||
state.current_slot -= 1;
|
state.current_slot -= 1;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
if action == BackpackAction::Right && state.current_slot < state.count.saturating_sub(1) {
|
||||||
if action == BackpackAction::Right {
|
|
||||||
if state.current_slot < state.count.saturating_sub(1) {
|
|
||||||
state.current_slot += 1;
|
state.current_slot += 1;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if action == BackpackAction::Swap {
|
if action == BackpackAction::Swap {
|
||||||
commands.trigger(BackbackSwapEvent(state.current_slot));
|
commands.trigger(BackbackSwapEvent(state.current_slot));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ pub fn plugin(app: &mut App) {
|
|||||||
fn setup(mut commands: Commands) {
|
fn setup(mut commands: Commands) {
|
||||||
commands.insert_resource(Backpack {
|
commands.insert_resource(Backpack {
|
||||||
heads: (0usize..HEAD_COUNT)
|
heads: (0usize..HEAD_COUNT)
|
||||||
.into_iter()
|
|
||||||
.map(|i| BackpackHead {
|
.map(|i| BackpackHead {
|
||||||
head: i,
|
head: i,
|
||||||
health: 1.,
|
health: 1.,
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ fn startup(mut commands: Commands) {
|
|||||||
|
|
||||||
fn update_look_around(controls: Res<Controls>, mut cam_state: ResMut<CameraState>) {
|
fn update_look_around(controls: Res<Controls>, mut cam_state: ResMut<CameraState>) {
|
||||||
let look_around =
|
let look_around =
|
||||||
controls.keyboard_state.view_mode || controls.gamepad_state.map_or(false, |g| g.view_mode);
|
controls.keyboard_state.view_mode || controls.gamepad_state.is_some_and(|g| g.view_mode);
|
||||||
|
|
||||||
if look_around != cam_state.look_around {
|
if look_around != cam_state.look_around {
|
||||||
cam_state.look_around = look_around;
|
cam_state.look_around = look_around;
|
||||||
|
|||||||
@@ -239,11 +239,9 @@ fn set_movement_flag(mut player_movement: ResMut<PlayerMovement>, controls: Res<
|
|||||||
if direction.length_squared() < deadzone {
|
if direction.length_squared() < deadzone {
|
||||||
player_movement.any_direction = false;
|
player_movement.any_direction = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else if direction.length_squared() > deadzone {
|
||||||
if direction.length_squared() > deadzone {
|
|
||||||
player_movement.any_direction = true;
|
player_movement.any_direction = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Responds to [`MovementAction`] events and moves character controllers accordingly.
|
/// Responds to [`MovementAction`] events and moves character controllers accordingly.
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ fn gamepad_controls(
|
|||||||
if rotate < 0.5 - EPSILON {
|
if rotate < 0.5 - EPSILON {
|
||||||
40. * (rotate - 0.5)
|
40. * (rotate - 0.5)
|
||||||
} else if rotate > 0.5 + EPSILON {
|
} else if rotate > 0.5 + EPSILON {
|
||||||
40. * (rotate - 0.5)
|
-40. * (rotate - 0.5)
|
||||||
} else {
|
} else {
|
||||||
0.
|
0.
|
||||||
},
|
},
|
||||||
@@ -189,8 +189,8 @@ fn mouse_click(mut events: EventReader<MouseButtonInput>, mut commands: Commands
|
|||||||
|
|
||||||
fn gamepad_connections(mut evr_gamepad: EventReader<GamepadEvent>) {
|
fn gamepad_connections(mut evr_gamepad: EventReader<GamepadEvent>) {
|
||||||
for ev in evr_gamepad.read() {
|
for ev in evr_gamepad.read() {
|
||||||
match ev {
|
if let GamepadEvent::Connection(connection) = ev {
|
||||||
GamepadEvent::Connection(connection) => match &connection.connection {
|
match &connection.connection {
|
||||||
GamepadConnection::Connected {
|
GamepadConnection::Connected {
|
||||||
name,
|
name,
|
||||||
vendor_id,
|
vendor_id,
|
||||||
@@ -204,8 +204,7 @@ fn gamepad_connections(mut evr_gamepad: EventReader<GamepadEvent>) {
|
|||||||
GamepadConnection::Disconnected => {
|
GamepadConnection::Disconnected => {
|
||||||
info!("Lost connection with gamepad: {:?}", connection.gamepad);
|
info!("Lost connection with gamepad: {:?}", connection.gamepad);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ fn on_start_cutscene(
|
|||||||
let move_end = cutscene_movement
|
let move_end = cutscene_movement
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, _, target)| cutscene == target.target.clone().unwrap_or_default())
|
.find(|(_, _, target)| cutscene == target.target.clone().unwrap_or_default())
|
||||||
.map(|(t, _, _)| t.clone())
|
.map(|(t, _, _)| *t)
|
||||||
.unwrap_or_else(|| t.clone());
|
.unwrap_or_else(|| *t);
|
||||||
|
|
||||||
let Some((target, _)) = cam_target.iter().find(|(_, camera_target)| {
|
let Some((target, _)) = cam_target.iter().find(|(_, camera_target)| {
|
||||||
camera_target.targetname == target.target.clone().unwrap_or_default()
|
camera_target.targetname == target.target.clone().unwrap_or_default()
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ fn on_key(trigger: Trigger<KeyCollected>, mut commands: Commands) {
|
|||||||
|
|
||||||
let entities: HashSet<_> = vec!["fence_01", "fence_02"]
|
let entities: HashSet<_> = vec!["fence_01", "fence_02"]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|s| String::from(s))
|
.map(String::from)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
commands.trigger(PlaySound::Gate);
|
commands.trigger(PlaySound::Gate);
|
||||||
@@ -23,10 +23,7 @@ fn on_key(trigger: Trigger<KeyCollected>, mut commands: Commands) {
|
|||||||
"fence_shaft" => {
|
"fence_shaft" => {
|
||||||
commands.trigger(StartCutscene("cutscene_02".to_string()));
|
commands.trigger(StartCutscene("cutscene_02".to_string()));
|
||||||
|
|
||||||
let entities: HashSet<_> = vec!["fence_shaft"]
|
let entities: HashSet<_> = vec!["fence_shaft"].into_iter().map(String::from).collect();
|
||||||
.into_iter()
|
|
||||||
.map(|s| String::from(s))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
commands.trigger(PlaySound::Gate);
|
commands.trigger(PlaySound::Gate);
|
||||||
commands.trigger(TriggerMovableEvent(entities));
|
commands.trigger(TriggerMovableEvent(entities));
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let heads = (0usize..HEAD_COUNT)
|
let heads = (0usize..HEAD_COUNT)
|
||||||
.into_iter()
|
|
||||||
.map(|i| asset_server.load(format!("ui/heads/{}.png", head_id_to_str(i))))
|
.map(|i| asset_server.load(format!("ui/heads/{}.png", head_id_to_str(i))))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::{collections::HashMap, usize};
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
heads_ui::HEAD_COUNT, keys::KeySpawn, player::head_id_to_str, sounds::PlaySound,
|
heads_ui::HEAD_COUNT, keys::KeySpawn, player::head_id_to_str, sounds::PlaySound,
|
||||||
|
|||||||
@@ -151,11 +151,7 @@ fn enemy_hit(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let enemy_entity = query_npc
|
let enemy_entity = if query_npc.contains(*e1) { *e1 } else { *e2 };
|
||||||
.contains(*e1)
|
|
||||||
.then(|| *e1)
|
|
||||||
.or_else(|| Some(*e2))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
commands.entity(enemy_entity).trigger(Hit { damage: 20 });
|
commands.entity(enemy_entity).trigger(Hit { damage: 20 });
|
||||||
}
|
}
|
||||||
@@ -199,11 +195,7 @@ fn shot_collision(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let shot_entity = query_shot
|
let shot_entity = if query_shot.contains(*e1) { *e1 } else { *e2 };
|
||||||
.contains(*e1)
|
|
||||||
.then(|| *e1)
|
|
||||||
.or_else(|| Some(*e2))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let shot_pos = query_shot.get(shot_entity).unwrap().1.translation;
|
let shot_pos = query_shot.get(shot_entity).unwrap().1.translation;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user