Skip to content
This repository was archived by the owner on Jun 26, 2020. It is now read-only.

Commit fc88520

Browse files
Add Azure Pipelines CI setup (#948)
Add Azure Pipelines CI setup
1 parent 2f146c6 commit fc88520

3 files changed

Lines changed: 255 additions & 0 deletions

File tree

.azure-pipelines.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
name: $(Build.SourceBranch)-$(date:yyyy-MM-dd)$(rev:.r)
2+
trigger:
3+
branches:
4+
include:
5+
- 'master'
6+
tags:
7+
include:
8+
- '*'
9+
exclude:
10+
- 'dev'
11+
12+
jobs:
13+
- job: rustfmt
14+
pool:
15+
vmImage: 'macos-10.14'
16+
steps:
17+
- checkout: self
18+
submodules: true
19+
- template: ci/azure-install-rust.yml
20+
- script: rustup component add rustfmt
21+
displayName: Add rustfmt
22+
- script: cargo fmt --all -- --check
23+
displayName: Check formatting
24+
variables:
25+
toolchain: stable
26+
27+
# Smoke test to build docs on one builder, using OSX for now since it's the
28+
# fastest
29+
- job: docs
30+
pool:
31+
vmImage: 'macos-10.14'
32+
steps:
33+
- checkout: self
34+
submodules: true
35+
- template: ci/azure-install-rust.yml
36+
- script: cargo doc
37+
displayName: Build documentation
38+
- script: cargo install cargo-deadlinks
39+
displayName: Install cargo-deadlinks
40+
- bash: |
41+
find ./target/doc -maxdepth 1 -type d -name "cranelift*" | xargs -I{} cargo deadlinks --dir {}
42+
displayName: Run cargo-deadlinks
43+
variables:
44+
toolchain: nightly
45+
46+
- job: Test
47+
strategy:
48+
matrix:
49+
windows-earliest:
50+
imageName: 'vs2017-win2016'
51+
toolchain: '1.37.0'
52+
linux-earliest:
53+
imageName: 'ubuntu-16.04'
54+
toolchain: '1.37.0'
55+
mac-earliest:
56+
imageName: 'macos-10.14'
57+
toolchain: '1.37.0'
58+
mac-stable:
59+
imageName: 'macos-10.14'
60+
toolchain: stable
61+
mac-beta:
62+
imageName: 'macos-10.14'
63+
toolchain: beta
64+
mac-nightly:
65+
imageName: 'macos-10.14'
66+
toolchain: nightly
67+
68+
pool:
69+
vmImage: $(imageName)
70+
71+
steps:
72+
- checkout: self
73+
submodules: true
74+
- template: ci/azure-install-rust.yml
75+
76+
- script: cargo fetch
77+
displayName: Fetch cargo dependencies
78+
79+
- script: cargo build
80+
displayName: Cargo build
81+
82+
- bash: cargo test --all
83+
displayName: Cargo test
84+
env:
85+
RUST_BACKTRACE: 1
86+
87+
# Ensure fuzzer works by running it with a single input
88+
- bash: cargo install cargo-fuzz
89+
displayName: Install cargo-fuzz
90+
condition: and(succeeded(), eq(variables['toolchain'], 'nightly'))
91+
- bash: |
92+
fuzz_module="ffaefab69523eb11935a9b420d58826c8ea65c4c"
93+
cargo fuzz run fuzz_translate_module \
94+
"fuzz/corpus/fuzz_translate_module/$fuzz_module"
95+
displayName: Run cargo-fuzz
96+
env:
97+
RUST_BACKTRACE: 1
98+
condition: and(succeeded(), eq(variables['toolchain'], 'nightly'))
99+
100+
- job: Build
101+
strategy:
102+
matrix:
103+
windows:
104+
imageName: 'vs2017-win2016'
105+
# Statically link against msvcrt to produce slightly more portable
106+
# binaries on Windows by reducing our binary compatibility requirements.
107+
RUSTFLAGS: -Ctarget-feature=+crt-static
108+
mac:
109+
imageName: 'macos-10.14'
110+
# Lower the deployment target from our build image in an attempt to
111+
# build more portable binaries that run on older releases. Note that
112+
# 10.9 here is arbitrarily chosen and just happens to be the lowest that
113+
# works at this time. Raising this is probably fine.
114+
MACOSX_DEPLOYMENT_TARGET: 10.9
115+
variables:
116+
toolchain: '1.37.0'
117+
pool:
118+
vmImage: $(imageName)
119+
# We try to be compatible with beta and nightly, but they occasionally
120+
# fail, so we don't allow them to hold up people using stable.
121+
continueOnError: $[ne(variables['toolchain'], 'stable')]
122+
steps:
123+
- template: ci/azure-build-release.yml
124+
125+
# Build the Linux release binary in an older Linux container (in this case
126+
# Centos 6)
127+
- job: Build_linux
128+
variables:
129+
toolchain: '1.37.0'
130+
container:
131+
image: centos:6
132+
options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
133+
steps:
134+
# We're executing in the container as non-root but `yum` requires root. We
135+
# need to install `sudo` but to do that we need `sudo`. Do a bit of a weird
136+
# hack where we use the host `docker` executable to re-execute in our own
137+
# container with the root user to install `sudo`
138+
- bash: /tmp/docker exec -t -u 0 ci-container sh -c "yum install -y sudo"
139+
displayName: Configure sudo
140+
141+
# See https://edwards.sdsu.edu/research/c11-on-centos-6/ for where these
142+
# various commands came from.
143+
- bash: |
144+
set -e
145+
sudo yum install -y centos-release-scl cmake xz
146+
sudo yum install -y devtoolset-8-gcc devtoolset-8-binutils devtoolset-8-gcc-c++
147+
echo "##vso[task.prependpath]/opt/rh/devtoolset-8/root/usr/bin"
148+
displayName: Install system dependencies
149+
150+
# Delete `libstdc++.so` to force gcc to link against `libstdc++.a` instead.
151+
# This is a hack and not the right way to do this, but it ends up doing the
152+
# right thing for now.
153+
- bash: sudo rm -f /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so
154+
displayName: Force a static libstdc++
155+
156+
- template: ci/azure-build-release.yml

ci/azure-build-release.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
steps:
2+
- checkout: self
3+
submodules: true
4+
5+
- template: azure-install-rust.yml
6+
7+
- bash: echo "##vso[task.setvariable variable=RUSTC_VERSION;]`rustc --version`"
8+
displayName: Set rustc version string for caching
9+
10+
- bash: cargo build --release
11+
displayName: Cargo build
12+
13+
# Test what we're about to release in release mode itself.
14+
- bash: cargo test --release --all
15+
displayName: Cargo test
16+
env:
17+
RUST_BACKTRACE: 1
18+
19+
- bash: |
20+
echo "##vso[task.setvariable variable=tagName;]`echo $BUILD_SOURCEBRANCH | sed -e 's|refs/tags/||'`"
21+
displayName: Set tag name
22+
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
23+
- bash: |
24+
echo "##vso[task.setvariable variable=tagName;]dev"
25+
displayName: Set tag name to "dev"
26+
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
27+
28+
- bash: echo "##vso[task.setvariable variable=basename;]cranelift-$(tagName)-x86_64-windows"
29+
displayName: Configure basename var
30+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
31+
- bash: echo "##vso[task.setvariable variable=basename;]cranelift-$(tagName)-x86_64-macos"
32+
displayName: Configure basename var
33+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
34+
- bash: echo "##vso[task.setvariable variable=basename;]cranelift-$(tagName)-x86_64-linux"
35+
displayName: Configure basename var
36+
condition: and(succeeded(), eq( variables['Agent.OS'], 'Linux' ))
37+
38+
- bash: |
39+
set -e
40+
mkdir -p $BUILD_BINARIESDIRECTORY/$BASENAME
41+
if [ "$AGENT_OS" = "Windows_NT" ]; then
42+
ext=.exe
43+
fi
44+
cp LICENSE README.md target/release/clif-util$ext $BUILD_BINARIESDIRECTORY/$BASENAME
45+
displayName: Copy binaries
46+
47+
- task: ArchiveFiles@2
48+
inputs:
49+
rootFolderOrFile: $(Build.BinariesDirectory)/$(basename)
50+
archiveType: 'zip'
51+
archiveFile: '$(Build.ArtifactStagingDirectory)/$(basename).zip'
52+
displayName: Archive files (Win)
53+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
54+
- task: ArchiveFiles@2
55+
inputs:
56+
rootFolderOrFile: $(Build.BinariesDirectory)/$(basename)
57+
archiveType: 'tar'
58+
tarCompression: 'xz'
59+
archiveFile: '$(Build.ArtifactStagingDirectory)/$(basename).tar.xz'
60+
displayName: Archive files (Unix)
61+
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
62+
- task: PublishPipelineArtifact@1
63+
inputs:
64+
path: $(Build.ArtifactStagingDirectory)/
65+
artifactName: 'bundle-$(Agent.OS)'
66+

ci/azure-install-rust.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
steps:
2+
# Rustup is currently installed on Windows and Linux, but not macOS.
3+
# It is installed in /usr/local/cargo/bin/ or C:\Program Files\Rust\.cargo\bin\
4+
# This steps ensures that rustup is installed, mainly for macOS, or if the
5+
# azure image changes in the future.
6+
- bash: |
7+
set -ex
8+
if [ -x "`command -v rustup`" ]; then
9+
echo `command -v rustup` `rustup -V` already installed
10+
rustup self update
11+
else
12+
if [ "$AGENT_OS" = "Windows_NT" ]; then
13+
curl -sSf -o rustup-init.exe https://win.rustup.rs
14+
./rustup-init.exe -y --default-toolchain $TOOLCHAIN
15+
echo "##vso[task.prependpath]$USERPROFILE/.cargo/bin"
16+
else
17+
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN
18+
echo "##vso[task.prependpath]$HOME/.cargo/bin"
19+
fi
20+
fi
21+
displayName: Install rustup
22+
23+
- bash: |
24+
set -ex
25+
rustup update $TOOLCHAIN
26+
rustup default $TOOLCHAIN
27+
displayName: Install rust
28+
29+
- bash: |
30+
set -ex
31+
rustc -Vv
32+
cargo -V
33+
displayName: Query rust and cargo versions

0 commit comments

Comments
 (0)