.cargo_test_template: &cargo_test
  stage: test
  script:
    - rustc --version && cargo --version            # Print version info for debugging
    - time cargo test --verbose --jobs 1 --release  # Don't paralize to make errors more readable
  cache:
    paths:
      - target/*
      - cargo/*

stages:
  - test
  - deploy

stable:cargo:
  image: rust:latest
  <<: *cargo_test

lib:
  image: rust:latest
  stage: deploy
  only:
    - master
  script:
    - cargo doc --no-deps
    - cargo build --release
    - rm -rf public
    - mkdir public
    - cp -R target/doc/* public
  artifacts:
    paths:
    - public/
    - target/release/
  cache:
    paths:
      - $HOME/.cargo/*
