diff --git a/README.md b/README.md index dc0edf5fa717271ec4fe1be7f33889d856695fed..7d5649e9a11699f18ef38aba312bd5bc35853d8e 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,23 @@ This project contains the common CI templates and scripts for Hive and Hive-rela ## Job templates - [docker_image_jobs.gitlab-ci.yml](templates/docker_image_jobs.gitlab-ci.yml) - templates for managing Docker images +- [npm_projects.gitlab-ci.yml](templates/npm_projects.gitlab-ci.yml) - templates for NPM package building and publishing - [test_jobs.gitlab-ci.yml](templates/test_jobs.gitlab-ci.yml) - templates for running tests +## Pipeline Skip Variables + +The following variables can be set to `"true"` when running a pipeline to skip certain jobs: + +| Variable | Effect | +|----------|--------| +| `QUICK_TEST` | Skip all production deployments and dev package deployments | +| `SKIP_PRODUCTION_DEPLOY` | Skip all production deployments (npm to npmjs.org, Docker to Docker Hub) | +| `SKIP_DEV_DEPLOY` | Skip dev package deployments (npm to internal GitLab registry) | +| `SKIP_NPM_PUBLISH` | Skip all npm publishing jobs (both dev and production) | +| `SKIP_DOCKER_PUBLISH` | Skip Docker Hub publishing jobs | + +These variables are checked in the template rules, so projects that extend templates without overriding rules automatically get this behavior. + ## Example jobs The GitLab CI configuration for this repository contains example jobs based on the templates defined in it. On top of that the Docker images are built by jobs also based on said templates. diff --git a/templates/docker_image_jobs.gitlab-ci.yml b/templates/docker_image_jobs.gitlab-ci.yml index 771f3adcbc7ce7250926cc523d7b4d305009ca44..351bcf3bea2deebd779c6c0f7ad85e500921b350 100644 --- a/templates/docker_image_jobs.gitlab-ci.yml +++ b/templates/docker_image_jobs.gitlab-ci.yml @@ -63,6 +63,15 @@ include: tags: - public-runner-docker +# Template for publishing Docker images to Docker Hub (PUBLIC production registry). +# +# IMPORTANT: This template publishes to the PUBLIC Docker Hub registry! +# By default, only runs on protected tags. +# +# Skip variables (set to "true" to skip this job): +# - QUICK_TEST: Skip during quick test pipelines +# - SKIP_PRODUCTION_DEPLOY: Skip all production deployments +# - SKIP_DOCKER_PUBLISH: Skip all Docker Hub publishing jobs .publish_docker_image_template: extends: .docker_image_builder_job_template needs: [] @@ -70,6 +79,12 @@ include: DOCKER_HUB_USER: $DOCKER_HUB_USER DOCKER_HUB_PASSWORD: $DOCKER_HUB_PASSWORD rules: + - if: $QUICK_TEST == "true" + when: never + - if: $SKIP_PRODUCTION_DEPLOY == "true" + when: never + - if: $SKIP_DOCKER_PUBLISH == "true" + when: never - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"' when: on_success - when: never diff --git a/templates/npm_projects.gitlab-ci.yml b/templates/npm_projects.gitlab-ci.yml index d2a19dd748f68e5b458cebd47dc2ef427e61275e..066e2222b09c11103b76561ea213c5b237f60107 100644 --- a/templates/npm_projects.gitlab-ci.yml +++ b/templates/npm_projects.gitlab-ci.yml @@ -181,8 +181,13 @@ variables: expire_in: 1 week -# Base definition for NPM package publishing job. +# Base definition for NPM package publishing job (to internal GitLab registry). # The derived job, should have in its dependencies a final job performing a npm-build (derived from `.npm_build_template`) +# +# Skip variables (set to "true" to skip this job): +# - QUICK_TEST: Skip during quick test pipelines +# - SKIP_DEV_DEPLOY: Skip dev package deployments specifically +# - SKIP_NPM_PUBLISH: Skip all npm publishing jobs .npm_deploy_package_template: extends: .npm_process_built_package_tarball variables: @@ -200,8 +205,25 @@ variables: - /home/emscripten/scripts/npm_publish.sh "${SOURCE_DIR}" "${NPM_REGISTRY_URL}" "${NPM_PACKAGE_SCOPE}" "${NPM_PUBLISH_TOKEN}" - echo -e "\e[0Ksection_end:$(date +%s):publishing\r\e[0KDone" -# Base definition for NPM package publishing job to the registry.npmjs.org. + rules: + - if: $QUICK_TEST == "true" + when: never + - if: $SKIP_DEV_DEPLOY == "true" + when: never + - if: $SKIP_NPM_PUBLISH == "true" + when: never + - when: on_success + +# Base definition for NPM package publishing job to the registry.npmjs.org (PUBLIC production registry). # The derived job, should have in its dependencies a final job performing a npm-build (derived from `.npm_build_template`) +# +# IMPORTANT: This template publishes to the PUBLIC npmjs.org registry! +# By default, only runs on protected tags with manual trigger. +# +# Skip variables (set to "true" to skip this job): +# - QUICK_TEST: Skip during quick test pipelines +# - SKIP_PRODUCTION_DEPLOY: Skip all production deployments +# - SKIP_NPM_PUBLISH: Skip all npm publishing jobs .registry_npmjs_org_deploy_package_template: extends: .npm_process_built_package_tarball variables: @@ -222,6 +244,12 @@ variables: - echo -e "\e[0Ksection_end:$(date +%s):publishing\r\e[0KDone" rules: + - if: $QUICK_TEST == "true" + when: never + - if: $SKIP_PRODUCTION_DEPLOY == "true" + when: never + - if: $SKIP_NPM_PUBLISH == "true" + when: never - if: '$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED == "true"' when: manual allow_failure: true