Skip to content

Commit

Permalink
Install a fixed version of rust for CI integration tests (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Matan Kushner committed May 1, 2019
1 parent 0b9334f commit d945b03
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 18 deletions.
20 changes: 20 additions & 0 deletions .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
37 changes: 22 additions & 15 deletions azure-pipelines.yml
@@ -1,4 +1,5 @@
jobs:
# Run the Rust linter
- job: "Clippy"
pool:
vmImage: "ubuntu-16.04"
Expand All @@ -9,6 +10,7 @@ jobs:
- script: cargo clippy --all
displayName: Run clippy

# Run the Rust formatter
- job: "Rustfmt"
pool:
vmImage: "ubuntu-16.04"
Expand All @@ -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:
Expand All @@ -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
8 changes: 5 additions & 3 deletions tests/Dockerfile
@@ -1,4 +1,4 @@
FROM rust:latest
FROM rust:1.34.0

# Install Node.js
ENV NODE_VERSION 12.0.0
Expand All @@ -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
Expand All @@ -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"]

0 comments on commit d945b03

Please sign in to comment.