From f7343d37d799fd62ca2c0598685d26305f2e005d Mon Sep 17 00:00:00 2001 From: Nero Alpha Date: Thu, 18 Apr 2024 14:05:19 +0000 Subject: [PATCH 1/3] [NRO-6] Add GitHub workflow for Rust checks: testing, fmt, clippy Establishes a CI workflow for Rust. It includes running tests, enforcing code formatting with `cargo fmt`, and linting with `clippy`. This ensures all pushed code and PRs against main comply with these quality checks. --- .github/workflows/rust_checks.yml | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/rust_checks.yml diff --git a/.github/workflows/rust_checks.yml b/.github/workflows/rust_checks.yml new file mode 100644 index 0000000..fea3d26 --- /dev/null +++ b/.github/workflows/rust_checks.yml @@ -0,0 +1,53 @@ +name: Rust Checks + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + name: Run tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Run tests + run: cargo test --all + + check_format: + name: Check format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Check format + run: cargo fmt -- --check + + check_clippy: + name: Check clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: clippy + override: true + - name: Run Clippy + run: cargo clippy -- -D warnings From 2ed952c54c7450bbbd79191e1a6fcec03c0132b8 Mon Sep 17 00:00:00 2001 From: Nero Alpha Date: Thu, 18 Apr 2024 14:12:47 +0000 Subject: [PATCH 2/3] [NRO-6] Fix GitHub Actions workflow by correcting Cargo command paths Resolved the GitHub Actions workflow issue where `Cargo.toml` was not found by adjusting the working directory before executing `cargo` commands. This fix ensures that the `cargo test`, `cargo fmt`, and `cargo clippy` commands are run from the correct directory, thus eliminating the `Cargo.toml` not found error. --- .github/workflows/rust_checks.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust_checks.yml b/.github/workflows/rust_checks.yml index fea3d26..0594ef0 100644 --- a/.github/workflows/rust_checks.yml +++ b/.github/workflows/rust_checks.yml @@ -21,7 +21,9 @@ jobs: toolchain: stable override: true - name: Run tests - run: cargo test --all + run: | + cd .. # Move up from the .github directory to find the workspace root + cargo test --all check_format: name: Check format @@ -35,7 +37,9 @@ jobs: toolchain: stable override: true - name: Check format - run: cargo fmt -- --check + run: | + cd .. # Move up from the .github directory to find the workspace root + cargo fmt -- --check check_clippy: name: Check clippy @@ -50,4 +54,6 @@ jobs: components: clippy override: true - name: Run Clippy - run: cargo clippy -- -D warnings + run: | + cd .. # Move up from the .github directory to find the workspace root + cargo clippy -- -D warnings From a95fbb349a8d63e13cbce37bd7486482dea791e3 Mon Sep 17 00:00:00 2001 From: Nero Alpha Date: Thu, 18 Apr 2024 14:24:47 +0000 Subject: [PATCH 3/3] [NRO-6] Fix: Correct working directory for Cargo commands in CI workflow The commit fixes the issue where Cargo commands failed to locate the `Cargo.toml` by setting the working directory explicitly to `${{github.workspace}}` for test, format, and clippy jobs in the Rust checks CI workflow. --- .github/workflows/rust_checks.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rust_checks.yml b/.github/workflows/rust_checks.yml index 0594ef0..9849a6c 100644 --- a/.github/workflows/rust_checks.yml +++ b/.github/workflows/rust_checks.yml @@ -21,10 +21,9 @@ jobs: toolchain: stable override: true - name: Run tests - run: | - cd .. # Move up from the .github directory to find the workspace root - cargo test --all - + run: cargo test --all + working-directory: ${{github.workspace}} + check_format: name: Check format runs-on: ubuntu-latest @@ -37,9 +36,8 @@ jobs: toolchain: stable override: true - name: Check format - run: | - cd .. # Move up from the .github directory to find the workspace root - cargo fmt -- --check + run: cargo fmt -- --check + working-directory: ${{github.workspace}} check_clippy: name: Check clippy @@ -54,6 +52,5 @@ jobs: components: clippy override: true - name: Run Clippy - run: | - cd .. # Move up from the .github directory to find the workspace root - cargo clippy -- -D warnings + run: cargo clippy -- -D warnings + working-directory: ${{github.workspace}}