From 79135e1e0c93af9c50d612d95f888323fed0ee23 Mon Sep 17 00:00:00 2001 From: eiiko6 Date: Wed, 3 Jun 2026 10:27:17 +0200 Subject: [PATCH] added CI and fixed clippy errors --- .gitea/workflows/cli.yml | 55 ++++++++++++++++++++++++++++++++++ .gitea/workflows/server.yml | 59 +++++++++++++++++++++++++++++++++++++ .gitignore | 1 + src/slimes.rs | 14 ++++----- 4 files changed, 121 insertions(+), 8 deletions(-) create mode 100644 .gitea/workflows/cli.yml create mode 100644 .gitea/workflows/server.yml diff --git a/.gitea/workflows/cli.yml b/.gitea/workflows/cli.yml new file mode 100644 index 0000000..f48f413 --- /dev/null +++ b/.gitea/workflows/cli.yml @@ -0,0 +1,55 @@ +name: CLI Rust lint and build + +on: + push: + branches: [main] + paths: + - 'src/**' + - 'Cargo/**' + - '.gitea/workflows/cli.yml' + pull_request: + paths: + - 'src/**' + - 'Cargo/**' + - '.gitea/workflows/cli.yml' + +jobs: + ci: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure Cargo Cache + uses: actions/cache@v5 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt, clippy + + - name: Rustfmt + run: cargo fmt --all -- --check + + - name: Check + run: cargo check + + - name: Clippy + run: cargo clippy -- -D warnings + + - name: Test + run: cargo test + + - name: Build + run: cargo build diff --git a/.gitea/workflows/server.yml b/.gitea/workflows/server.yml new file mode 100644 index 0000000..1135b91 --- /dev/null +++ b/.gitea/workflows/server.yml @@ -0,0 +1,59 @@ +name: Server Rust lint and build + +on: + push: + branches: [main] + paths: + - 'server/src/**' + - 'server/Cargo/**' + - '.gitea/workflows/server.yml' + pull_request: + paths: + - 'server/src/**' + - 'server/Cargo/**' + - '.gitea/workflows/server.yml' + +jobs: + ci: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: server + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure Cargo Cache + uses: actions/cache@v5 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Install Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt, clippy + + - name: Rustfmt + run: cargo fmt --all -- --check + + - name: Check + run: cargo check + + - name: Clippy + run: cargo clippy -- -D warnings + + - name: Test + run: cargo test + + - name: Build + run: cargo build diff --git a/.gitignore b/.gitignore index d787b70..537ac0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target /result +*.swp diff --git a/src/slimes.rs b/src/slimes.rs index a5d594c..ecec422 100644 --- a/src/slimes.rs +++ b/src/slimes.rs @@ -25,7 +25,7 @@ pub trait Slime { } } - fn print_from_values(&self, values: &Vec) { + fn print_from_values(&self, values: &[String]) { for (i, val) in values.iter().enumerate() { if i == 0 { print!( @@ -42,7 +42,7 @@ pub trait Slime { } pub fn get_all_slimes() -> Vec> { - let mut slimes: Vec> = vec![ + let slimes: Vec> = vec![ Box::new(OsSlime), Box::new(KernelSlime), Box::new(HostnameSlime), @@ -51,14 +51,12 @@ pub fn get_all_slimes() -> Vec> { Box::new(GpuSlime), Box::new(RamSlime), Box::new(NetworkSlime), + #[cfg(feature = "monitors")] + Box::new(MonitorSlime), + #[cfg(feature = "audio")] + Box::new(AudioSlime), ]; - #[cfg(feature = "monitors")] - slimes.push(Box::new(MonitorSlime)); - - #[cfg(feature = "audio")] - slimes.push(Box::new(AudioSlime)); - slimes }