name: CI
on:
push:
branches:
- 'master'
tags: [ 'v*' ]
pull_request:
branches:
- 'master'
jobs:
build:
name: Build
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform: [
{
os: 'macos-latest',
rust_target: 'aarch64-apple-darwin',
},
{
os: 'macos-latest',
rust_target: 'x86_64-apple-darwin',
},
{
os: 'ubuntu-latest',
rust_target: 'aarch64-unknown-linux-gnu',
},
{
os: 'ubuntu-latest',
rust_target: 'aarch64-unknown-linux-musl',
},
{
os: 'ubuntu-latest',
rust_target: 'i686-unknown-linux-gnu',
},
{
os: 'ubuntu-latest',
rust_target: 'powerpc64le-unknown-linux-gnu',
},
{
os: 'ubuntu-latest',
rust_target: 's390x-unknown-linux-gnu',
},
{
os: 'ubuntu-latest',
rust_target: 'x86_64-unknown-linux-gnu',
},
{
os: 'ubuntu-latest',
rust_target: 'x86_64-unknown-linux-musl',
},
{
os: 'windows-latest',
rust_target: 'i686-pc-windows-msvc',
},
{
os: 'windows-latest',
rust_target: 'x86_64-pc-windows-msvc',
},
]
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Setup Rust'
uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.platform.rust_target }}
- name: 'Setup QEMU'
uses: docker/setup-qemu-action@v2
with:
platforms: all
if: ${{ runner.os == 'Linux' }}
- name: 'Build'
run: cargo build --all-features
test:
name: Test
runs-on: ${{ matrix.platform.os }}
needs: build
strategy:
matrix:
platform: [
{
os: 'macos-latest',
rust_target: 'x86_64-apple-darwin',
},
{
os: 'ubuntu-latest',
rust_target: 'i686-unknown-linux-gnu',
},
{
os: 'ubuntu-latest',
rust_target: 'x86_64-unknown-linux-gnu',
},
{
os: 'windows-latest',
rust_target: 'i686-pc-windows-msvc',
},
{
os: 'windows-latest',
rust_target: 'x86_64-pc-windows-msvc',
},
]
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Setup Rust'
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
target: ${{ matrix.platform.rust_target }}
- name: 'Check metadata'
run: >
[[ $(cargo metadata --format-version=1 --no-deps | jq '.packages[0].repository')
== '"${{ github.server_url }}/${{ github.repository }}"' ]]
shell: bash
- name: 'Run linter'
run: cargo fmt --check
- name: 'Setup cross-compiling dependencies'
run: sudo apt-get update && sudo apt-get install gcc-multilib
if: ${{ runner.os == 'Linux' &&
startsWith(matrix.platform.rust_target, 'i686') }}
- name: 'Install cargo-hack'
run: cargo install cargo-hack
- name: 'Run cargo-hack'
run: >
cargo hack --feature-powerset --depth
$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].features | length')
check --all-targets
- name: 'Run doctests'
run: rustup run nightly cargo test --all-features --doc --target=${{ matrix.platform.rust_target }}
env:
CARGO_INCREMENTAL: 0
RUSTDOCFLAGS: >
-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off
-Zpanic_abort_tests -Cpanic=abort
RUSTFLAGS: >
-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off
-Zpanic_abort_tests -Cpanic=abort
- name: 'Run tests'
run: rustup run nightly cargo test --all-features --all-targets
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: >
-Zprofile -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off
-Zpanic_abort_tests -Cpanic=abort
- name: 'Install coverage dependencies'
run: cargo install grcov
- name: 'Collect coverage'
run: >
grcov target -s . -t cobertura --llvm --branch --ignore-not-existing
--ignore "/*" -o coverage.xml
- name: 'Upload coverage'
uses: codecov/codecov-action@v3.1.1
with:
fail_ci_if_error: false
files: ./coverage.xml
continue-on-error: true
pre-deploy:
name: 'Pre-deploy'
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'push' && github.ref_type == 'tag'
steps:
- name: '_'
run: echo "Pre-deploy step"
deploy:
name: 'Deploy'
environment: release
needs: pre-deploy
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v3
- name: 'Setup Rust'
uses: dtolnay/rust-toolchain@stable
- name: 'Upload'
run: cargo publish --no-verify
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}