Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.gitlab-ci.yml 2.70 KiB
variables:
  CONTAINER_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
  NODE_IMAGE: "node:16.14.0"
  CYPRESS_IMAGE: "cypress/browsers:node16.14.0-slim-chrome99-ff97"
  CYPRESS_CACHE_FOLDER: "cache/Cypress"

stages:
  - dependencies
  - check
  - build
  - lint
  - documentation
  - test
  - package
  - release
  - deploy

default:
  tags:
    - docker

dependencies:
  stage: dependencies
  image: $NODE_IMAGE
  script:
    - npm ci
  artifacts:
    expire_in: 1 hour
    paths:
      - node_modules
      - ${CYPRESS_CACHE_FOLDER}

pre-commit:
  stage: check
  image: registry.esss.lu.se/ics-docker/pre-commit:latest
  script:
    - pre-commit run --all-files

build:
  stage: build
  image: $NODE_IMAGE
  script:
    - CI=false npm run build
  artifacts:
    expire_in: 1 hour
    paths:
      - build

lint:
  stage: lint
  image: $NODE_IMAGE
  script:
    - npm run code-quality
  artifacts:
    reports:
      codequality: gl-codequality.json

build-storybook:
  stage: documentation
  image: $NODE_IMAGE
  script:
    - npm run build-storybook
  artifacts:
    expire_in: 1 month
    paths:
      - storybook-static

test-components-chrome:
  stage: test
  image: $CYPRESS_IMAGE
  script:
    - npx cypress run-ct --browser chrome --record --key ${CYPRESS_DASHBOARD_KEY}
  artifacts:
    when: on_failure
    expire_in: 24 hours
    paths:
      - cypress/videos
      - cypress/screenshots

build-image:
  stage: package
  image: docker:latest
  dependencies: []
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker build -t $CONTAINER_IMAGE .
    - docker push $CONTAINER_IMAGE

release-image:
  stage: release
  image: docker:latest
  dependencies: []
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker pull "$CONTAINER_IMAGE"
    - docker tag "$CONTAINER_IMAGE" "$CI_REGISTRY_IMAGE:latest"
    - docker push "$CI_REGISTRY_IMAGE:latest"
  only:
    - tags

deploy-test:
  stage: deploy
  image: registry.esss.lu.se/ics-docker/awxkit
  dependencies: []
  script:
    - >
      awx job_templates launch deploy-ccce-test
      --extra_vars "ce_deploy_ui_container_image_tag: $CI_COMMIT_REF_NAME"
      --job_tags ce-deploy-ui
      --monitor
  environment:
    name: test
    url: https://ce-deploy-test.cslab.esss.lu.se/
  when: manual

deploy-demo:
  stage: deploy
  image: registry.esss.lu.se/ics-docker/awxkit
  dependencies: []
  script:
    - >
      awx job_templates launch deploy-ccce-demo
      --extra_vars "ce_deploy_ui_container_image_tag: $CI_COMMIT_REF_NAME"
      --job_tags ce-deploy-ui
      --monitor
  environment:
    name: demo
    url: https://ce-deploy-demo.cslab.esss.lu.se/
  when: manual