diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02e818f18d..64e2c9d0ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,19 +3,27 @@ name: build permissions: contents: read -on: [push, pull_request] +on: + pull_request: + push: + branches: + - master env: RUST_BACKTRACE: 1 CARGO_TERM_COLOR: always CLICOLOR: 1 +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + jobs: build: permissions: contents: none name: CI - needs: [test, lockfile, rustfmt, clippy] + needs: [test, msrv, lockfile, rustfmt, clippy] runs-on: ubuntu-latest if: "always()" steps: @@ -30,28 +38,64 @@ jobs: rust: ["stable"] continue-on-error: ${{ matrix.rust != 'stable' }} runs-on: ${{ matrix.os }} + env: + # Reduce amount of data cached + CARGO_PROFILE_DEV_DEBUG: line-tables-only steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6.0.2 + with: + persist-credentials: false - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: ${{ matrix.rust }} - - uses: Swatinem/rust-cache@v2 + - name: Initialize cache + uses: Swatinem/rust-cache@v2.9.1 + - name: Install cargo-hack + uses: taiki-e/install-action@v2.75.4 + with: + tool: cargo-hack - name: Build - run: cargo test --no-run + run: cargo test --workspace --no-run - name: Test - run: cargo test + run: cargo hack test --each-feature --workspace + msrv: + name: "Check MSRV" + strategy: + matrix: + os: ["ubuntu-latest"] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout repository + uses: actions/checkout@v6.0.2 + with: + persist-credentials: false + - name: Install Rust + uses: dtolnay/rust-toolchain@29eef336d9b2848a0b548edc03f92a220660cdb8 # stable + with: + toolchain: stable + - name: Initialize cache + uses: Swatinem/rust-cache@v2.9.1 + - name: Install cargo-hack + uses: taiki-e/install-action@v2.75.4 + with: + tool: cargo-hack + - name: Default features + run: cargo hack check --each-feature --locked --rust-version --ignore-private --workspace --all-targets --keep-going lockfile: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6.0.2 + with: + persist-credentials: false - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable - - uses: Swatinem/rust-cache@v2 + - name: Initialize cache + uses: Swatinem/rust-cache@v2.9.1 - name: "Is lockfile updated?" run: cargo update --workspace --locked rustfmt: @@ -59,15 +103,18 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6.0.2 + with: + persist-credentials: false - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable components: rustfmt - - uses: Swatinem/rust-cache@v2 + - name: Initialize cache + uses: Swatinem/rust-cache@v2.9.1 - name: Check formatting - run: cargo fmt --all -- --check + run: cargo fmt --check clippy: name: clippy runs-on: ubuntu-latest @@ -75,13 +122,16 @@ jobs: security-events: write # to upload sarif results steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6.0.2 + with: + persist-credentials: false - name: Install Rust uses: dtolnay/rust-toolchain@stable with: toolchain: stable components: clippy - - uses: Swatinem/rust-cache@v2 + - name: Initialize cache + uses: Swatinem/rust-cache@v2.9.1 - name: Install SARIF tools run: cargo install clippy-sarif --locked - name: Install SARIF tools @@ -94,9 +144,9 @@ jobs: | sarif-fmt continue-on-error: true - name: Upload - uses: github/codeql-action/upload-sarif@v3 + uses: github/codeql-action/upload-sarif@v4.35.1 with: sarif_file: clippy-results.sarif wait-for-processing: true - name: Report status - run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated + run: cargo clippy --workspace --all-features --all-targets --keep-going -- -D warnings --allow deprecated diff --git a/Cargo.toml b/Cargo.toml index a94b765d57..c61ff74f5e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ readme = "README.md" repository = "https://github.com/killercup/cargo-edit" version = "0.13.10" edition = "2024" +rust-version = "1.92" [package.metadata.release] pre-release-replacements = [ diff --git a/README.md b/README.md index 275cb3ce87..aad42aa25b 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,6 @@ Ensure that you have a fairly recent version of rust/cargo installed. On Ubuntu $ cargo install cargo-edit ``` -*Compiler support: requires rustc 1.44+* - (Please check [`cargo`'s documentation](http://doc.crates.io/) to learn how `cargo install` works and how to set up your system so it finds binaries installed by `cargo`.) Install a sub-set of the commands with `cargo install -f --no-default-features --features ""`, where `` is a space-separated list of commands; i.e. `add rm upgrade` for the full set. diff --git a/src/errors.rs b/src/errors.rs index cfaa7a39cd..cda69afbe3 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -52,6 +52,7 @@ impl From for CliError { } } +#[cfg(feature = "clap")] impl From for CliError { fn from(err: clap::Error) -> CliError { #[allow(clippy::bool_to_int_with_if)]