diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3b508e5..4e8a636 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,24 +7,57 @@ on: paths: - 'src/**' - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/rust.yml' pull_request: branches: - master paths: - 'src/**' - 'Cargo.toml' + - 'Cargo.lock' + - '.github/workflows/rust.yml' env: CARGO_TERM_COLOR: always jobs: - build: - + build_and_test: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + rust: [latest, 1.86.0, 1.77.2] steps: - - uses: actions/checkout@v3 - - name: Build - run: cargo build --verbose --release - - name: Run tests - run: cargo test --verbose + - name: Checkout code + uses: actions/checkout@v4 + + - name: Cache Cargo & target directories + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ matrix.rust }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ matrix.rust }}-${{ runner.os }}- + + - name: Build (${{ matrix.rust }}) + run: | + docker run --rm --user "$(id -u):$(id -g)" \ + -v "${HOME}/.cargo":/usr/local/cargo \ + -v "$(pwd)":/work -w /work \ + rust:${{ matrix.rust }} \ + cargo build --verbose --release + + - name: Run tests (${{ matrix.rust }}) + run: | + docker run --rm --user "$(id -u):$(id -g)" \ + -v "${HOME}/.cargo":/usr/local/cargo \ + -v "$(pwd)":/work -w /work \ + rust:${{ matrix.rust }} \ + cargo test --verbose diff --git a/Cargo.lock b/Cargo.lock index 466339e..50dcd48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "addr2line" diff --git a/flake.lock b/flake.lock index 0cf1126..d14b9e9 100644 --- a/flake.lock +++ b/flake.lock @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1701058557, - "narHash": "sha256-fux7HlrnoNs93MN0kET4AfiYwg/expoasndRCFeDRyk=", + "lastModified": 1735563628, + "narHash": "sha256-OnSAY7XDSx7CtDoqNh8jwVwh4xNL/2HaJxGjryLWzX8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "070b5cf9f70bc7ef2dfd739a1f7d6c563fe64bd1", + "rev": "b134951a4c9f3c995fd7be05f3243f8ecd65d798", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-23.11", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } diff --git a/src/commands/edge_app/setting.rs b/src/commands/edge_app/setting.rs index 72131f8..92976a5 100644 --- a/src/commands/edge_app/setting.rs +++ b/src/commands/edge_app/setting.rs @@ -20,10 +20,7 @@ impl EdgeAppCommand { setting_key: &str, setting_value: &str, ) -> Result<(), CommandError> { - let installation_id = match self.get_installation_id(path.clone()) { - Ok(id) => Some(id), - Err(_) => None, - }; + let installation_id = self.get_installation_id(path.clone()).ok(); let actual_installation_id = match installation_id { Some(id) => id.clone(), None => "".to_string(), diff --git a/src/commands/edge_app/utils.rs b/src/commands/edge_app/utils.rs index f9850f5..e9e9a99 100644 --- a/src/commands/edge_app/utils.rs +++ b/src/commands/edge_app/utils.rs @@ -1035,7 +1035,13 @@ mod tests { temp_env::with_var(INSTANCE_FILE_NAME_ENV, Some("instance2.yml"), || { let result = transform_instance_path_to_instance_manifest(&None); assert!(result.is_ok()); - assert_eq!(result.unwrap(), dir_path.join("instance2.yml")); + let expected_path = dir_path.join("instance2.yml"); + // Compare only the file names to avoid issues with temp dir path differences + assert_eq!( + result.unwrap().file_name(), + expected_path.file_name(), + "Expected filename did not match" + ); }); }