# Use Rust nightly docker image, see: https://hub.docker.com/r/rustlang/rust/
image: rustlang/rust:nightly

# Set the Cargo dir manually so it can be cached
variables:
  CARGO_HOME: $CI_PROJECT_DIR/cargo

# Cache the Cargo dir and build artifacts
cache:
  paths:
    - cargo/
    - target/

# Add the wasm32-unknown-unknown target for Rust
before_script:
  - rustup target add wasm32-unknown-unknown

# Defines stages which are to be executed
stages:
  - build

# Run `cargo build` for the project with nightly Rust
run-build:
  stage: build
  image: rustlang/rust:nightly
  script:
    - rustc --version && cargo --version
    - cargo build -p stoptime_server --release --jobs 1
    - cargo build -p stoptime_ui --target wasm32-unknown-unknown --release --jobs 1
    - cargo test -p stoptime_server --all-features -- --test-threads 1
