Migrate CI to Github Actions

This commit is contained in:
gnzlbg 2019-11-28 14:11:43 +01:00
parent bce67f3d2d
commit c69975db99
7 changed files with 266 additions and 175 deletions

View File

@ -1,17 +1,188 @@
name: CI name: CI
on:
on: [push] push:
branches:
- master
pull_request:
branches:
- master
jobs: jobs:
build: style:
name: Check Style
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@master
- name: Run a one-line script with:
run: echo Hello, world! submodules: true
- name: Run a multi-line script - name: Install Rust
run: rustup update nightly && rustup default nightly
- run: ci/style.sh
docs:
name: Build Documentation
needs: [style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Install Rust
run: rustup update nightly && rustup default nightly
- run: ci/dox.sh
env:
CI: 1
- name: Publish documentation
run: | run: |
echo Add other actions to build, cd target/doc
echo test, and deploy your project. git init
git add .
git -c user.name='ci' -c user.email='ci' commit -m init
git push -f -q https://git:${{ secrets.github_token }}@github.com/${{ github.repository }} HEAD:gh-pages
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
benches:
name: Build benchmarks
needs: [style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
submodules: true
- name: Install Rust
run: rustup update nightly && rustup default nightly
- name: Benchmarks
run: |
cargo test --bench roundtrip
cargo test --features=alloc_trait --bench roundtrip
test:
needs: [style]
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
target:
- aarch64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-unknown-linux-gnu
include:
# - target: aarch64-linux-android
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
rust: nightly
no_jemalloc_tests: 1
# - target: arm-linux-androideabi
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
# - target: arm-unknown-linux-gnueabi
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
# - target: armv7-unknown-linux-gnueabihf
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
# - target: i586-unknown-linux-gnu
# os: ubuntu-latest
# rust: nightly
# - target: i686-pc-windows-gnu
# os: windows-latest
# rust: nightly
# - target: i686-pc-windows-msvc
# os: windows-latest
# rust: nightly
# - target: i686-unknown-linux-gnu
# os: ubuntu-latest
# rust: nightly
# - target: mips-unknown-linux-gnu
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
# - target: mips64-unknown-linux-gnuabi64
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
# - target: mips64el-unknown-linux-gnuabi64
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
# - target: mipsel-unknown-linux-gnu
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
# - target: s390x-unknown-linux-gnu
# os: ubuntu-latest
# rust: nightly
# no_jemalloc_tests: 1
- target: x86_64-apple-darwin
os: macos-latest
rust: nightly
# - target: x86_64-apple-darwin
# os: macos-latest
# rust: beta
# - target: x86_64-apple-darwin
# os: macos-latest
# rust: stable
# - target: x86_64-linux-android
# os: ubuntu-latest
# rust: nightly
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
rust: nightly
# - target: x86_64-unknown-linux-gnu
# os: ubuntu-latest
# rust: nightly
# valgrind: 1
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
rust: nightly
jemalloc-dev: 1
valgrind: 1
# - target: x86_64-unknown-linux-gnu
# os: ubuntu-latest
# rust: beta
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
rust: stable
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: matrix.os != 'macos-latest'
- name: Install Rust (macos)
run: |
curl https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
echo "##[add-path]$HOME/.cargo/bin"
if: matrix.os == 'macos-latest'
- run: rustup target add ${{ matrix.target }}
- run: cargo generate-lockfile
# Configure some env vars based on matrix configuration
- run: echo "##[set-env name=NO_JEMALLOC_TESTS]1"
if: matrix.no_jemalloc_tests != ''
- run: echo "##[set-env name=JEMALLOC_SYS_GIT_DEV_BRANCH]1"
if: matrix.jemalloc-dev != ''
- run: echo "##[set-env name=VALGRIND]1"
if: matrix.valgrind != ''
# Windows & OSX go straight to `run.sh` ...
- run: ./ci/run.sh
shell: bash
if: matrix.os != 'ubuntu-latest'
env:
TARGET: ${{ matrix.target }}
# ... while Linux goes to `run-docker.sh`
- run: ./ci/run-docker.sh ${{ matrix.target }}
shell: bash
if: "matrix.os == 'ubuntu-latest'"
env:
TARGET: ${{ matrix.target }}

View File

@ -1,164 +0,0 @@
language: rust
rust: nightly
services: docker
matrix:
include:
# Linux
- name: "aarch64-unknown-linux-gnu"
env: TARGET=aarch64-unknown-linux-gnu NO_JEMALLOC_TESTS=1
- name: "arm-unknown-linux-gnueabi"
env: TARGET=arm-unknown-linux-gnueabi NO_JEMALLOC_TESTS=1
- name: "armv7-unknown-linux-gnueabihf"
env: TARGET=armv7-unknown-linux-gnueabihf NO_JEMALLOC_TESTS=1
- name: "i586-unknown-linux-gnu"
env: TARGET=i586-unknown-linux-gnu
addons: &gcc_multilib
apt:
packages:
- gcc-multilib
- name: "i686-unknown-linux-gnu (nightly)"
env: TARGET=i686-unknown-linux-gnu
addons: *gcc_multilib
- name: "i686-unknown-linux-gnu (beta)"
env: TARGET=i686-unknown-linux-gnu
addons: *gcc_multilib
rust: beta
- name: "i686-unknown-linux-gnu (stable)"
env: TARGET=i686-unknown-linux-gnu
addons: *gcc_multilib
rust: stable
# FIXME: blocked onhttps://github.com/jemalloc/jemalloc/issues/1464
# - name: "i686-unknown-linux-musl"
# env: TARGET=i686-unknown-linux-musl NOBGT=1 NO_JEMALLOC_TESTS=1
- name: "mips-unknown-linux-gnu"
env: TARGET=mips-unknown-linux-gnu NO_JEMALLOC_TESTS=1
- name: "mips64-unknown-linux-gnuabi64"
env: TARGET=mips64-unknown-linux-gnuabi64 NO_JEMALLOC_TESTS=1
- name: "mips64el-unknown-linux-gnuabi64"
env: TARGET=mips64el-unknown-linux-gnuabi64 NO_JEMALLOC_TESTS=1
- name: "mipsel-unknown-linux-gnu"
env: TARGET=mipsel-unknown-linux-gnu NO_JEMALLOC_TESTS=1
- name: "powerpc-unknown-linux-gnu"
env: TARGET=powerpc-unknown-linux-gnu NO_JEMALLOC_TESTS=1
- name: "powerpc64-unknown-linux-gnu"
env: TARGET=powerpc64-unknown-linux-gnu NO_JEMALLOC_TESTS=1
- name: "powerpc64le-unknown-linux-gnu"
env: TARGET=powerpc64le-unknown-linux-gnu NO_JEMALLOC_TESTS=1
- name: "x86_64-unknown-linux-gnu (nightly)"
env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1 JEMALLOC_SYS_VERIFY_CONFIGURE=1
install: rustup component add llvm-tools-preview
addons: &valgrind
apt:
packages:
- valgrind
- autoconf
- name: "x86_64-unknown-linux-gnu (nightly - jemalloc's dev branch)"
env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1 JEMALLOC_SYS_GIT_DEV_BRANCH=1
install: rustup component add llvm-tools-preview
addons: *valgrind
- name: "x86_64-unknown-linux-gnu (beta)"
env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1
rust: beta
install: rustup component add llvm-tools-preview
addons: *valgrind
- name: "x86_64-unknown-linux-gnu (stable)"
env: TARGET=x86_64-unknown-linux-gnu VALGRIND=1
rust: stable
install: rustup component add llvm-tools-preview
addons: *valgrind
- name: "Benchmarks using x86_64-unknown-linux-gnu (nightly)"
env: TARGET=x86_64-unknown-linux-gnu
install: true
script:
- cargo test --bench roundtrip
- cargo test --features=alloc_trait --bench roundtrip
- name: "x86_64-unknown-linux-musl"
env: TARGET=x86_64-unknown-linux-musl NOBGT=1 NO_JEMALLOC_TESTS=1
# Android
- name: "aarch64-linux-android"
env: TARGET=aarch64-linux-android NO_JEMALLOC_TESTS=1
- name: "x86_64-linux-android"
env: TARGET=x86_64-linux-android
# OSX
# FIXME: cannot jemalloc tests fail due to:
# https://github.com/jemalloc/jemalloc/issues/1320
# https://github.com/gnzlbg/jemallocator/issues/85
- name: "i686-apple-darwin (nightly)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
- name: "i686-apple-darwin (beta)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: beta
- name: "i686-apple-darwin (stable)"
env: TARGET=i686-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: stable
# FIXME: valgrind fails on OSX
# https://github.com/gnzlbg/jemallocator/issues/86
- name: "x86_64-apple-darwin (nightly)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 JEMALLOC_SYS_VERIFY_CONFIGURE=1
os: osx
osx_image: xcode10
install: rustup component add llvm-tools-preview
- name: "x86_64-apple-darwin (nightly - jemalloc's dev branch)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1 JEMALLOC_SYS_GIT_DEV_BRANCH=1
os: osx
osx_image: xcode10
install: rustup component add llvm-tools-preview
- name: "x86_64-apple-darwin (beta)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: beta
install: rustup component add llvm-tools-preview
- name: "x86_64-apple-darwin (stable)"
env: TARGET=x86_64-apple-darwin NO_JEMALLOC_TESTS=1
os: osx
osx_image: xcode10
rust: stable
install: rustup component add llvm-tools-preview
# TOOLING
- name: "Documentation"
install: true
script: RUSTDOCFLAGS="--cfg jemallocator_docs" cargo doc
deploy:
provider: script
script: curl -LsSf https://git.io/fhJ8n | rustc - && (cd target/doc && ../../rust_out)
skip_cleanup: true
on:
branch: master
- name: "rustfmt"
install: true
rust: nightly
script: |
if rustup component add rustfmt-preview ; then
cargo fmt --all -- --check
fi
- name: "clippy"
install: true
rust: nightly
# allow(clippy::all) fails in the syscrate, so we can't use --all here:
script: |
if rustup component add clippy-preview ; then
cargo clippy -p jemalloc-sys -- -D clippy::pedantic
cargo clippy -p jemallocator -- -D clippy::pedantic
cargo clippy -p jemallocator-global -- -D clippy::pedantic
cargo clippy -p jemalloc-ctl -- -D clippy::pedantic
fi
- name: "Shellcheck"
install: true
script: shellcheck ci/*.sh
install: rustup target add ${TARGET}
script: sh ci/run.sh
notifications:
email:
on_success: never

View File

@ -0,0 +1,7 @@
FROM ubuntu:19.04
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \
PATH=$PATH:/rust/bin

View File

@ -0,0 +1,6 @@
FROM ubuntu:19.04
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates valgrind
ENV PATH=$PATH:/rust/bin

View File

@ -6,3 +6,4 @@ export RUSTDOCFLAGS="--cfg jemallocator_docs"
cargo doc --features alloc_trait cargo doc --features alloc_trait
cargo doc -p jemalloc-sys cargo doc -p jemalloc-sys
cargo doc -p jemalloc-ctl cargo doc -p jemalloc-ctl
cargo doc -p jemallocator-global

46
ci/run-docker.sh Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env sh
# Small script to run tests for a target (or all targets) inside all the
# respective docker images.
set -ex
echo "${HOME}"
pwd
run() {
echo "Building docker container for target ${1}"
# use -f so we can use ci/ as build context
docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/
mkdir -p target
if [ -w /dev/kvm ]; then
kvm="--volume /dev/kvm:/dev/kvm"
else
kvm=""
fi
docker run \
--rm \
--user "$(id -u)":"$(id -g)" \
--env LIBC_CI \
--env CARGO_HOME=/cargo \
--env CARGO_TARGET_DIR=/checkout/target \
--volume "$(dirname "$(dirname "$(command -v cargo)")")":/cargo \
--volume "$(rustc --print sysroot)":/rust:ro \
--volume "$(pwd)":/checkout:ro \
--volume "$(pwd)"/target:/checkout/target \
$kvm \
--init \
--workdir /checkout \
libc \
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin exec ci/run.sh ${1}"
}
if [ -z "${1}" ]; then
for d in ci/docker/*; do
run "${d}"
done
else
run "${1}"
fi

24
ci/style.sh Executable file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env sh
set -ex
if rustup component add rustfmt-preview ; then
command -v rustfmt
rustfmt -V
cargo fmt --all -- --check
fi
if rustup component add clippy-preview ; then
cargo clippy -V
cargo clippy -p jemalloc-sys -- -D clippy::pedantic
cargo clippy -p jemallocator -- -D clippy::pedantic
cargo clippy -p jemallocator-global -- -D clippy::pedantic
cargo clippy -p jemalloc-ctl -- -D clippy::pedantic
fi
if shellcheck --version ; then
shellcheck ci/*.sh
else
echo "shellcheck not found"
exit 1
fi