diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..e62c4bb8 --- /dev/null +++ b/azure-pipelines.yml @@ -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] \ No newline at end of file diff --git a/ci/cargo-job-per-channel-target.yml b/ci/cargo-job-per-channel-target.yml new file mode 100644 index 00000000..511349b2 --- /dev/null +++ b/ci/cargo-job-per-channel-target.yml @@ -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 }} \ No newline at end of file diff --git a/ci/cargo-job.yml b/ci/cargo-job.yml new file mode 100644 index 00000000..33f0ad2b --- /dev/null +++ b/ci/cargo-job.yml @@ -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 }} \ No newline at end of file