Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.65 KiB
image: node:16-alpine
stages:
  - test
  - build
  - deploy

# Prevent detached merge request pipelines
# https://docs.gitlab.com/ee/ci/merge_request_pipelines/
# Those do not run the environment on_stop jobs when MRs are closed/merged
# or when branches get deleted, unlike branch pipelines.
workflow:
  rules:
    - if: '$CI_MERGE_REQUEST_ID'
      when: never
    - when: always

before_script:
  - npm ci

frontend-test:
  stage: test
  script:
    - npm run test -- --reporter=xunit --reporter-option output=test-report.xml

  artifacts:
    when: always
    reports:
      junit:
        - test-report.xml

frontend-lint:
  stage: test

  before_script:
    - npm ci
    - apk add py3-pip bash git build-base python3-dev
    - pip3 install pre-commit

  script:
    - pre-commit run -a

frontend-audit:
  stage: test
  script:
    - npm audit --parseable
  allow_failure: true

.build:
  stage: build
  # Ignore frontend-audit to speed up CI builds
  needs:
    - frontend-test
    - frontend-lint
  artifacts:
    paths:
      - dist
    expire_in: 2 weeks

frontend-build-surge:
  extends: .build

  # Only deploy branches on surge
  rules:
    - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "master"'
      when: on_success
    - when: never

  variables:
    # On merge requests we build using preprod to be able
    # to test on surge.sh