name: ci
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '00 00 * * *'
defaults:
run:
shell: bash
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: ${{ format('test ({0})', matrix.name || matrix.rust) }}
runs-on: ${{ format('{0}-latest', matrix.os || 'ubuntu') }}
env:
CARGO: cargo
TARGET: ''
strategy:
matrix:
rust:
- 1.53.0
- stable
- beta
- nightly
include:
- rust: nightly
name: macos
os: macos
- rust: nightly-x86_64-msvc
name: windows-msvc
os: windows
- rust: nightly-x86_64-gnu
name: windows-gnu
os: windows
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
profile: minimal
- name: Use Cross
if: ${{ matrix.target != '' }}
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET=--target ${{ matrix.target }}" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
echo "cargo command: ${{ env.CARGO }}"
echo "target flag: ${{ env.TARGET }}"
- name: Build
run: ${{ env.CARGO }} build --verbose --workspace ${{ env.TARGET }}
- name: Build (unstable)
if: ${{ startsWith(matrix.rust, 'nightly') }}
run: ${{ env.CARGO }} build --verbose --workspace --features unstable ${{ env.TARGET }}
- name: Run tests
run: ${{ env.CARGO }} test --verbose --workspace ${{ env.TARGET }}
- name: Run tests (unstable)
if: ${{ startsWith(matrix.rust, 'nightly') }}
run: ${{ env.CARGO }} test --verbose --workspace --features unstable ${{ env.TARGET }}
rustfmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
success:
name: ci pass
if: ${{ success() }}
runs-on: ubuntu-latest
needs:
- test
- rustfmt
steps:
- name: Mark the job as successful
run: exit 0