From ce04a53a3e0c5a16fb0d99a32587b2b748a92bc3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 15 Jul 2019 16:08:59 -0500 Subject: [PATCH] Set up CI with Azure Pipelines --- .travis.yml | 75 ---------------------------- README.md | 3 +- appveyor.yml | 22 --------- azure-pipelines.yml | 89 ++++++++++++++++++++++++++++++++++ ci/azure-install-rust.yml | 28 +++++++++++ ci/azure-test-all.yml | 25 ++++++++++ tests/testsuite/support/mod.rs | 15 +++++- 7 files changed, 156 insertions(+), 101 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml create mode 100644 azure-pipelines.yml create mode 100644 ci/azure-install-rust.yml create mode 100644 ci/azure-test-all.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 020002e5a268..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,75 +0,0 @@ -language: rust -rust: stable -dist: trusty - -git: - depth: 1 - -matrix: - include: - - name: "rustfmt" - env: TARGET=x86_64-unknown-linux-gnu - rust: stable - addons: - before_script: - - rustup component add rustfmt - script: - - cargo fmt --all -- --check - - cd crates/cargo-test-macro - - cargo fmt --all -- --check - - cd ../crates-io - - cargo fmt --all -- --check - - cd ../resolver-tests - - cargo fmt --all -- --check - - cd ../../ - - - env: TARGET=x86_64-unknown-linux-gnu - ALT=i686-unknown-linux-gnu - if: branch != master OR type = pull_request - - - env: TARGET=x86_64-apple-darwin - ALT=i686-apple-darwin - os: osx - osx_image: xcode9.2 - if: branch != master OR type = pull_request - - - env: TARGET=x86_64-unknown-linux-gnu - ALT=i686-unknown-linux-gnu - rust: beta - if: branch != master OR type = pull_request - - - env: TARGET=x86_64-unknown-linux-gnu - ALT=i686-unknown-linux-gnu - rust: nightly - install: - - travis_retry curl -Lf https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.1/mdbook-v0.3.1-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=$HOME/.cargo/bin - script: - - cargo test --features=deny-warnings || travis_terminate 1 - - cargo doc --no-deps || travis_terminate 1 - - (cd src/doc && mdbook build --dest-dir ../../target/doc) || travis_terminate 1 - if: branch != master OR type = pull_request - - - name: resolver tests - rust: stable - before_script: true - script: - - cargo test --manifest-path crates/resolver-tests/Cargo.toml - if: branch != master OR type = pull_request - - exclude: - - rust: stable - -before_script: - - rustup target add $ALT - - rustup component add clippy || echo "clippy not available" -script: - - cargo test --features=deny-warnings - -notifications: - email: - on_success: never - -addons: - apt: - packages: - - gcc-multilib diff --git a/README.md b/README.md index 9bf4fa779d05..813c44f4e283 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,7 @@ Learn more at https://doc.rust-lang.org/cargo/ ## Code Status -[![Build Status](https://travis-ci.com/rust-lang/cargo.svg?branch=master)](https://travis-ci.com/rust-lang/cargo) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-lang/cargo?branch=master&svg=true)](https://ci.appveyor.com/project/rust-lang-libs/cargo) +[![Build Status](https://dev.azure.com/rust-lang/cargo/_apis/build/status/rust-lang.cargo?branchName=master)](https://dev.azure.com/rust-lang/cargo/_build/latest?definitionId=18&branchName=master) Code documentation: https://docs.rs/cargo/ diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4173501e3a0b..000000000000 --- a/appveyor.yml +++ /dev/null @@ -1,22 +0,0 @@ -environment: - matrix: - - TARGET: x86_64-pc-windows-msvc - OTHER_TARGET: i686-pc-windows-msvc - -install: - - if NOT defined APPVEYOR_PULL_REQUEST_NUMBER if "%APPVEYOR_REPO_BRANCH%" == "master" appveyor exit - - appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe - - rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly - - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - - if defined OTHER_TARGET rustup target add %OTHER_TARGET% - - rustup component add clippy || exit 0 - - rustc -V - - cargo -V - - git submodule update --init - -clone_depth: 1 - -build: false - -test_script: - - cargo test --features=deny-warnings diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000000..ae5621d19f18 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,89 @@ +trigger: + branches: + exclude: + - master +pr: +- master + +jobs: +- job: Linux + pool: + vmImage: ubuntu-16.04 + steps: + - template: ci/azure-test-all.yml + strategy: + matrix: + stable: + TOOLCHAIN: stable + beta: + TOOLCHAIN: beta + nightly: + TOOLCHAIN: nightly + variables: + OTHER_TARGET: i686-unknown-linux-gnu + +- job: macOS + pool: + vmImage: macos-10.13 + steps: + - template: ci/azure-test-all.yml + variables: + TOOLCHAIN: stable + OTHER_TARGET: i686-apple-darwin + +- job: Windows + pool: + vmImage: windows-2019 + steps: + - template: ci/azure-test-all.yml + strategy: + matrix: + x86_64-msvc: + TOOLCHAIN: stable-x86_64-pc-windows-msvc + OTHER_TARGET: i686-pc-windows-msvc +- job: rustfmt + pool: + vmImage: ubuntu-16.04 + steps: + - template: ci/azure-install-rust.yml + - bash: rustup component add rustfmt + displayName: "Install rustfmt" + - bash: cargo fmt --all -- --check + displayName: "Check rustfmt (cargo)" + - bash: cd crates/cargo-test-macro && cargo fmt --all -- --check + displayName: "Check rustfmt (cargo-test-macro)" + - bash: cd crates/crates-io && cargo fmt --all -- --check + displayName: "Check rustfmt (crates-io)" + - bash: cd crates/resolver-tests && cargo fmt --all -- --check + displayName: "Check rustfmt (resolver-tests)" + variables: + TOOLCHAIN: stable + +- job: resolver + pool: + vmImage: ubuntu-16.04 + steps: + - template: ci/azure-install-rust.yml + - bash: cargo test --manifest-path crates/resolver-tests/Cargo.toml + displayName: "Resolver tests" + variables: + TOOLCHAIN: stable + +- job: docs + pool: + vmImage: ubuntu-16.04 + steps: + - template: ci/azure-install-rust.yml + - bash: | + set -e + mkdir mdbook + curl -Lf https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.1/mdbook-v0.3.1-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook + echo "##vso[task.prependpath]`pwd`/mdbook" + displayName: "Install mdbook" + - bash: cargo doc --no-deps + displayName: "Build documentation" + - bash: cd src/doc && mdbook build --dest-dir ../../target/doc + displayName: "Build mdbook documentation" + variables: + TOOLCHAIN: stable + diff --git a/ci/azure-install-rust.yml b/ci/azure-install-rust.yml new file mode 100644 index 000000000000..c48d0d0155ff --- /dev/null +++ b/ci/azure-install-rust.yml @@ -0,0 +1,28 @@ +steps: + - bash: | + set -e + if command -v rustup; then + echo `command -v rustup` `rustup -V` already installed + rustup self update + elif [ "$AGENT_OS" = "Windows_NT" ]; then + curl -sSf -o rustup-init.exe https://win.rustup.rs + rustup-init.exe -y --default-toolchain $TOOLCHAIN + echo "##vso[task.prependpath]$USERPROFILE/.cargo/bin" + else + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN + echo "##vso[task.prependpath]$HOME/.cargo/bin" + fi + displayName: Install rustup + + - bash: | + set -e + rustup update $TOOLCHAIN + rustup default $TOOLCHAIN + displayName: Install rust + + - bash: | + set -ex + rustup -V + rustc -Vv + cargo -V + displayName: Query rust and cargo versions diff --git a/ci/azure-test-all.yml b/ci/azure-test-all.yml new file mode 100644 index 000000000000..7f75f40da4b8 --- /dev/null +++ b/ci/azure-test-all.yml @@ -0,0 +1,25 @@ +steps: +- checkout: self + fetchDepth: 1 + +- template: azure-install-rust.yml + +- bash: rustup target add $OTHER_TARGET + displayName: "Install cross-compile target" + +- bash: sudo apt install gcc-multilib + displayName: "Install gcc-multilib (linux)" + condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) + +# Some tests rely on a clippy command to run, so let's try to install clippy to +# we can be sure to run those tests. +- bash: rustup component add clippy || echo "clippy not available" + displayName: "Install clippy (maybe)" + +# Deny warnings on CI to avoid warnings getting into the codebase, and note the +# `force-system-lib-on-osx` which is intended to fix compile issues on OSX where +# compiling curl from source on OSX yields linker errors on Azure. It's sort of +# unclear how to fix these linker errors and why it worked previously on Travis, +# but if you can remove the `curl` feature please do. +- bash: cargo test --features 'deny-warnings curl/force-system-lib-on-osx' + displayName: "cargo test" diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index a9d9982f6328..355f7190dd91 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -1122,7 +1122,18 @@ impl Execs { None => expected.to_string(), Some(ref p) => match p.get_cwd() { None => expected.to_string(), - Some(cwd) => expected.replace("[CWD]", &cwd.display().to_string()), + Some(cwd) => { + // Round-trip through `Url` and replace with that value. + // Most of the time `cwd` is byte-for-byte the same after + // round-tripping it through `Url`, but on + // Windows it might be the case that `cwd` looks like + // `c:\...` whereas after going through `Url` it looks like + // `C:\...`. To make sure our string assertions match what + // Cargo is doing internally we round-trip through `Url`. + let expected = expected.replace(&cwd.display().to_string(), "[CWD]"); + let cwd_through_url = Url::from_file_path(cwd).unwrap().to_file_path().unwrap(); + expected.replace("[CWD]", &cwd_through_url.display().to_string()) + } }, }; @@ -1740,7 +1751,7 @@ pub fn is_coarse_mtime() -> bool { // This should actually be a test that `$CARGO_TARGET_DIR` is on an HFS // filesystem, (or any filesystem with low-resolution mtimes). However, // that's tricky to detect, so for now just deal with CI. - cfg!(target_os = "macos") && env::var("CI").is_ok() + cfg!(target_os = "macos") && env::var("TF_BUILD").is_ok() } /// Some CI setups are much slower then the equipment used by Cargo itself.