stages:
  - test
  - build_site
  - deploy

variables:
  CARGO_HOME: "$CI_PROJECT_DIR/cargo"

cache:
  paths:
    - target/
    - cargo/

test:
  image: rust:latest
  stage: test
  script:
    - cargo test --verbose

build_site:
  image: rust:latest
  stage: build_site
  script:
    - cargo run
    - mv output public
  artifacts:
    paths:
      - public

pages:
  stage: deploy
  script:
    - echo "Publishing site..."
  dependencies:
    - build_site
  artifacts:
    paths:
      - public
  rules:
    - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"