Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
.gitlab-ci.yml 4.13 KiB
workflow:
  rules:
    - if: $CI_COMMIT_REF_NAME =~ /^i18n$/
    - if: $CI_COMMIT_REF_NAME =~ /^(\d+\.\d+\.\d+)$/
      variables:
        IS_RELEASE: "true"
    - if: $CI_COMMIT_TAG
    - if: '$CI_PIPELINE_SOURCE == "web"'
    - if: '$CI_PIPELINE_SOURCE == "schedule"'
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

include:
  - component: $CI_SERVER_HOST/appsuite/web-foundation/ci/kaniko/kaniko@0.0.9
    inputs:
      build-context: $CI_PROJECT_DIR/packages/appsuite-codeceptjs
      dockerfile: container/Dockerfile
      job-name: build appsuite-codeceptjs image
  - component: $CI_SERVER_HOST/appsuite/web-foundation/ci/nodejs/publish-npm-module@0.0.1
    inputs:
      job-name: publish appsuite-codeceptjs npm module
      base-path: packages/appsuite-codeceptjs


# Add check for existing tag in registry
build appsuite-codeceptjs release image:
  extends:
    - .build appsuite-codeceptjs image
  before_script:
    - VERSION=$(grep '"version"' packages/appsuite-codeceptjs/package.json | cut -d '"' -f 4)
    - DESTINATION=$CI_REGISTRY/appsuite/web-foundation/tools/appsuite-codeceptjs:$VERSION
    - |
      if [[ "$CI_COMMIT_BRANCH" != "main" ]]; then
        REPO_ID=$(wget -q --no-check-certificate --header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" -O - "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/registry/repositories" | grep -o '{[^}]*"name":"appsuite-codeceptjs"[^}]*}' | grep -o '"id":[0-9]*' | sed 's/"id"://')
        if [[ -n "$REPO_ID" ]]; then
          wget -q --no-check-certificate --header "PRIVATE-TOKEN: ${CI_JOB_TOKEN}" -O - "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/registry/repositories/${REPO_ID}/tags/${VERSION}" | grep name || {
            echo "Tag $VERSION already exists in the registry. Skipping build."
            exit 0
          }
        fi
      fi
  tags:
    - build-hetzner
  stage: build

build appsuite-codeceptjs image:
  before_script:
    - DESTINATION=$CI_REGISTRY_IMAGE/appsuite-codeceptjs:$CI_COMMIT_REF_SLUG
  extends:
    - .build appsuite-codeceptjs image
  tags:
    - build-hetzner
  stage: build

variables:
  HUSKY: 0

stages:
  - test
  - build
  - e2e
  - publish

audit npm modules:
  image: $CI_REGISTRY/appsuite/web-foundation/base-images/node_builder:latest
  stage: test
  script:
      - pnpm audit
  timeout: 5 minutes
  tags:
    - docker

unit tests:
  image: $CI_REGISTRY/appsuite/web-foundation/base-images/node_builder:latest
  stage: test
  script:
    - pnpm i -s
    - pnpm -r test
  timeout: 10 minutes
  tags:
    - build-hetzner

eslint:
  image: $CI_REGISTRY/appsuite/web-foundation/base-images/node_builder:latest
  stage: test
  script:
    - pnpm i -s
    - pnpm -r lint
  timeout: 10 minutes
  tags:
    - docker

e2e codeceptjs preview:
  image: $CI_REGISTRY_IMAGE/appsuite-codeceptjs:$CI_COMMIT_REF_SLUG
  tags:
    - e2e-hetzner
  variables:
    # codecept config
    REPORT_PATH: reports/$CI_PROJECT_PATH/$CI_COMMIT_REF_SLUG
    CONTEXT_ID: $CI_JOB_ID
    MIN_SUCCESS: 1
    MAX_RERUNS: 5
    # gitlab config
    KUBERNETES_CPU_REQUEST: 1
    KUBERNETES_CPU_LIMIT: 2
    KUBERNETES_MEMORY_REQUEST: 1.8G
    KUBERNETES_MEMORY_LIMIT: 1.8G
  retry:
    max: 2
    when:
      - api_failure
      - runner_system_failure
  timeout: 20 minutes
  script:
    - cd packages/appsuite-codeceptjs-e2e
    - pnpm i -P -s
    - mkdir -p ./output/
    - export LAUNCH_URL=https://core-ui-main.dev.oxui.de/
    - export MAX_RERUNS=5
    - pnpm e2e-rerun
  after_script:
    - |
      # Remove screenshots on successful run / Compress screenshots on failure
      if [ "$CI_JOB_STATUS" = "success" ]; then
        rm -rf ./output/*.png
      elif [ -n "$(ls -A ./output/*.png 2>/dev/null)" ] && command -v oxipng &> /dev/null; then
        oxipng ./output/*.png
      fi
  artifacts:
    when: always
    expire_in: 1 day
    paths:
      - packages/appsuite-codeceptjs-e2e/output/
    exclude:
      - packages/appsuite-codeceptjs-e2e/output/junit.xml
    reports:
      junit: packages/appsuite-codeceptjs-e2e/output/junit.xml
  rules:
    - when: always
  needs:
    - build appsuite-codeceptjs image
  stage: e2e