version: 2

jobs:
  build:
    docker:
      - image:  circleci/rust:1.37.0

    steps:
      - checkout
      - run:
          name: Check formatting
          command: |
            rustfmt --version
            cargo fmt --
      - run:
          name: Build
          command: |
            rustc --version --verbose
            cargo --version --verbose
            cargo doc --no-deps
            cargo build --release
            rm -rf public
            mkdir public
            cp -R target/doc/* public
      - run:
          name: Test
          command: cargo test
      - save_cache:
          key: project-cache
          paths:
            - "~/.cargo"
            - "./target"