Skip to content

Commit

Permalink
chore(ci): add azure pipelines configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
darfink committed Jun 12, 2019
1 parent b8170ff commit 53997fa
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
22 changes: 22 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
trigger:
- master

stages:
- stage: test
displayName: Test
jobs:
- template: ci/cargo-job-per-channel-target.yml
parameters:
channels: [nightly]
targets:
# Targets are specified as arrays (due to missing 'split' function in
# azure) so 'join' can be used for defining alpha numeric job names,
# whilst also being used for specifying the rust target triple.
- target: [i686, pc, windows, gnu]
- target: [i686, pc, windows, msvc]
- target: [x86_64, pc, windows, msvc]
- target: [x86_64, pc, windows, gnu]
- target: [i686, apple, darwin]
- target: [x86_64, apple, darwin]
- target: [i686, unknown, linux, gnu]
- target: [x86_64, unknown, linux, gnu]
25 changes: 25 additions & 0 deletions ci/cargo-job-per-channel-target.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This template creates one job per channel-target.
parameters:
# The default rust channels to use ('stable', 'beta' and/or 'nightly').
# This can also be overriden for each target.
channels: [stable]
# The target triples to use (e.g 'i686-apple-darwin')
targets: []

jobs:
- ${{ each target in parameters.targets }}:
- ${{ if target.channels }}:
- ${{ each channel in target.channels }}:
- template: cargo-job.yml
parameters:
identifier: ${{ format('rust_{0}_{1}', channel, join('_', target.target)) }}
channel: ${{ channel }}
${{ insert }}: ${{ target }}

- ${{ if not(target.channels) }}:
- ${{ each channel in parameters.channels }}:
- template: cargo-job.yml
parameters:
identifier: ${{ format('rust_{0}_{1}', channel, join('_', target.target)) }}
channel: ${{ channel }}
${{ insert }}: ${{ target }}
77 changes: 77 additions & 0 deletions ci/cargo-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This template runs a job for arbitrary cargo/cross operations.
parameters:
# The identifier for the job
identifier:
# The display name for the job
displayName:
# The host target triple (e.g 'i686-apple-darwin') (required)
target:
# The rust channel ('stable', 'beta' or 'nightly')
channel: stable
# Whether cross should be used or not
cross: false
# Steps before any cargo operations
preSteps: []
# Steps after all cargo operations
postSteps: []
# List of cargo steps ($CARGO and $TARGET is injected via 'env')
cargoSteps:
- bash: $CARGO test --target $TARGET --all
displayName: Cargo test

jobs:
- job: ${{ coalesce(parameters.identifier, format('rust_{0}_{1}', parameters.channel, join('_', parameters.target))) }}
displayName: ${{ coalesce(parameters.displayName, format('{0}-{1}', parameters.channel, join('-', parameters.target))) }}
variables:
${{ if eq(parameters.cross, 'true') }}:
toolchain: ${{ parameters.channel }}
cargo: cross
${{ if not(eq(parameters.cross, 'true')) }}:
toolchain: ${{ format('{0}-{1}', parameters.channel, join('-', parameters.target)) }}
cargo: cargo
pool:
${{ if containsValue(parameters.target, 'windows') }}:
vmImage: 'vs2017-win2016'
${{ if containsValue(parameters.target, 'apple') }}:
vmImage: 'macos-10.13'
${{ if containsValue(parameters.target, 'linux') }}:
vmImage: 'ubuntu-16.04'
steps:
- ${{ if containsValue(parameters.target, 'windows') }}:
- script: |
curl -sSf -o rustup-init.exe https://win.rustup.rs
rustup-init.exe -y --default-toolchain=none
rustup default $(toolchain)
echo "##vso[task.setvariable variable=PATH;]%PATH%;%USERPROFILE%\.cargo\bin"
displayName: Install rust
- ${{ if not(containsValue(parameters.target, 'windows')) }}:
- script: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=none
PATH="$PATH:$HOME/.cargo/bin" rustup default $(toolchain)
echo "##vso[task.setvariable variable=PATH;]$PATH:$HOME/.cargo/bin"
displayName: Install rust
- ${{ if eq(parameters.cross, 'true') }}:
- script: |
git config --global user.email "foo@bar"
git config --global user.name "Placeholder"
git clone https://github.com/rust-embedded/cross
cd cross
git remote add pitkley https://github.com/pitkley/cross
git fetch pitkley
git checkout 718a19c
git merge -m "No pseudo tty" pitkley/docker-no-pseudo-tty
cargo install --force --path .
displayName: Install cross
- ${{ parameters.preSteps }}
- script: |
rustup -V
rustc -Vv
cargo -V
displayName: Cargo environment
- ${{ each step in parameters.cargoSteps }}:
- ${{ each pair in step }}:
${{ pair.key }}: ${{ pair.value }}
env:
TARGET: ${{ join('-', parameters.target) }}
CARGO: $(cargo)
- ${{ parameters.postSteps }}

0 comments on commit 53997fa

Please sign in to comment.