name: CI

on:
  push:
    branches: [ trunk ]
  pull_request:
    branches: [ trunk ]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: debug build & test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Build
      run: cargo build --verbose
    - name: Run tests
      run: cargo test --verbose
  test-release:
    name: release build & test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Build
      run: cargo build --release --verbose
    - name: Run tests
      run: cargo test --release --verbose
    - name: Run ignored tests
      run: cargo test --release --verbose -- --ignored
  test-miri:
    name: miri build & test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Install latest nightly
      uses: actions-rs/toolchain@v1
      with:
        toolchain: nightly
        override: true
        components: miri, rust-src
    - name: Run tests under Miri
      run: cargo miri test --verbose
  fmt:
    name: rustfmt
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - name: Check with rustfmt
      run: cargo fmt -- --check
