image: vlafeychine/rust

variables:
  CARGO_HOME: "$CI_PROJECT_DIR/.cache/cargo/"

cache:
  key:
    files:
      - Cargo.lock
  paths:
    - .cache/cargo/
    - target/

format:
  script:
    - cargo fmt --check

lint:
  script:
    - cargo clippy -- -D warnings

build:
  needs: [format, lint]
  script:
    - cargo build

test:
  needs: [build]
  script:
    - cargo test

docs:
  only:
    refs:
      - main
  script:
    - cargo doc --no-deps
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q -r target/doc/* v-lafeychine@zamok.crans.org:www/.
