Install a fixed version of rust for CI integration tests (#39)

This commit is contained in:
Matan Kushner 2019-05-01 11:12:02 -04:00 committed by GitHub
parent 0b9334f438
commit d945b03093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 18 deletions

20
.build/install-rust.yml Normal file
View File

@ -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

View File

@ -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

View File

@ -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"]