diff --git a/.circleci/config.yml b/.circleci/config.yml index 389ce63a..fbfb6dd7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -19,9 +19,13 @@ jobs: - run: rustup default stable-x86_64-pc-windows-msvc - run: choco install -y mingw --version=13.2.0 - run: choco install -y nsis + # Install quality tools + - run: cargo install cargo-audit # Run checks - run: cargo check - run: cargo fmt -- --check + - run: cargo clippy -- -D warnings + - run: cargo audit - run: name: Lint PowerShell installer scripts (PSScriptAnalyzer) shell: powershell.exe @@ -110,8 +114,12 @@ jobs: # Install quality tools - run: | $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; + Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" install cargo-audit' # Run checks - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" check' + - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" fmt -- --check' + - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" clippy -- -D warnings' + - run: $env:PATH = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\ARM64\bin;" + $env:PATH; Invoke-Expression '& "$env:USERPROFILE\.cargo\bin\cargo" audit' - run: name: Lint PowerShell installer scripts (PSScriptAnalyzer) shell: powershell.exe @@ -199,8 +207,13 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add x86_64-unknown-linux-musl + # Install quality tools + - run: cargo install cargo-audit # Run checks - run: cargo check + - run: cargo fmt -- --check + - run: cargo clippy -- -D warnings + - run: cargo audit - run: . "$HOME/.cargo/env"; cargo build --target=x86_64-unknown-linux-musl --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/x86_64-unknown-linux-musl/release/openaev-agent @@ -259,8 +272,13 @@ jobs: - run: sudo apt-get -y install curl musl-tools - run: curl https://sh.rustup.rs -sSf | sh -s -- -y - run: . "$HOME/.cargo/env"; rustup target add aarch64-unknown-linux-musl + # Install quality tools + - run: cargo install cargo-audit # Run checks - run: cargo check + - run: cargo fmt -- --check + - run: cargo clippy -- -D warnings + - run: cargo audit - run: . "$HOME/.cargo/env"; cargo build --target=aarch64-unknown-linux-musl --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/aarch64-unknown-linux-musl/release/openaev-agent @@ -317,8 +335,13 @@ jobs: - cargo-{{ arch }}-{{ checksum "Cargo.toml" }} - cargo-{{ arch }} - run: curl https://sh.rustup.rs -sSf | sh -s -- -y + # Install quality tools + - run: cargo install cargo-audit # Run checks - run: cargo check + - run: cargo fmt -- --check + - run: cargo clippy -- -D warnings + - run: cargo audit - run: . "$HOME/.cargo/env"; cargo build --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/release/openaev-agent @@ -374,12 +397,12 @@ jobs: - run: rustup toolchain install stable-x86_64-apple-darwin - run: rustup default stable-x86_64-apple-darwin # Install quality tools - - run: | - rustup component add clippy - rustup component add rustfmt - cargo install cargo-audit + - run: cargo install cargo-audit # Run checks - run: cargo check + - run: cargo fmt -- --check + - run: cargo clippy -- -D warnings + - run: cargo audit - run: . "$HOME/.cargo/env"; cargo build --release - run: . "$HOME/.cargo/env"; cargo test --release - run: strip ./target/release/openaev-agent diff --git a/src/api/manage_jobs.rs b/src/api/manage_jobs.rs index 296c652a..2b14d778 100644 --- a/src/api/manage_jobs.rs +++ b/src/api/manage_jobs.rs @@ -44,7 +44,7 @@ impl Client { } } Err(err) => { - error!("Error API list_jobs {}", err.to_string()); + error!("Error API list_jobs {}", err); Err(Error::Internal(err.to_string())) } } @@ -65,7 +65,7 @@ impl Client { } } Err(err) => { - error!("Error API clean_job {}", err.to_string()); + error!("Error API clean_job {}", err); Err(Error::Internal(err.to_string())) } } diff --git a/src/api/register_agent.rs b/src/api/register_agent.rs index 830ef8d3..a3774ebf 100644 --- a/src/api/register_agent.rs +++ b/src/api/register_agent.rs @@ -116,7 +116,7 @@ impl Client { } } Err(err) => { - error!("Error API register_agent {}", err.to_string()); + error!("Error API register_agent {}", err); Err(Error::Internal(err.to_string())) } } diff --git a/src/process/agent_job.rs b/src/process/agent_job.rs index c4becfb8..6ad7383a 100644 --- a/src/process/agent_job.rs +++ b/src/process/agent_job.rs @@ -28,8 +28,8 @@ pub fn listen( execution_details.executed_by_user.clone(), tenant_id.clone(), ); - if jobs.is_ok() { - if let Ok(jobs) = jobs { + match jobs { + Ok(jobs) => { jobs.iter().for_each(|j| { info!("Start handling inject: {:?}", j.asset_agent_inject); // 01. Remove the execution job @@ -46,8 +46,9 @@ pub fn listen( info!("Done handling inject: {:?}", j.asset_agent_inject); }); } - } else { - error!("Fail getting jobs {}", jobs.unwrap_err()) + Err(err) => { + error!("Fail getting jobs {}", err) + } } // Wait for the next ping (30 secs) sleep(Duration::from_secs(30)); diff --git a/src/process/keep_alive.rs b/src/process/keep_alive.rs index c0a38d6e..74d7e105 100644 --- a/src/process/keep_alive.rs +++ b/src/process/keep_alive.rs @@ -8,6 +8,7 @@ use std::thread; use std::thread::{sleep, JoinHandle}; use std::time::Duration; +#[allow(clippy::too_many_arguments)] pub fn ping( uri: String, token: String, @@ -32,8 +33,8 @@ pub fn ping( service_name.clone(), tenant_id.clone(), ); - if register.is_err() { - error!("Fail registering the agent {}", register.unwrap_err()) + if let Err(err) = register { + error!("Fail registering the agent {}", err) } // Wait for the next ping (2 minutes) sleep(Duration::from_secs(120));