# GitLab CI leans harder on YAML anchors than any other CI dialect, and combines them with its
# own `extends` keyword. The two do not compose the same way: anchors are resolved by the YAML
# loader before GitLab sees the document, `extends` is resolved afterwards and merges deeply.
.runner_defaults: &runner_defaults
  image: registry.example.invalid/ci/node:20
  tags:
    - linux
    - docker
  retry: 1

.test_template:
  <<: *runner_defaults
  stage: test
  before_script:
    - npm ci
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

stages: [build, test]

build:
  <<: *runner_defaults
  stage: build
  script:
    - npm run build

unit:
  extends: .test_template
  script:
    - npm run test:unit

integration:
  extends: .test_template
  retry: 2
  script:
    - npm run test:integration
