diff --git a/.build/install-rust.yml b/.build/install-rust.yml new file mode 100644 index 00000000..57c503c8 --- /dev/null +++ b/.build/install-rust.yml @@ -0,0 +1,20 @@ +parameters: + versionSpec: "" + +steps: + # Install Rust at a fixed version for integration tests to pass + - script: | + curl -sSf -o rustup-init.exe https://win.rustup.rs + rustup-init.exe -y --default-toolchain ${{ parameters.versionSpec }} + echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" + displayName: Windows install Rust + condition: eq( variables['Agent.OS'], 'Windows_NT' ) + - script: | + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain ${{ parameters.versionSpec }} + echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" + displayName: Install a fixed version of Rust + condition: ne( variables['Agent.OS'], 'Windows_NT' ) + + # Install the version of Rust used for testing with + - script: rustup install $RUSTUP_TOOLCHAIN + displayName: Install Rust used for CI diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1f1dd639..e3af9504 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,4 +1,5 @@ jobs: + # Run the Rust linter - job: "Clippy" pool: vmImage: "ubuntu-16.04" @@ -9,6 +10,7 @@ jobs: - script: cargo clippy --all displayName: Run clippy + # Run the Rust formatter - job: "Rustfmt" pool: vmImage: "ubuntu-16.04" @@ -20,6 +22,15 @@ jobs: - script: cargo fmt --all -- --check displayName: Run Rustfmt + # Run the integration tests in a Docker container + - job: "Docker" + pool: + vmImage: "ubuntu-16.04" + steps: + - script: ./integration_test + displayName: Dockerized tests + + # Run the integration tests on virtual machines - job: "Test" strategy: matrix: @@ -41,21 +52,17 @@ jobs: pool: vmImage: "ubuntu-16.04" steps: - - task: NodeTool@0 + # Install Node.js + - task: NodeTool@0 inputs: - versionSpec: '12.0.0' - - script: | - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $RUSTUP_TOOLCHAIN - echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin" - displayName: Install rust - condition: ne( variables['Agent.OS'], 'Windows_NT' ) - - script: | - curl -sSf -o rustup-init.exe https://win.rustup.rs - rustup-init.exe -y --default-toolchain %RUSTUP_TOOLCHAIN% - echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin" - displayName: Windows install rust - condition: eq( variables['Agent.OS'], 'Windows_NT' ) - - script: cargo build --all + versionSpec: "12.0.0" + # Install Rust at a fixed version for integration tests + - template: ".build/install-rust.yml" + parameters: + versionSpec: "1.34.0" + + # Because integration tests rely on a fixed Rust version, we must use rustup to run with the intended toolkit + - script: rustup run $RUSTUP_TOOLCHAIN cargo build --all displayName: Cargo build - - script: cargo test -- --ignored + - script: rustup run $RUSTUP_TOOLCHAIN cargo test -- --ignored displayName: Cargo test diff --git a/tests/Dockerfile b/tests/Dockerfile index 992e31ea..bd1bcaa4 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,4 +1,4 @@ -FROM rust:latest +FROM rust:1.34.0 # Install Node.js ENV NODE_VERSION 12.0.0 @@ -24,7 +24,8 @@ RUN mkdir benches RUN touch benches/my_benchmark.rs # This is a dummy build to get dependencies cached -RUN cargo build --release +RUN rustup install stable +RUN rustup run stable cargo build --release # Delete the dummy build RUN rm -rf /starship @@ -33,4 +34,5 @@ RUN rm -rf /starship RUN mkdir starship WORKDIR /starship -CMD [ "cargo", "test", "--", "--ignored"] +# Run with rustup to use stable instead of the Rust default +CMD [ "rustup", "run", "stable", "cargo", "test", "--", "--ignored"]