image: node:alpine # Much smaller than other variants, faster and more resource effective

cache:
  key: "${CI_COMMIT_REF_SLUG}" # Branch-specific cache keys to have separate caches across branches.
  paths:
    - node_modules/
    - build/

stages:
  - install
  - build
  - test

install_dependencies:
  stage: install
  script:
    - npm ci
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
        - node_modules/
    policy: push

build_project:
  stage: build
  script:
    - npm ci
    - npm run build
  dependencies:
    - install_dependencies
  cache:
    key: "${CI_COMMIT_REF_SLUG}"
    paths:
      - node_modules/
    policy: pull

vitest_unit-tests:
  stage: test
  script:
    - npm ci
    - npm run test:unit
  dependencies:
    - install_dependencies
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
        - node_modules/
    policy: pull

eslint_check-lint:
  stage: test
  script:
    - npm run lint
  dependencies:
    - install_dependencies
  cache:
    key: ${CI_COMMIT_REF_SLUG}
    paths:
        - node_modules/
    policy: pull
  allow_failure: true  



    
