From 678f15bd48151f82233fdecb4a4e7c538932d09a Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Fri, 22 Mar 2019 11:58:00 -0700 Subject: [PATCH] ci: skip crates.io dep run when releasing (#995) #993 introduces changes in a sub crate that other Tokio crates depend on. To make CI pass, a `[patch]` statement and `path` dependencies are used. When releasing, these must be removed. However, the commit that removes them and prepares the crates for release will not be able to pass CI. This commit adds a conditional on a special `[ci-release]` snippet in the commit message. If this exists, CI is only run with the full "patched" dependencies. --- .cirrus.yml | 15 ++++++++++++++- ci/azure-cargo-check.yml | 11 +++++++++++ ci/azure-check-minrust.yml | 2 ++ ci/azure-cross-compile.yml | 3 +++ ci/azure-is-release.yml | 9 +++++++++ ci/azure-test-stable.yml | 3 +++ 6 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 ci/azure-is-release.yml diff --git a/.cirrus.yml b/.cirrus.yml index 4172a50d9..d66d5f365 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -15,6 +15,18 @@ task: - sh rustup.sh -y - . $HOME/.cargo/env - rustup target add i686-unknown-freebsd + - | + # Remove any existing patch statements + mv Cargo.toml Cargo.toml.bck + sed -n '/\[patch.crates-io\]/q;p' Cargo.toml.bck > Cargo.toml + + # Patch all crates + cat ci/patch.toml >> Cargo.toml + + # Print `Cargo.toml` for debugging + echo "~~~~ Cargo.toml ~~~~" + cat Cargo.toml + echo "~~~~~~~~~~~~~~~~~~~~" cargo_cache: folder: $HOME/.cargo/registry test_script: @@ -23,6 +35,7 @@ task: - cargo doc --all i686_test_script: - . $HOME/.cargo/env - - cargo test --all --exclude tokio-tls --no-fail-fast --target i686-unknown-freebsd + - | + cargo test --all --exclude tokio-tls --no-fail-fast --target i686-unknown-freebsd before_cache_script: - rm -rf $HOME/.cargo/registry/index diff --git a/ci/azure-cargo-check.yml b/ci/azure-cargo-check.yml index d386bd6c3..b8a3b9e3d 100644 --- a/ci/azure-cargo-check.yml +++ b/ci/azure-cargo-check.yml @@ -11,6 +11,17 @@ jobs: parameters: rust_version: ${{ parameters.rust }} + - template: azure-is-release.yml + + - ${{ each crate in parameters.crates }}: + - ${{ each feature in crate.value }}: + - script: cargo check ${{ parameters.noDefaultFeatures }} --features ${{ feature }} + displayName: Check `${{ crate.key }}`, features = ${{ feature }} + workingDirectory: $(Build.SourcesDirectory)/${{ crate.key }} + condition: and(succeeded(), not(variables['isRelease'])) + + - template: azure-patch-crates.yml + - ${{ each crate in parameters.crates }}: - ${{ each feature in crate.value }}: - script: cargo check ${{ parameters.noDefaultFeatures }} --features ${{ feature }} diff --git a/ci/azure-check-minrust.yml b/ci/azure-check-minrust.yml index de6313c24..7a5e602af 100644 --- a/ci/azure-check-minrust.yml +++ b/ci/azure-check-minrust.yml @@ -8,5 +8,7 @@ jobs: parameters: rust_version: ${{ parameters.rust_version }} + - template: azure-patch-crates.yml + - script: cargo check --all displayName: cargo check --all diff --git a/ci/azure-cross-compile.yml b/ci/azure-cross-compile.yml index 79606bb41..857aeb944 100644 --- a/ci/azure-cross-compile.yml +++ b/ci/azure-cross-compile.yml @@ -14,6 +14,9 @@ jobs: - script: rustup target add ${{ parameters.target }} displayName: "Add target" + # Always patch + - template: azure-patch-crates.yml + - script: cargo check --all --exclude tokio-tls --target ${{ parameters.target }} displayName: Check source diff --git a/ci/azure-is-release.yml b/ci/azure-is-release.yml new file mode 100644 index 000000000..014b7a98a --- /dev/null +++ b/ci/azure-is-release.yml @@ -0,0 +1,9 @@ +steps: + - bash: | + set -e + + if git log --no-merges -1 --format='%s' | grep -q '[ci-release]'; then + echo "##vso[task.setvariable variable=isRelease]true" + fi + failOnStderr: true + displayName: Check if release commit diff --git a/ci/azure-test-stable.yml b/ci/azure-test-stable.yml index c385be26c..cd4f8cf9d 100644 --- a/ci/azure-test-stable.yml +++ b/ci/azure-test-stable.yml @@ -19,6 +19,8 @@ jobs: parameters: rust_version: stable + - template: azure-is-release.yml + - ${{ each crate in parameters.crates }}: - script: cargo test env: @@ -26,6 +28,7 @@ jobs: CI: 'True' displayName: cargo test -p ${{ crate }} workingDirectory: $(Build.SourcesDirectory)/${{ crate }} + condition: and(succeeded(), not(variables['isRelease'])) - template: azure-patch-crates.yml