diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b03f069..4faa843 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,10 +18,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: 1.90.0 - components: rustfmt, clippy + run: rustup install - name: Cache cargo registry uses: actions/cache@v4 @@ -30,9 +27,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-cargo- + ${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-cargo- - name: Check formatting run: cargo fmt --all -- --check @@ -99,14 +96,11 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - rust: [1.90.0] steps: - uses: actions/checkout@v4 - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: ${{ matrix.rust }} + run: rustup install - name: Cache cargo registry uses: actions/cache@v4 @@ -115,10 +109,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ runner.os }}-${{ matrix.rust }}-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ runner.os }}-${{ matrix.rust }}-cargo- - ${{ runner.os }}-cargo- + ${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}-cargo- - name: Build run: cargo build --verbose @@ -231,9 +224,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: 1.90.0 + run: rustup install - name: Cache cargo registry uses: actions/cache@v4 @@ -242,7 +233,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: windows-latest-cargo-${{ hashFiles('**/Cargo.lock') }} + key: windows-latest-${{ hashFiles('rust-toolchain.toml') }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Build Ruby Butler run: cargo build --release @@ -305,12 +296,10 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: 1.90.0 + run: rustup install - name: Install cargo-audit - run: cargo install --force cargo-audit + run: cargo install --locked --force cargo-audit - name: Run security audit run: cargo audit @@ -323,10 +312,10 @@ jobs: - uses: actions/checkout@v4 - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: 1.90.0 - components: llvm-tools-preview + run: rustup install + + - name: Install coverage tools + run: rustup component add llvm-tools-preview - name: Cache cargo registry uses: actions/cache@v4 @@ -335,7 +324,7 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: coverage-cargo-${{ hashFiles('**/Cargo.lock') }} + key: coverage-${{ hashFiles('rust-toolchain.toml') }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install cargo-llvm-cov run: cargo install --force cargo-llvm-cov diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e97e566..73bf187 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,10 +81,10 @@ jobs: fetch-depth: 0 # Need full history for git info - name: Install Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: 1.90.0 - targets: ${{ matrix.target }} + run: rustup install + + - name: Install target + run: rustup target add ${{ matrix.target }} - name: Cache cargo registry uses: actions/cache@v4 @@ -93,9 +93,9 @@ jobs: ~/.cargo/registry ~/.cargo/git target - key: ${{ matrix.os }}-1.90.0-cargo-${{ hashFiles('**/Cargo.lock') }} + key: ${{ matrix.os }}-${{ hashFiles('rust-toolchain.toml') }}-cargo-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - ${{ matrix.os }}-1.90.0-cargo- + ${{ matrix.os }}-${{ hashFiles('rust-toolchain.toml') }}-cargo- ${{ matrix.os }}-cargo- - name: Build release binary diff --git a/crates/rb-cli/src/config/mod.rs b/crates/rb-cli/src/config/mod.rs index fab081f..11ec6a1 100644 --- a/crates/rb-cli/src/config/mod.rs +++ b/crates/rb-cli/src/config/mod.rs @@ -86,11 +86,8 @@ impl RbConfig { debug!(" Using rubies-dir from config file: {}", dir.display()); self.rubies_dir = other.rubies_dir; } - } else { - debug!( - " Using rubies-dir from CLI arguments: {}", - self.rubies_dir.as_ref().unwrap().display() - ); + } else if let Some(dir) = &self.rubies_dir { + debug!(" Using rubies-dir from CLI arguments: {}", dir.display()); } if self.ruby_version.is_none() { @@ -98,11 +95,8 @@ impl RbConfig { debug!(" Using ruby-version from config file: {}", version); self.ruby_version = other.ruby_version; } - } else { - debug!( - " Using ruby-version from CLI arguments: {}", - self.ruby_version.as_ref().unwrap() - ); + } else if let Some(version) = &self.ruby_version { + debug!(" Using ruby-version from CLI arguments: {}", version); } if self.gem_home.is_none() { @@ -110,11 +104,8 @@ impl RbConfig { debug!(" Using gem-home from config file: {}", home.display()); self.gem_home = other.gem_home; } - } else { - debug!( - " Using gem-home from CLI arguments: {}", - self.gem_home.as_ref().unwrap().display() - ); + } else if let Some(home) = &self.gem_home { + debug!(" Using gem-home from CLI arguments: {}", home.display()); } if self.no_bundler.is_none() { @@ -122,11 +113,8 @@ impl RbConfig { debug!(" Using no-bundler from config file: {}", no_bundler); self.no_bundler = Some(no_bundler); } - } else { - debug!( - " Using no-bundler from CLI arguments: {}", - self.no_bundler.unwrap() - ); + } else if let Some(no_bundler) = &self.no_bundler { + debug!(" Using no-bundler from CLI arguments: {}", no_bundler); } if self.work_dir.is_none() { @@ -134,11 +122,8 @@ impl RbConfig { debug!(" Using work-dir from config file: {}", dir.display()); self.work_dir = other.work_dir; } - } else { - debug!( - " Using work-dir from CLI arguments: {}", - self.work_dir.as_ref().unwrap().display() - ); + } else if let Some(dir) = &self.work_dir { + debug!(" Using work-dir from CLI arguments: {}", dir.display()); } } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..c3f67b6 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.98.1" +profile = "minimal" +components = ["rustfmt", "clippy"]