# SPDX-FileCopyrightText: 2024 Sarah Vaupel <sarah.vaupel@uniworx.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

### IMPORTANT NOTICE ###
# Our pipeline consists of static and dynamic parts.
# 
# This file only contains the dynamic frontend parts of our pipeline.
# Static jobs are defined in .gitlab-ci.yml.
# 
# The marker "#dyn#" (without quotes) will be replaced by concrete values.
###

variables:
  FRONTEND_IMAGE_VERSION: #dyn#

stages:
  - compile
  - lint
  - test

default:
  image:
    name: ${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_SLUG}/frontend:${FRONTEND_IMAGE_VERSION}
    entrypoint: [""]
    docker:
      platform: x86_64
  artifacts:
    name: "${CI_JOB_NAME}-${CI_COMMIT_SHORT_SHA}"
    expire_in: "1 day"
  retry: 2
  interruptible: true


compile:
  stage: compile
  script:
    - make -- compile-frontend IN_CI=true IN_CONTAINER=true
  artifacts:
    paths:
      - ${CI_PROJECT_DIR}/node_modules
      - ${CI_PROJECT_DIR}/well-known
      - ${CI_PROJECT_DIR}/config/webpack.yml
  cache:
    - &frontend-cache
      key: default-frontend
      paths:
        - ${CI_PROJECT_DIR}/.npm/
        - ${CI_PROJECT_DIR}/.well-known-cache/

lint:
  stage: lint
  script:
    - make -- lint-frontend IN_CI=true IN_CONTAINER=true
  cache: *frontend-cache

test:
  stage: test
  needs:
    - compile
  script:
    - make -- test-frontend IN_CI=true IN_CONTAINER=true
  cache: *frontend-cache
