language: rust
cache: cargo
before_script: 
  - cargo install -f rustfmt
  - export PATH=$PATH:$HOME/.cargo/bin
rust:
  - stable
  - beta
  - nightly
env:
  - NOTHING=INTERESTING
matrix:
  include:
    - rust: nightly
      env: RUSTFMT=YESPLEASE
      before_script: cargo install rustfmt-nightly --force
      script: cargo fmt --all -- --write-mode diff
  allow_failures:
    - rust: nightly
      env: NOTHING=INTERESTING

script:
  - cargo test --all

services:
  - docker

language: rust
cache: cargo
rust:
  - stable
  - beta
  - nightly
env:
  - RUN=TEST
script:
  - cargo test --all
services:
  - docker
matrix:
  include:
    - rust: nightly
      env: RUN=RUSTFMT
      before_script: rustup component add rustfmt-preview
      script: cargo fmt --all -- --write-mode diff
  allow_failures:
    - rust: nightly
      env: RUN=TEST

Use rustfmt-preview to not recompile rustfmt each time
Use rustfmt-preview to not recompile rustfmt each time
