Migrate CI to GitHub Actions

This commit migrates from Azure Pipelines to Github Actions for CI for
cranelift. The CI configuration was relatively straightforward, and the
intention here is not to change what's actually being done on CI, just
change where it's being done. The previous CI configuration had build
targets for producing releases, but these weren't actually applicable
for cranelift itself (mostly just copied from wasmtime), so they've been
folded into the main "test everything" matrix which now includes
`--release` mode items.

See cranestation/wasmtime#474 for some more context as well in terms of
benefits of Github Actions vs Azure Pipelines.
This commit is contained in:
Alex Crichton
2019-11-05 10:48:09 -08:00
committed by Andrew Brown
parent a49483408c
commit f0e90df9ac
4 changed files with 136 additions and 283 deletions

View File

@@ -1,184 +0,0 @@
name: $(Build.SourceBranch)-$(date:yyyy-MM-dd)$(rev:.r)
trigger:
branches:
include:
- 'master'
tags:
include:
- '*'
exclude:
- 'dev'
jobs:
- job: rustfmt
pool:
vmImage: 'macos-10.14'
steps:
- checkout: self
submodules: true
- template: ci/azure-install-rust.yml
- script: rustup component add rustfmt
displayName: Add rustfmt
- script: cargo fmt --all -- --check
displayName: Check formatting
variables:
toolchain: stable
# Smoke test to build docs on one builder, using OSX for now since it's the
# fastest
- job: docs
pool:
vmImage: 'macos-10.14'
steps:
- checkout: self
submodules: true
- template: ci/azure-install-rust.yml
- script: |
cargo doc --all --exclude cranelift-codegen-meta
cargo doc --package cranelift-codegen-meta --document-private-items
displayName: Build documentation
- script: cargo install cargo-deadlinks
displayName: Install cargo-deadlinks
- bash: |
find ./target/doc -maxdepth 1 -type d -name "cranelift*" | xargs -I{} cargo deadlinks --dir {}
displayName: Run cargo-deadlinks
variables:
toolchain: nightly
- job: Test
strategy:
matrix:
windows-earliest:
imageName: 'vs2017-win2016'
toolchain: '1.37.0'
linux-earliest:
imageName: 'ubuntu-16.04'
toolchain: '1.37.0'
mac-earliest:
imageName: 'macos-10.14'
toolchain: '1.37.0'
mac-stable:
imageName: 'macos-10.14'
toolchain: stable
mac-beta:
imageName: 'macos-10.14'
toolchain: beta
mac-nightly:
imageName: 'macos-10.14'
toolchain: nightly
pool:
vmImage: $(imageName)
steps:
- checkout: self
submodules: true
- template: ci/azure-install-rust.yml
- script: cargo fetch
displayName: Fetch cargo dependencies
- script: cargo build
displayName: Cargo build
- bash: cargo test --all
displayName: Cargo test
env:
RUST_BACKTRACE: 1
# Ensure fuzzer works by running it with a single input
- bash: cargo install cargo-fuzz
displayName: Install cargo-fuzz
condition: and(succeeded(), eq(variables['toolchain'], 'nightly'))
- bash: |
fuzz_module="ffaefab69523eb11935a9b420d58826c8ea65c4c"
cargo fuzz run fuzz_translate_module \
"fuzz/corpus/fuzz_translate_module/$fuzz_module"
displayName: Run cargo-fuzz
env:
RUST_BACKTRACE: 1
condition: and(succeeded(), eq(variables['toolchain'], 'nightly'))
continueOnError: true
- job: Fuzz_regression
displayName: Fuzz regression
pool:
vmImage: "ubuntu-16.04"
variables:
toolchain: nightly
steps:
- template: ci/azure-install-rust.yml
- bash: cargo install cargo-fuzz
- bash: ci/fuzzit.sh local-regression
- job: Fuzz
condition: ne(variables['Build.Reason'], 'PullRequest')
pool:
vmImage: "ubuntu-16.04"
variables:
toolchain: nightly
steps:
- template: ci/azure-install-rust.yml
- bash: cargo install cargo-fuzz
- bash: ci/fuzzit.sh fuzzing
env:
FUZZIT_API_KEY: $(FUZZIT_API_KEY)
- job: Build
strategy:
matrix:
windows:
imageName: 'vs2017-win2016'
# Statically link against msvcrt to produce slightly more portable
# binaries on Windows by reducing our binary compatibility requirements.
RUSTFLAGS: -Ctarget-feature=+crt-static
mac:
imageName: 'macos-10.14'
# Lower the deployment target from our build image in an attempt to
# build more portable binaries that run on older releases. Note that
# 10.9 here is arbitrarily chosen and just happens to be the lowest that
# works at this time. Raising this is probably fine.
MACOSX_DEPLOYMENT_TARGET: 10.9
variables:
toolchain: '1.37.0'
pool:
vmImage: $(imageName)
# We try to be compatible with beta and nightly, but they occasionally
# fail, so we don't allow them to hold up people using stable.
continueOnError: $[ne(variables['toolchain'], 'stable')]
steps:
- template: ci/azure-build-release.yml
# Build the Linux release binary in an older Linux container (in this case
# Centos 6)
- job: Build_linux
variables:
toolchain: '1.37.0'
container:
image: centos:6
options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
steps:
# We're executing in the container as non-root but `yum` requires root. We
# need to install `sudo` but to do that we need `sudo`. Do a bit of a weird
# hack where we use the host `docker` executable to re-execute in our own
# container with the root user to install `sudo`
- bash: /tmp/docker exec -t -u 0 ci-container sh -c "yum install -y sudo"
displayName: Configure sudo
# See https://edwards.sdsu.edu/research/c11-on-centos-6/ for where these
# various commands came from.
- bash: |
set -e
sudo yum install -y centos-release-scl cmake xz
sudo yum install -y devtoolset-8-gcc devtoolset-8-binutils devtoolset-8-gcc-c++
echo "##vso[task.prependpath]/opt/rh/devtoolset-8/root/usr/bin"
displayName: Install system dependencies
# Delete `libstdc++.so` to force gcc to link against `libstdc++.a` instead.
# This is a hack and not the right way to do this, but it ends up doing the
# right thing for now.
- bash: sudo rm -f /opt/rh/devtoolset-8/root/usr/lib/gcc/x86_64-redhat-linux/8/libstdc++.so
displayName: Force a static libstdc++
- template: ci/azure-build-release.yml

136
cranelift/.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,136 @@
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- run: cargo fmt -- --check
docs:
name: Build API Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: cargo doc --all --exclude cranelift-codegen-meta
- run: cargo doc --package cranelift-codegen-meta --document-private-items
- run: cargo install cargo-deadlinks
- run: find ./target/doc -maxdepth 1 -type d -name "cranelift*" | xargs -I{} cargo deadlinks --dir {}
name: Run cargo-deadlinks
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
# first a list of everything we test...
name:
- windows-earliest
- linux-earliest
- mac-earliest
- stable
- beta
- nightly
- windows-release
- linux-release
- mac-release
# .. and then the actual configuration for each thing we test
include:
- name: windows-earliest
os: ubuntu-latest
rust: 1.37.0
- name: linux-earliest
os: ubuntu-16.04
rust: 1.37.0
- name: mac-earliest
os: macos-10.14
rust: 1.37.0
- name: stable
os: macos-latest
rust: stable
- name: beta
os: macos-latest
rust: beta
- name: nightly
os: macos-latest
rust: nightly
- name: mac-release
os: macos-latest
rust: stable
release: --release
- name: linux-release
os: ubuntu-latest
rust: stable
release: --release
- name: windows-release
os: windows-latest
rust: stable
release: --release
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Install Rust (rustup)
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
if: "!startsWith(matrix.os, 'macos-')"
shell: bash
- name: Install Rust (macos)
run: |
curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=${{ matrix.rust }}
echo ::add-path::$HOME/.cargo/bin
if: startsWith(matrix.os, 'macos-')
- run: cargo fetch
- run: cargo build ${{ matrix.release }}
- run: cargo test --all ${{ matrix.release }}
env:
RUST_BACKTRACE: 1
# Ensure fuzzer works by running it with a single input
- run: cargo install cargo-fuzz
if: matrix.rust == 'nightly'
- run: |
fuzz_module="ffaefab69523eb11935a9b420d58826c8ea65c4c"
cargo fuzz run fuzz_translate_module fuzz/corpus/fuzz_translate_module/$fuzz_module
env:
RUST_BACKTRACE: 1
if: matrix.rust == 'nightly'
continue-on-error: true
fuzz:
name: Fuzz Regression
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: cargo install cargo-fuzz
- run: ci/fuzzit.sh local-regression
fuzz_push:
name: Fuzz (push)
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: cargo install cargo-fuzz
- run: ci/fuzzit.sh fuzzing
env:
FUZZIT_API_KEY: ${{ secrets.FUZZIT_API_KEY }}

View File

@@ -1,66 +0,0 @@
steps:
- checkout: self
submodules: true
- template: azure-install-rust.yml
- bash: echo "##vso[task.setvariable variable=RUSTC_VERSION;]`rustc --version`"
displayName: Set rustc version string for caching
- bash: cargo build --release
displayName: Cargo build
# Test what we're about to release in release mode itself.
- bash: cargo test --release --all
displayName: Cargo test
env:
RUST_BACKTRACE: 1
- bash: |
echo "##vso[task.setvariable variable=tagName;]`echo $BUILD_SOURCEBRANCH | sed -e 's|refs/tags/||'`"
displayName: Set tag name
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
- bash: |
echo "##vso[task.setvariable variable=tagName;]dev"
displayName: Set tag name to "dev"
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
- bash: echo "##vso[task.setvariable variable=basename;]cranelift-$(tagName)-x86_64-windows"
displayName: Configure basename var
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- bash: echo "##vso[task.setvariable variable=basename;]cranelift-$(tagName)-x86_64-macos"
displayName: Configure basename var
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
- bash: echo "##vso[task.setvariable variable=basename;]cranelift-$(tagName)-x86_64-linux"
displayName: Configure basename var
condition: and(succeeded(), eq( variables['Agent.OS'], 'Linux' ))
- bash: |
set -e
mkdir -p $BUILD_BINARIESDIRECTORY/$BASENAME
if [ "$AGENT_OS" = "Windows_NT" ]; then
ext=.exe
fi
cp LICENSE README.md target/release/clif-util$ext $BUILD_BINARIESDIRECTORY/$BASENAME
displayName: Copy binaries
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.BinariesDirectory)/$(basename)
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(basename).zip'
displayName: Archive files (Win)
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: $(Build.BinariesDirectory)/$(basename)
archiveType: 'tar'
tarCompression: 'xz'
archiveFile: '$(Build.ArtifactStagingDirectory)/$(basename).tar.xz'
displayName: Archive files (Unix)
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
- task: PublishPipelineArtifact@1
inputs:
path: $(Build.ArtifactStagingDirectory)/
artifactName: 'bundle-$(Agent.OS)'

View File

@@ -1,33 +0,0 @@
steps:
# Rustup is currently installed on Windows and Linux, but not macOS.
# It is installed in /usr/local/cargo/bin/ or C:\Program Files\Rust\.cargo\bin\
# This steps ensures that rustup is installed, mainly for macOS, or if the
# azure image changes in the future.
- bash: |
set -ex
if [ -x "`command -v rustup`" ]; then
echo `command -v rustup` `rustup -V` already installed
rustup self update
else
if [ "$AGENT_OS" = "Windows_NT" ]; then
curl -sSf -o rustup-init.exe https://win.rustup.rs
./rustup-init.exe -y --default-toolchain $TOOLCHAIN
echo "##vso[task.prependpath]$USERPROFILE/.cargo/bin"
else
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $TOOLCHAIN
echo "##vso[task.prependpath]$HOME/.cargo/bin"
fi
fi
displayName: Install rustup
- bash: |
set -ex
rustup update $TOOLCHAIN
rustup default $TOOLCHAIN
displayName: Install rust
- bash: |
set -ex
rustc -Vv
cargo -V
displayName: Query rust and cargo versions