From 4e494ea71b799325d7c62f2e34966fffe37e921c Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Wed, 13 Nov 2019 00:42:14 +0100 Subject: [PATCH 01/14] add matrix CI using Github Actions --- .github/workflows/build.yml | 26 ++++++++++++++++++++++++++ README.md | 1 + bors.toml | 8 +++++++- 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..10106a08c1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,26 @@ +name: build + +on: [push] + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + rust: [stable, nightly] + + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: ${{ matrix.rust }} + components: rustfmt, clippy + - uses: actions/checkout@master + - name: Check Formatting + run: cargo fmt --all -- --write-mode=diff + - name: Lint + run: cargo clippy -- -D warnings -A deprecated + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose diff --git a/README.md b/README.md index 9f611e493c..a0a0f1f754 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Currently available subcommands: - [`cargo rm`](#cargo-rm) - [`cargo upgrade`](#cargo-upgrade) +[![Build Status](https://github.com/killercup/cargo-edit/workflows/build/badge.svg)](https://github.com/killercup/cargo-edit/actions) [![Build Status](https://travis-ci.org/killercup/cargo-edit.svg?branch=master)](https://travis-ci.org/killercup/cargo-edit) [![Build status](https://ci.appveyor.com/api/projects/status/m23rnkaxhipb23i9/branch/master?svg=true)](https://ci.appveyor.com/project/killercup/cargo-edit/branch/master) [![Coverage Status](https://coveralls.io/repos/killercup/cargo-edit/badge.svg?branch=master&service=github)](https://coveralls.io/github/killercup/cargo-edit?branch=master) diff --git a/bors.toml b/bors.toml index db020e08ae..37640bafa9 100644 --- a/bors.toml +++ b/bors.toml @@ -1,4 +1,10 @@ status = [ + "build (ubuntu-latest, stable)", + "build (ubuntu-latest, nightly)", + "build (windows-latest, stable)", + "build (windows-latest, nightly)", + "build (macOS-latest, stable)", + "build (macOS-latest, nightly)", "continuous-integration/travis-ci/push", - "continuous-integration/appveyor/branch", + "continuous-integration/appveyor/branch", ] From 5475b9728adcfd12dd7ce913e5d5e8060d823f37 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Wed, 13 Nov 2019 00:47:18 +0100 Subject: [PATCH 02/14] fix formatting issue --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 10106a08c1..070311904f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - name: Check Formatting run: cargo fmt --all -- --write-mode=diff - name: Lint - run: cargo clippy -- -D warnings -A deprecated + run: cargo clippy -- -D warnings -A deprecated - name: Build run: cargo build --verbose - name: Run tests From f2f353522b376e3f897d7e354b5473c0b1c39b3c Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Wed, 13 Nov 2019 00:55:05 +0100 Subject: [PATCH 03/14] use cargo fmt check option --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 070311904f..f2c9ab743d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: components: rustfmt, clippy - uses: actions/checkout@master - name: Check Formatting - run: cargo fmt --all -- --write-mode=diff + run: cargo fmt --all -- --check - name: Lint run: cargo clippy -- -D warnings -A deprecated - name: Build From 1ccc560fc97b6eb51a56904bde38641953293dca Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Wed, 13 Nov 2019 01:00:22 +0100 Subject: [PATCH 04/14] cargo fmt fixes --- src/bin/add/args.rs | 3 ++- tests/cargo-add.rs | 5 ++++- tests/cargo-upgrade.rs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bin/add/args.rs b/src/bin/add/args.rs index b833c281e9..fc58fad692 100644 --- a/src/bin/add/args.rs +++ b/src/bin/add/args.rs @@ -226,7 +226,8 @@ impl Args { .iter() .map(|crate_name| { self.parse_single_dependency(crate_name).map(|x| { - let mut x = x.set_optional(self.optional) + let mut x = x + .set_optional(self.optional) .set_default_features(!self.no_default_features); if let Some(ref rename) = self.rename { x = x.set_rename(rename); diff --git a/tests/cargo-add.rs b/tests/cargo-add.rs index 32e492abaf..c8318ef7c2 100644 --- a/tests/cargo-add.rs +++ b/tests/cargo-add.rs @@ -131,7 +131,10 @@ fn adds_renamed_dependency() { // dependency present afterwards let toml = get_toml(&manifest); let renamed = &toml["dependencies"]["renamed"]; - assert_eq!(renamed["version"].as_str().unwrap(), "my-package1--CURRENT_VERSION_TEST"); + assert_eq!( + renamed["version"].as_str().unwrap(), + "my-package1--CURRENT_VERSION_TEST" + ); assert_eq!(renamed["package"].as_str().unwrap(), "my-package1"); } diff --git a/tests/cargo-upgrade.rs b/tests/cargo-upgrade.rs index d9e25598d6..935e07b213 100644 --- a/tests/cargo-upgrade.rs +++ b/tests/cargo-upgrade.rs @@ -464,7 +464,7 @@ fn upgrade_to_lockfile() { Path::new("tests/fixtures/upgrade/Cargo.lock"), tmpdir.path().join("Cargo.lock"), ) - .unwrap_or_else(|err| panic!("could not copy test lock file: {}", err));; + .unwrap_or_else(|err| panic!("could not copy test lock file: {}", err)); execute_command(&["upgrade", "--to-lockfile"], &manifest); let upgraded = get_toml(&manifest); From cfe326a7e38aed689fa296260d3ea5a857e48a73 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Wed, 13 Nov 2019 01:01:04 +0100 Subject: [PATCH 05/14] cargo clippy fixes --- src/bin/upgrade/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/upgrade/main.rs b/src/bin/upgrade/main.rs index 075c7d111a..8b46c843f3 100644 --- a/src/bin/upgrade/main.rs +++ b/src/bin/upgrade/main.rs @@ -202,7 +202,7 @@ impl Manifests { .flat_map(|&(_, ref package)| package.dependencies.clone()) .filter(is_version_dep) .filter_map(|dependency| { - let is_prerelease = dependency.req.to_string().contains("-"); + let is_prerelease = dependency.req.to_string().contains('-'); if selected_dependencies.is_empty() { // User hasn't asked for any specific dependencies to be upgraded, // so upgrade all the dependencies. From b5777c1ece6f5248afcc6ad9897712b8c24ad217 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Fri, 22 Nov 2019 00:42:16 +0100 Subject: [PATCH 06/14] fix nightly build --- tests/cargo-add.rs | 4 ++-- tests/fixtures/upgrade/Cargo.toml.source | 2 +- tests/fixtures/upgrade/Cargo.toml.target | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cargo-add.rs b/tests/cargo-add.rs index c8318ef7c2..fbdbf4e209 100644 --- a/tests/cargo-add.rs +++ b/tests/cargo-add.rs @@ -894,14 +894,14 @@ fn adds_dependency_with_custom_target() { let (_tmpdir, manifest) = clone_out_test("tests/fixtures/add/Cargo.toml.sample"); execute_command( - &["add", "--target", "x86_64/windows.json", "my-package1"], + &["add", "--target", "windows.json", "my-package1"], &manifest, ); // dependencies present afterwards let toml = get_toml(&manifest); // Get package by hand because toml-rs does not currently handle escaping dots in get() - let val = &toml["target"]["x86_64/windows.json"]["dependencies"]["my-package1"]; + let val = &toml["target"]["windows.json"]["dependencies"]["my-package1"]; assert_eq!(val.as_str(), Some("my-package1--CURRENT_VERSION_TEST")); } diff --git a/tests/fixtures/upgrade/Cargo.toml.source b/tests/fixtures/upgrade/Cargo.toml.source index 2a5e53468f..019788d4ba 100644 --- a/tests/fixtures/upgrade/Cargo.toml.source +++ b/tests/fixtures/upgrade/Cargo.toml.source @@ -32,7 +32,7 @@ serde = { version = "1.0", git= "https://github.com/serde-rs/serde.git" } [target.'cfg(unix)'.dependencies] openssl = "0.9" -[target."x86_64/windows.json"] +[target."windows.json"] # let's make it an inline table dependencies = { rget = "0.3.0" } diff --git a/tests/fixtures/upgrade/Cargo.toml.target b/tests/fixtures/upgrade/Cargo.toml.target index 0d6c4eba34..97452906aa 100644 --- a/tests/fixtures/upgrade/Cargo.toml.target +++ b/tests/fixtures/upgrade/Cargo.toml.target @@ -32,7 +32,7 @@ serde = { version = "1.0", git= "https://github.com/serde-rs/serde.git" } [target.'cfg(unix)'.dependencies] openssl = "openssl--CURRENT_VERSION_TEST" -[target."x86_64/windows.json"] +[target."windows.json"] # let's make it an inline table dependencies = { rget = "rget--CURRENT_VERSION_TEST" } From 09a6cb69dc6a88b7e2918620b17f6ce78ddb1508 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Fri, 22 Nov 2019 00:58:27 +0100 Subject: [PATCH 07/14] fix clippy warnings --- src/manifest.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/manifest.rs b/src/manifest.rs index 40b9ac73d2..54211c9fc4 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -214,7 +214,7 @@ impl Manifest { vec![ "target".to_string(), target_name.to_string(), - dependency_type.to_string(), + (*dependency_type).to_string(), ], dependency_table.clone(), ) @@ -321,7 +321,6 @@ impl Manifest { /// # Examples /// /// ``` - /// # fn main() { /// use cargo_edit::{Dependency, Manifest}; /// use toml_edit; /// @@ -331,7 +330,6 @@ impl Manifest { /// assert!(manifest.remove_from_table("dependencies", &dep.name).is_ok()); /// assert!(manifest.remove_from_table("dependencies", &dep.name).is_err()); /// assert!(manifest.data["dependencies"].is_none()); - /// # } /// ``` pub fn remove_from_table(&mut self, table: &str, name: &str) -> Result<()> { if !self.data[table].is_table_like() { From 6c0eca11af4b44f71e1b8b619b792ca3a8a6688e Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Fri, 22 Nov 2019 01:02:53 +0100 Subject: [PATCH 08/14] fix clippy warnings --- src/manifest.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manifest.rs b/src/manifest.rs index 54211c9fc4..1f45b1c543 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -194,7 +194,7 @@ impl Manifest { // Dependencies can be in the three standard sections... if self.data[dependency_type].is_table_like() { sections.push(( - vec![dependency_type.to_string()], + vec![(*dependency_type).to_string()], self.data[dependency_type].clone(), )) } From d22be747bd68a6b6f38ae0fd16d6691a7b5e0b1a Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sat, 30 Nov 2019 23:20:40 +0100 Subject: [PATCH 09/14] Let's not wait for appveyor Gothub Action tests on Windows anyway. --- bors.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/bors.toml b/bors.toml index b921b257e7..ae6d3b23a7 100644 --- a/bors.toml +++ b/bors.toml @@ -6,6 +6,5 @@ status = [ "build (macOS-latest, stable)", "build (macOS-latest, nightly)", "continuous-integration/travis-ci/push", - "continuous-integration/appveyor/branch", ] use_squash_merge = true From d8bb36a4a11f7626bda6b5ba83fc148f1e874204 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Thu, 5 Dec 2019 23:47:35 +0100 Subject: [PATCH 10/14] Run rustfmt separately --- .github/workflows/build.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2c9ab743d..5b35619d0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,11 +16,22 @@ jobs: rust-version: ${{ matrix.rust }} components: rustfmt, clippy - uses: actions/checkout@master - - name: Check Formatting - run: cargo fmt --all -- --check - name: Lint run: cargo clippy -- -D warnings -A deprecated - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose + +fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: stable + components: rustfmt + - name: Checkout sources + uses: actions/checkout@v1 + - name: Check Formatting + run: cargo fmt --all -- --check From df5f6a8d1864746e367d21588b96d07854ac469a Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Thu, 5 Dec 2019 23:48:43 +0100 Subject: [PATCH 11/14] fix incorrect formatting --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b35619d0d..5acd020f89 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: - name: Run tests run: cargo test --verbose -fmt: + fmt: name: Rustfmt runs-on: ubuntu-latest steps: From b21bfa1e06d243778ad1e4c315ac7e3a34357dd0 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Fri, 6 Dec 2019 00:07:06 +0100 Subject: [PATCH 12/14] Separate check & clippy as well --- .github/workflows/build.yml | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5acd020f89..5f5790ff86 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,15 +16,38 @@ jobs: rust-version: ${{ matrix.rust }} components: rustfmt, clippy - uses: actions/checkout@master - - name: Lint - run: cargo clippy -- -D warnings -A deprecated - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose + check: + name: check (ubuntu-latest, stable) + runs-on: ubuntu-latest + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: stable + - name: Checkout sources + uses: actions/checkout@v1 + - name: Cargo Check + run: cargo check + + clippy: + name: clippy (ubuntu-latest, stable) + runs-on: ubuntu-latest + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: stable + components: clippy + - name: Checkout sources + uses: actions/checkout@v1 + - name: Cargo Clippy + run: cargo clippy -- -D warnings -A deprecated + fmt: - name: Rustfmt + name: fmt (ubuntu-latest, stable) runs-on: ubuntu-latest steps: - uses: hecrj/setup-rust-action@v1 From 32b7e34cbb2544a42faf7ef94e1e5fd27cfb45ad Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Fri, 6 Dec 2019 00:16:42 +0100 Subject: [PATCH 13/14] Remove unnecessary components for build & test tasks --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f5790ff86..d9a7f35f6a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,12 +9,10 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] rust: [stable, nightly] - steps: - uses: hecrj/setup-rust-action@v1 with: rust-version: ${{ matrix.rust }} - components: rustfmt, clippy - uses: actions/checkout@master - name: Build run: cargo build --verbose From 8b087fb8c1d0b9824f3095044402cfcc44db8fd2 Mon Sep 17 00:00:00 2001 From: Steve Degosserie Date: Fri, 6 Dec 2019 00:47:07 +0100 Subject: [PATCH 14/14] Cache cargo registry & index during build; only build nightly on ubuntu, and continue on error --- .github/workflows/build.yml | 55 ++++++++++++++++++++++++++++++++++++- bors.toml | 2 -- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9a7f35f6a..9e7e13156f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,16 +8,54 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [stable, nightly] + rust: [stable] steps: - uses: hecrj/setup-rust-action@v1 with: rust-version: ${{ matrix.rust }} - uses: actions/checkout@master + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} - name: Build run: cargo build --verbose - name: Run tests run: cargo test --verbose + + build-nightly: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + rust: [nightly] + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: ${{ matrix.rust }} + - uses: actions/checkout@master + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} + - name: Build + run: cargo build --verbose + continue-on-error: true + - name: Run tests + run: cargo test --verbose + continue-on-error: true check: name: check (ubuntu-latest, stable) @@ -41,6 +79,21 @@ jobs: components: clippy - name: Checkout sources uses: actions/checkout@v1 + - name: Cache cargo registry + uses: actions/cache@v1 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }} + - name: Cache cargo index + uses: actions/cache@v1 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('Cargo.lock') }} + - name: Cache cargo build + uses: actions/cache@v1 + with: + path: target + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('Cargo.lock') }} - name: Cargo Clippy run: cargo clippy -- -D warnings -A deprecated diff --git a/bors.toml b/bors.toml index ae6d3b23a7..a19d6e4c39 100644 --- a/bors.toml +++ b/bors.toml @@ -2,9 +2,7 @@ status = [ "build (ubuntu-latest, stable)", "build (ubuntu-latest, nightly)", "build (windows-latest, stable)", - "build (windows-latest, nightly)", "build (macOS-latest, stable)", - "build (macOS-latest, nightly)", "continuous-integration/travis-ci/push", ] use_squash_merge = true