variables:
  RUST_IMAGE: "rust:latest"
  NODE_IMAGE: "node:lts"
  CARGO_HOME: $CI_PROJECT_DIR/cargo

stages:
  - lint
  - build
  - test
  - release

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - target
    - cargo
    - ui/node_modules

lint:backend:
  stage: lint
  image: $RUST_IMAGE
  script:
    - rustup component add clippy
    - make backend_lint
  rules:
    - allow_failure: true

#lint:frontend:
#  stage: lint
#  image: $NODE_IMAGE
#  script:
#    - make frontend_lint
#  rules:
#    - allow_failure: true

build:backend:
  stage: build
  image: $RUST_IMAGE
  script:
    - rustc --version && cargo --version
    - make backend
  artifacts:
    paths:
      - target
    expire_in: 1 day

build:frontend:
  stage: build
  image: $NODE_IMAGE
  script:
    - node --version && npm --version
    - make frontend
  artifacts:
    paths:
      - ui/dist
    expire_in: 1 day

test:backend:
  stage: test
  image: $RUST_IMAGE
  script:
    - make backend_test

package:
  stage: release
  image: $RUST_IMAGE
  script:
    - make
  artifacts:
    paths:
      - dist
