stages:
  - build
  - test
  - deploy

default:
  image: registry.example.invalid/ci/node:20
  interruptible: true
  retry:
    max: 2
    when: runner_system_failure

variables:
  BUILD_DIR: build
  GIT_DEPTH: "20"

build:
  stage: build
  script:
    - npm ci
    - npm run build
  artifacts:
    paths:
      - $BUILD_DIR/
    expire_in: 1 week

unit-tests:
  stage: test
  needs: [build]
  script:
    - npm test
  coverage: '/Lines\s*:\s*(\d+\.\d+)%/'

deploy:
  stage: deploy
  needs: [unit-tests]
  environment:
    name: staging
    url: https://staging.example.invalid
  script:
    - echo "deploying $CI_COMMIT_SHORT_SHA"
