diff --git a/.circleci/README.md b/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.circleci/config.yml b/.circleci/config.yml index 270c3769c..f8f76c5ca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -103,15 +103,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -199,6 +190,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -527,53 +519,6 @@ jobs: path: *artifacts #;> DEPLOYMENT - #;< DEPS_UPDATE_PROVIDER_CI - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:40.36.8 - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - #;> DEPS_UPDATE_PROVIDER_CI - #;============================================================================ #; Vortex development section. Removed during Vortex installation/update. #;============================================================================ @@ -616,96 +561,6 @@ jobs: - store_artifacts: path: *artifacts - - #----------------------------------------------------------------------------- - # Launching and testing databases stored within Docker data image. - #----------------------------------------------------------------------------- - # - # Switching between "database in file" (DIF, mounted data volume) and - # "database-in-image" (DIDI, data volume is a part of the image) is - # done by providing the value of VORTEX_DB_IMAGE environment variable, - # which would be set in .env file for consumer projects. - # - # Also, the source of the database can be either file (downloaded from - # remote location) or a previous version of the data image. - # - # This means that there should be the following tests for Vortex - # database-in-image workflow functionality: - # 1. DB is file -> create data image -> cache data image and push it to registry -> build and test site - # 2. DB is image -> create data image -> cache data image and push it to registry -> build and test site - # - # Since we need to have "database" job generic for consumer sites and any - # logic is controlled within Vortex scripts, we have to create additional - # test jobs below and run them as a part of the CI system for Vortex itself. - # - # Job to test creation of the image from DB dump file when using - # VORTEX_DB_IMAGE workflow. - vortex-dev-didi-database-fi: - <<: *job-database - environment: - VORTEX_DOWNLOAD_DB_SOURCE: url - VORTEX_DOWNLOAD_DB_FORCE: 1 - # Use container image database storage despite that the file is coming - # from CURL - this is to make sure that image is exported into cache - # to be used between jobs. Note that in consumer project .env file would - # have VORTEX_DB_IMAGE variable set and this environment variable - # would not be required. - # - # Note that here and below we are using "destination" demo image - this - # is to allow updating of this image from CI tests without jeopardizing - # main demo image. - VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x - # Use a separate tag to make sure that pushed image does not affect - # other tests (pushing broken image as 'latest' would fail other tests). - VORTEX_DEPLOY_CONTAINER_REGISTRY_IMAGE_TAG: vortex-dev-didi-database-fi - # Also, use this job to test pushing of the DB image to the container - # registry to replicate what database-nightly job would do. - VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 - # Use custom cache key for this workflow to make sure that caches from - # the main workflow are separated from this one. - VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-fi - - # Job to test creation of the image from the previous version of the image - # when using database-in-image workflow. - vortex-dev-database-ii: - <<: *job-database - environment: - VORTEX_DOWNLOAD_DB_SOURCE: VORTEX_CONTAINER_REGISTRY - VORTEX_DOWNLOAD_DB_FORCE: 1 - VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x - VORTEX_DEPLOY_CONTAINER_REGISTRY_IMAGE_TAG: vortex-dev-database-ii - # Also, use this job to test pushing of the DB image to the container - # registry so replicate what database-nightly job would do. - VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 - # Use custom cache key for this workflow to make sure that caches from - # the main workflow are separated from this one. - VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-ii - - # Job to test build of the image from the previous stage of the image when - # using database-in-image workflow. Overwriting just the VORTEX_DB_IMAGE - # variable should change the storage mechanisms, but preserve application-level - # stack operation. - vortex-dev-didi-build-fi: - <<: *job_build - environment: - VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x:vortex-dev-didi-database-fi - # Use custom cache key for this workflow to make sure that caches from - # the main workflow are separated from this one. - VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-fi - # Migration database is always file-based and is not supported as an - # image. Skip migration in DIDI test jobs. - MIGRATION_SKIP: 1 - - vortex-dev-didi-build-ii: - <<: *job_build - environment: - VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x:vortex-dev-database-ii - # Use custom cache key for this workflow to make sure that caches from - # the main workflow are separated from this one. - VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-ii - # Migration database is always file-based and is not supported as an - # image. Skip migration in DIDI test jobs. - MIGRATION_SKIP: 1 #============================================================================= #;> VORTEX_DEV @@ -714,7 +569,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: @@ -769,7 +623,7 @@ workflows: #;============================================================================ #; #;< VORTEX_DEV - # Run functional tests for Vortex. + # Run functional tests for Vortex to assert CircleCI configuration is correct. # Note that these jobs must run within the "commit" workflow, because they # depend on the "build" job. # Run tests after 'build' job. @@ -779,22 +633,6 @@ workflows: filters: tags: only: /.*/ - - # Test workflow to test VORTEX_DB_IMAGE workflow for DB from file. - vortex-dev-didi-fi: - jobs: - - vortex-dev-didi-database-fi - - vortex-dev-didi-build-fi: - requires: - - vortex-dev-didi-database-fi - - # Test workflow to test VORTEX_DB_IMAGE workflow for DB from the container registry. - vortex-dev-didi-ii: - jobs: - - vortex-dev-database-ii - - vortex-dev-didi-build-ii: - requires: - - vortex-dev-database-ii #============================================================================= #;> VORTEX_DEV @@ -811,22 +649,3 @@ workflows: jobs: - database-nightly #;> !PROVISION_TYPE_PROFILE - - #;< DEPS_UPDATE_PROVIDER_CI - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies - #;> DEPS_UPDATE_PROVIDER_CI diff --git a/.circleci/update-dependencies.yml b/.circleci/update-dependencies.yml new file mode 100644 index 000000000..8bea21f03 --- /dev/null +++ b/.circleci/update-dependencies.yml @@ -0,0 +1,91 @@ +# CircleCI configuration file for automated dependency updates via Renovate. +# +# Scheduled pipelines: +# The `update-dependencies` workflow requires a schedule trigger configured in +# CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: update-dependencies +# - Config source: update-dependencies.yml +# - Branch: develop +# - Schedule: Every day at 11:05 and 23:05 UTC (or a custom schedule) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci +version: '2.1' + +################################################################################ +# PARAMETERS +################################################################################ + +parameters: + run_update_dependencies: + type: boolean + default: false + +################################################################################ +# JOBS +################################################################################ + +jobs: + # Self-hosted dependency updates. + # Add the following environment variables to the CircleCI project: + # - RENOVATE_TOKEN: GitHub access token. + # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. + # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. + # Variables provided below can be overridden in the CircleCI project settings. + update-dependencies: + docker: + - image: renovate/renovate:40.36.8 + environment: + RENOVATE_PLATFORM: 'github' + RENOVATE_AUTODISCOVER: false + RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' + RENOVATE_DEPENDENCY_DASHBOARD: false + RENOVATE_DRY_RUN: false + LOG_LEVEL: 'debug' + + steps: + - checkout + - run: + name: Check if RENOVATE_TOKEN is set + command: | + if [ -z "${RENOVATE_TOKEN}" ]; then + echo "RENOVATE_TOKEN is not set. Skipping job." + circleci-agent step halt + fi + + if [ -z "${RENOVATE_REPOSITORIES}" ]; then + echo "Renovate repository is not set. Skipping job." + circleci-agent step halt + fi + + if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then + echo "Renovate git author is not set. Skipping job." + circleci-agent step halt + fi + + - run: + name: Validate Renovate configuration + command: renovate-config-validator + + - run: + name: Run Renovate + command: renovate + +################################################################################ +# WORKFLOWS +################################################################################ + +workflows: + # Self-hosted Renovate workflow. + # Requires an "update-dependencies" schedule trigger configured in CircleCI UI. + update-dependencies: + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["update-dependencies", << pipeline.schedule.name >>] + jobs: + - update-dependencies + + update-dependencies-manual: + when: << pipeline.parameters.run_update_dependencies >> + jobs: + - update-dependencies diff --git a/.circleci/vortex-test-common.yml b/.circleci/vortex-test-common.yml new file mode 100644 index 000000000..f5bc22c8e --- /dev/null +++ b/.circleci/vortex-test-common.yml @@ -0,0 +1,481 @@ +# Auto-generated by .vortex/tests/generate-vortex-dev-circleci +# Source: .circleci/config.yml +# Do not edit directly. +version: '2.1' + +aliases: + #;< !PROVISION_TYPE_PROFILE + # SSH key fingerprint to download the database. + # Replace this key fingerprint with your own and remove this comment. + - &db_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + #;> !PROVISION_TYPE_PROFILE + + # SSH key fingerprint to deploy code. + # Replace this key fingerprint with your own and remove this comment. + - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + + #;< !PROVISION_TYPE_PROFILE + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + #;> !PROVISION_TYPE_PROFILE + + # Shared runner container configuration applied to each job. + - &runner_config + working_directory: &working_directory ~/project + environment: + #;< !PROVISION_TYPE_PROFILE + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + #;> !PROVISION_TYPE_PROFILE + VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint + docker: + # Using the 'runner' container where each job will be executed. + # This container has all the necessary tools to run a dockerized environment. + # https://github.com/drevops/ci-runner + # https://hub.docker.com/repository/docker/drevops/ci-runner/tags + - image: drevops/ci-runner:26.2.0@sha256:fe1561c2984a1023e84eebe6461056b0b55afedbb2512e6c2c7f19aca6beb398 + auth: + username: ${VORTEX_CONTAINER_REGISTRY_USER} + password: ${VORTEX_CONTAINER_REGISTRY_PASS} + environment: + # Set runner timezone via UI to ensure that executed operations use correct timestamps. + # https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + TZ: UTC + # Set runner terminal capabilities. + TERM: xterm-256color + # Disable strict host key checking for SSH connections. + VORTEX_SSH_DISABLE_STRICT_HOST_KEY_CHECKING: "1" + # Remove all SSH keys from the runner container. + VORTEX_SSH_REMOVE_ALL_KEYS: "1" + #;< !PROVISION_TYPE_PROFILE + # How often to refresh the cache of the DB dump. Refer to `date` command. + VORTEX_CI_DB_CACHE_TIMESTAMP: +%Y%m%d + # Use previous database caches on this branch as a fallback if the above cache + # does not match (for example, the cache is available only from the previous + # day). If "no" is set, the cache will be rebuilt from scratch. + VORTEX_CI_DB_CACHE_FALLBACK: "yes" + # Which branch to use as a source of DB caches. + VORTEX_CI_DB_CACHE_BRANCH: "develop" + #;> !PROVISION_TYPE_PROFILE + # Directory to store test results. + VORTEX_CI_TEST_RESULTS: &test_results /tmp/tests + # Directory to store test artifacts. + VORTEX_CI_ARTIFACTS: &artifacts /tmp/artifacts + # Directory to use for artifact deployments. + VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code + # Source code location for artifact deployments. + VORTEX_DEPLOY_ARTIFACT_ROOT: *working_directory + # Report file location for artifact deployments. + VORTEX_DEPLOY_ARTIFACT_LOG: /tmp/artifacts/deployment_log.txt + # Check only minimal stack requirements. + VORTEX_DOCTOR_CHECK_MINIMAL: 1 + # CI runner resource class. + # https://circleci.com/docs/2.0/configuration-reference/#resource_class + # Change to 'large' for faster builds. + resource_class: medium + + - &step_setup_remote_docker + setup_remote_docker: + # Docker Layer Caching allows to significantly speed up builds by caching + # images built during previous runs. + # https://circleci.com/docs/2.0/docker-layer-caching/ + docker_layer_caching: false + version: default + + - &step_process_codebase_for_ci + run: + name: Process codebase to run in CI + command: | + find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e ''/###/d'' {} && sed -i -e ''s/##//'' {}" + mkdir -p /tmp/workspace/code + + - &load_variables_from_dotenv + run: + name: Load environment variables from .env file + # Load variables from .env file, respecting existing values, and make them available for the next steps. + command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" + +################################################################################ +# JOBS +################################################################################ + +jobs: + # Base jobs as anchor sources (not referenced in any workflow). + database: &job-database + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *db_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + - *step_setup_remote_docker + + - run: + name: Create cache keys for database caching as files + command: | + echo "${VORTEX_CI_DB_CACHE_BRANCH}" | tee /tmp/db_cache_branch + echo "${VORTEX_CI_DB_CACHE_FALLBACK/no/${CIRCLE_BUILD_NUM}}" | tee /tmp/db_cache_fallback + date "${VORTEX_CI_DB_CACHE_TIMESTAMP}" | tee /tmp/db_cache_timestamp + echo "yes" | tee /tmp/db_cache_fallback_yes + + - restore_cache: + keys: + # Restore DB cache based on the cache strategy set by the cache keys below. + # https://circleci.com/docs/2.0/caching/#restoring-cache + # Change 'v1' to 'v2', 'v3' etc., commit and push to force cache reset. + # Lookup cache based on the default branch and a timestamp. Allows + # to use cache from the very first build on the day (sanitized database dump, for example). + - v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }} + # Fallback to caching by default branch name only. Allows to use + # cache from the branch build on the previous day. + - v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}- + + - run: + name: Download DB + command: VORTEX_DOWNLOAD_DB_SEMAPHORE=/tmp/download-db-success ./scripts/vortex/download-db.sh + no_output_timeout: 30m + + #;< MIGRATION + - run: + name: Download migration DB + command: VORTEX_VAR_PREFIX=VORTEX_DOWNLOAD_DB2 ./scripts/vortex/download-db.sh + no_output_timeout: 30m + #;> MIGRATION + + # Execute commands after database download script finished: if the + # DB dump was downloaded - build the site (to ensure that the DB dump + # is valid) and export the DB using selected method (to support + # "file-to-image" or "image-to-file" conversions). + # Note that configuration changes and the DB updates are not applied, so + # the database will be cached in the same state as downloaded. + - run: + name: Export DB after download + command: | + [ ! -f /tmp/download-db-success ] && echo "==> Database download semaphore file is missing. DB export will not proceed." && exit 0 + ./scripts/vortex/login-container-registry.sh + docker compose up --detach && sleep 15 + docker compose exec cli mkdir -p .data && docker compose cp -L .data/db.sql cli:/app/.data/db.sql || true + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "VORTEX_PROVISION_POST_OPERATIONS_SKIP=1 ./scripts/vortex/provision.sh" + grep -q ^VORTEX_DB_IMAGE .env && rm .data/db.sql || true + ./scripts/vortex/export-db.sh db.sql + no_output_timeout: 30m + + - save_cache: + # Save cache per default branch and the timestamp. + # The cache will not be saved if it already exists. + # Note that the cache fallback flag is enabled for this case in order + # to save cache even if the fallback is not used when restoring it. + key: v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + paths: + - /root/project/.data + + build: &job_build + <<: *runner_config + parallelism: 2 + steps: + - attach_workspace: + at: /tmp/workspace + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Validate Composer configuration + command: composer validate --strict || [ "${VORTEX_CI_COMPOSER_VALIDATE_IGNORE_FAILURE:-0}" -eq 1 ] + + #;< !PROVISION_TYPE_PROFILE + - run: + name: Set cache keys for database caching + command: | + echo "${VORTEX_CI_DB_CACHE_BRANCH}" | tee /tmp/db_cache_branch + echo "yes" | tee /tmp/db_cache_fallback_yes + echo "$(date ${VORTEX_CI_DB_CACHE_TIMESTAMP})" | tee /tmp/db_cache_timestamp + + - restore_cache: + keys: + # Use cached artifacts from previous builds of this branch. + # https://circleci.com/docs/2.0/caching/#restoring-cache + - v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - v26.2.0-db11-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- + #;> !PROVISION_TYPE_PROFILE + + - *step_setup_remote_docker + + - run: + name: Login to container registry + command: ./scripts/vortex/login-container-registry.sh + + - run: + name: Lint Dockerfiles with Hadolint + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + for file in $(find .docker -name 'Dockerfile' -o -name '*.dockerfile'); do + echo "Linting ${file}" && cat "${file}" | docker run --rm -i hadolint/hadolint || [ "${VORTEX_CI_HADOLINT_IGNORE_FAILURE:-0}" -eq 1 ] + done + + - run: + name: Lint Docker Compose files with DCLint + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker run --rm -v "${PWD}":/app zavoloklom/dclint:3.1.0 . || [ "${VORTEX_CI_DCLINT_IGNORE_FAILURE:-0}" -eq 1 ] + + - run: + name: Build stack + command: docker compose up --detach && docker builder prune --all --force + + - run: + name: Export built codebase + command: | + echo "${VORTEX_DEPLOY_TYPES:-}" | grep -vq "artifact" && exit 0 || true + mkdir -p "/tmp/workspace/code" + docker compose cp -L cli:"/app/." "/tmp/workspace/code" + du -sh "/tmp/workspace/code" + + - run: + name: Install development dependencies + command: | + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c " \ + if [ -n \"${PACKAGE_TOKEN:-}\" ]; then export COMPOSER_AUTH='{\"github-oauth\": {\"github.com\": \"${PACKAGE_TOKEN-}\"}}'; fi && \ + COMPOSER_MEMORY_LIMIT=-1 composer --ansi install --prefer-dist" + #;< TOOL_ESLINT_STYLELINT + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + #;> TOOL_ESLINT_STYLELINT + + - run: + name: Audit Composer packages + command: docker compose exec -T cli composer audit || [ "${VORTEX_CI_COMPOSER_AUDIT_IGNORE_FAILURE:-0}" -eq 1 ] + + - run: + name: Validate Composer configuration is normalized + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli composer normalize --dry-run || [ "${VORTEX_CI_COMPOSER_NORMALIZE_IGNORE_FAILURE:-0}" -eq 1 ] + + #;< TOOL_PHPCS + - run: + name: Lint code with PHPCS + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli vendor/bin/phpcs || [ "${VORTEX_CI_PHPCS_IGNORE_FAILURE:-0}" -eq 1 ] + #;> TOOL_PHPCS + + #;< TOOL_PHPSTAN + - run: + name: Lint code with PHPStan + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli vendor/bin/phpstan || [ "${VORTEX_CI_PHPSTAN_IGNORE_FAILURE:-0}" -eq 1 ] + #;> TOOL_PHPSTAN + + #;< TOOL_RECTOR + - run: + name: Lint code with Rector + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli vendor/bin/rector --dry-run || [ "${VORTEX_CI_RECTOR_IGNORE_FAILURE:-0}" -eq 1 ] + #;> TOOL_RECTOR + + #;< TOOL_PHPMD + - run: + name: Lint code with PHPMD + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml || [ "${VORTEX_CI_PHPMD_IGNORE_FAILURE:-0}" -eq 1 ] + #;> TOOL_PHPMD + + - run: + name: Lint code with Twig CS Fixer + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli vendor/bin/twig-cs-fixer || [ "${VORTEX_CI_TWIG_CS_FIXER_IGNORE_FAILURE:-0}" -eq 1 ] + + #;< TOOL_BEHAT + - run: + name: Lint code with Gherkin Lint + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features || [ "${VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE:-0}" -eq 1 ] + #;> TOOL_BEHAT + + #;< TOOL_ESLINT_STYLELINT + - run: + name: Lint module code with NodeJS linters + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli bash -c "yarn run lint" || [ "${VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE:-0}" -eq 1 ] + #;> TOOL_ESLINT_STYLELINT + + #;< DRUPAL_THEME + - run: + name: Lint theme code with NodeJS linters + command: | + { [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ]; } || [ "${VORTEX_FRONTEND_BUILD_SKIP:-0}" -eq 1 ] && exit 0 + docker compose exec -T cli bash -c "yarn --cwd=\${WEBROOT}/themes/custom/\${DRUPAL_THEME} run lint" || [ "${VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE:-0}" -eq 1 ] + #;> DRUPAL_THEME + + - run: + name: Provision site + command: | + if [ -f .data/db.sql ]; then + docker compose exec cli mkdir -p .data + docker compose cp -L .data/db.sql cli:/app/.data/db.sql + fi + #;< MIGRATION + if [ -f ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" ]; then + docker compose exec -T cli mkdir -p .data + docker compose cp -L ".data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" cli:"/app/.data/${VORTEX_DOWNLOAD_DB2_FILE:-db2.sql}" + fi + #;> MIGRATION + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh + no_output_timeout: 30m + + #;< TOOL_PHPUNIT + - run: + name: Test with PHPUnit + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + docker compose exec -T cli vendor/bin/phpunit || [ "${VORTEX_CI_PHPUNIT_IGNORE_FAILURE:-0}" -eq 1 ] + + - run: + name: Process PHPUnit logs and coverage + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + mkdir -p "${VORTEX_CI_ARTIFACTS}" + if docker compose ps --services --filter "status=running" | grep -q cli && docker compose exec cli test -d /app/.logs; then + docker compose cp cli:/app/.logs/. "${VORTEX_CI_ARTIFACTS}/" + fi + + - run: + name: Check code coverage threshold + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + RATE=$(grep -om1 'line-rate="[0-9.]*"' /tmp/artifacts/coverage/phpunit/cobertura.xml | tr -cd '0-9.') + PERCENT=$(awk "BEGIN {printf \"%.2f\", $RATE*100}") + echo "Coverage: $PERCENT% (threshold: ${VORTEX_CI_CODE_COVERAGE_THRESHOLD:-90}%)" + if [ "${PERCENT//./}" -lt "$((${VORTEX_CI_CODE_COVERAGE_THRESHOLD:-90}*100))" ]; then + echo "FAIL: coverage too low" + exit 1 + fi + + - run: + name: Post coverage summary as PR comment + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + [ "${VORTEX_CI_CODE_COVERAGE_PR_COMMENT_SKIP:-0}" = "1" ] && exit 0 + [ -z "${CIRCLE_PULL_REQUEST}" ] && exit 0 + [ -z "${GITHUB_TOKEN}" ] && exit 0 + COVERAGE_CONTENT=$(sed '/./,$!d' /tmp/artifacts/coverage/phpunit/coverage.txt) + PR_NUMBER=$(echo "${CIRCLE_PULL_REQUEST}" | cut -d'/' -f 7) + REPO_SLUG="${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}" + curl -s -X POST \ + -H "Authorization: token ${GITHUB_TOKEN}" \ + -H "Accept: application/vnd.github.v3+json" \ + "https://api.github.com/repos/${REPO_SLUG}/issues/${PR_NUMBER}/comments" \ + -d "$(jq -n --arg body "\`\`\` + ${COVERAGE_CONTENT} + \`\`\`" '{body: $body}')" + + - run: + name: Upload code coverage reports to Codecov + command: | + [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ] && [ "${CIRCLE_NODE_INDEX:-0}" -ne 0 ] && exit 0 + if [ -n "${CODECOV_TOKEN}" ] && [ -d /tmp/artifacts/coverage ] && ! echo "${CIRCLE_BRANCH}" | grep -q '^deps/'; then + codecov -Z -s /tmp/artifacts/coverage; + fi + #;> TOOL_PHPUNIT + + #;< TOOL_BEHAT + - run: + name: Test with Behat + command: | + if [ "${CIRCLE_NODE_TOTAL:-1}" -gt 1 ]; then export VORTEX_CI_BEHAT_PROFILE="${VORTEX_CI_BEHAT_PROFILE:-p${CIRCLE_NODE_INDEX}}"; fi + echo "Running with ${VORTEX_CI_BEHAT_PROFILE:-default} profile" + docker compose exec -T cli php -d memory_limit=-1 vendor/bin/behat --colors --strict --profile="${VORTEX_CI_BEHAT_PROFILE:-default}" || \ + docker compose exec -T cli php -d memory_limit=-1 vendor/bin/behat --colors --strict --rerun --profile="${VORTEX_CI_BEHAT_PROFILE:-default}" || \ + [ "${VORTEX_CI_BEHAT_IGNORE_FAILURE:-0}" -eq 1 ] + no_output_timeout: 30m + #;> TOOL_BEHAT + + - run: + name: Process test logs and artifacts + command: | + mkdir -p "${VORTEX_CI_TEST_RESULTS}" "${VORTEX_CI_ARTIFACTS}" + if docker compose ps --services --filter "status=running" | grep -q cli && docker compose exec cli test -d /app/.logs; then + docker compose cp cli:/app/.logs/. "${VORTEX_CI_ARTIFACTS}/" + if docker compose exec -T cli sh -c '[ -d /app/.logs/test_results/ ]'; then + docker compose cp cli:/app/.logs/test_results/. "${VORTEX_CI_TEST_RESULTS}/" + fi + fi + when: always + + - store_test_results: + path: *test_results + + - store_artifacts: + path: *artifacts + + - persist_to_workspace: + root: /tmp/workspace + paths: + - code + + # DIDI-FI variant jobs + vortex-dev-didi-database-fi: + <<: *job-database + environment: + VORTEX_DOWNLOAD_DB_SOURCE: url + VORTEX_DOWNLOAD_DB_FORCE: 1 + VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x + VORTEX_DEPLOY_CONTAINER_REGISTRY_IMAGE_TAG: vortex-dev-didi-database-fi + VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 + VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-fi + + vortex-dev-didi-build-fi: + <<: *job_build + environment: + VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x:vortex-dev-didi-database-fi + VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-fi + MIGRATION_SKIP: 1 + + # DIDI-II variant jobs + vortex-dev-database-ii: + <<: *job-database + environment: + VORTEX_DOWNLOAD_DB_SOURCE: VORTEX_CONTAINER_REGISTRY + VORTEX_DOWNLOAD_DB_FORCE: 1 + VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x + VORTEX_DEPLOY_CONTAINER_REGISTRY_IMAGE_TAG: vortex-dev-database-ii + VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 + VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-ii + + vortex-dev-didi-build-ii: + <<: *job_build + environment: + VORTEX_DB_IMAGE: drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x:vortex-dev-database-ii + VORTEX_CI_DB_CACHE_BRANCH: vortex-dev-didi-ii + MIGRATION_SKIP: 1 + +################################################################################ +# WORKFLOWS +################################################################################ + +workflows: + vortex-dev-didi-fi: + jobs: + - vortex-dev-didi-database-fi + - vortex-dev-didi-build-fi: + requires: + - vortex-dev-didi-database-fi + + vortex-dev-didi-ii: + jobs: + - vortex-dev-database-ii + - vortex-dev-didi-build-ii: + requires: + - vortex-dev-database-ii diff --git a/.github/workflows/vortex-test-common.yml b/.github/workflows/vortex-test-common.yml index a56d4a66a..4147467be 100644 --- a/.github/workflows/vortex-test-common.yml +++ b/.github/workflows/vortex-test-common.yml @@ -77,6 +77,7 @@ jobs: ./tests/lint.scripts.sh ./tests/lint.dockerfiles.sh ./tests/lint.markdown.sh + ./tests/lint.ci.sh working-directory: .vortex # Special case to validate Renovate configuration with the same action diff --git a/.vortex/.ahoy.yml b/.vortex/.ahoy.yml index 622ae9891..adfa98204 100644 --- a/.vortex/.ahoy.yml +++ b/.vortex/.ahoy.yml @@ -48,6 +48,7 @@ commands: ahoy lint-dockerfiles ahoy lint-docs ahoy lint-markdown + ahoy lint-ci lint-fix: name: Fix linting issues in Vortex project. @@ -56,6 +57,13 @@ commands: ahoy lint-tests-fix ahoy lint-docs-fix ahoy lint-markdown-fix + ahoy lint-ci-fix + + lint-ci: + cmd: ./tests/lint.ci.sh + + lint-ci-fix: + cmd: ./tests/lint.ci.sh --fix lint-installer: cmd: composer --working-dir installer lint diff --git a/.vortex/docs/content/continuous-integration/circleci.mdx b/.vortex/docs/content/continuous-integration/circleci.mdx index a3bdc4424..173c4de25 100644 --- a/.vortex/docs/content/continuous-integration/circleci.mdx +++ b/.vortex/docs/content/continuous-integration/circleci.mdx @@ -28,9 +28,9 @@ Before you begin, ensure you have: ### 1. Enable the project [Log in to CircleCI](https://app.circleci.com/) and add your repository as a new -project. CircleCI will connect to your GitHub account, detect the -[`.circleci/config.yml`](https://github.com/drevops/vortex/blob/main/.circleci/config.yml) -configuration file, and start running builds automatically when you push code. +project. CircleCI will connect to your GitHub account, detect the configuration +files in the [`.circleci/`](https://github.com/drevops/vortex/blob/main/.circleci/) +directory, and start running builds automatically when you push code. ### 2. Add SSH key for database download @@ -101,6 +101,37 @@ Add the following variables in **Project Settings → Environment Variables**: | `VORTEX_ACQUIA_KEY` | Acquia Cloud API key | | `VORTEX_ACQUIA_SECRET` | Acquia Cloud API secret | +### 6. Configure schedule triggers + +If you use the self-hosted Renovate workflow for automatic dependency updates, +the `update-dependencies.yml` pipeline requires a schedule trigger configured +in the CircleCI UI. Without this trigger, the workflow will not run. + +Go to **Project Settings → Triggers** and create the following scheduled +trigger: + +| Setting | Value | +|---------------|------------------------------------| +| Trigger name | `update-dependencies` | +| Config source | `update-dependencies.yml` | +| Branch | `develop` | +| Schedule | Every day at 11:05 and 23:05 UTC | + +:::note + +The trigger name `update-dependencies` must match exactly - it is referenced +in the workflow `when` condition in the configuration file. + +::: + +:::tip + +The nightly database schedule is defined directly in `.circleci/config.yml` +using the `nightly_db_schedule` YAML anchor. No UI configuration is needed +for this schedule. + +::: + ## Maintenance ### Update deployment branches @@ -119,6 +150,7 @@ filters: The nightly database job caches a fresh database dump for faster builds the next day. To change when this runs, update the `nightly_db_schedule` YAML anchor +in `.circleci/config.yml` ([cron format](https://crontab.guru/#0_18_*_*_*), UTC timezone): ```yaml diff --git a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php index a2b5a88f4..ef5973683 100644 --- a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php @@ -86,12 +86,14 @@ public function process(): void { File::removeTokenAsync('DEPS_UPDATE_PROVIDER_CI'); File::replaceContentInFile($t . '/renovate.json', '/\s*"ignorePaths":\s*\[\s*"[^"]*"\s*\],?\n/s', "\n"); File::remove($t . '/.github/workflows/update-dependencies.yml'); + File::remove($t . '/.circleci/update-dependencies.yml'); } else { File::removeTokenAsync('DEPS_UPDATE_PROVIDER_APP'); File::removeTokenAsync('DEPS_UPDATE_PROVIDER_CI'); File::removeTokenAsync('DEPS_UPDATE_PROVIDER'); File::remove($t . '/renovate.json'); + File::remove($t . '/.circleci/update-dependencies.yml'); } } diff --git a/.vortex/installer/src/Prompts/Handlers/Internal.php b/.vortex/installer/src/Prompts/Handlers/Internal.php index 6b5dfe8a9..a37c7aee3 100644 --- a/.vortex/installer/src/Prompts/Handlers/Internal.php +++ b/.vortex/installer/src/Prompts/Handlers/Internal.php @@ -88,6 +88,14 @@ public function process(): void { File::remove($t . 'LICENSE'); File::remove($t . 'SECURITY.md'); + // Remove Vortex internal CircleCI configs. + $files = glob($t . '/.circleci/vortex-*.yml'); + if ($files) { + foreach ($files as $file) { + @unlink($file); + } + } + // Remove Vortex internal GHAs. $files = glob($t . '/.github/workflows/vortex-*.yml'); if ($files) { diff --git a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml index cfc64fbaa..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -482,7 +474,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml index cfc64fbaa..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -482,7 +474,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml index 1e081be9e..12d51b334 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -424,7 +416,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml index de599d289..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -477,57 +469,11 @@ jobs: - store_artifacts: path: *artifacts - # Self-hosted dependency updates. - # Add the following environment variables to the CircleCI project: - # - RENOVATE_TOKEN: GitHub access token. - # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. - # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. - # Variables provided below can be overridden in the CircleCI project settings. - update-dependencies: - docker: - - image: renovate/renovate:__VERSION__ - environment: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' - RENOVATE_DEPENDENCY_DASHBOARD: false - RENOVATE_DRY_RUN: false - LOG_LEVEL: 'debug' - - steps: - - checkout - - run: - name: Check if RENOVATE_TOKEN is set - command: | - if [ -z "${RENOVATE_TOKEN}" ]; then - echo "RENOVATE_TOKEN is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_REPOSITORIES}" ]; then - echo "Renovate repository is not set. Skipping job." - circleci-agent step halt - fi - - if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then - echo "Renovate git author is not set. Skipping job." - circleci-agent step halt - fi - - - run: - name: Validate Renovate configuration - command: renovate-config-validator - - - run: - name: Run Renovate - command: renovate - ################################################################################ # WORKFLOWS ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: @@ -582,20 +528,3 @@ workflows: - develop jobs: - database-nightly - - # Self-hosted Renovate workflow. - update-dependencies: - triggers: - - schedule: - cron: "5 11,23 * * *" - filters: - branches: - only: - - develop - jobs: - - update-dependencies - - update-dependencies-manual: - when: << pipeline.parameters.run_update_dependencies >> - jobs: - - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/update-dependencies.yml b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/update-dependencies.yml new file mode 100644 index 000000000..262ec832b --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/update-dependencies.yml @@ -0,0 +1,91 @@ +# CircleCI configuration file for automated dependency updates via Renovate. +# +# Scheduled pipelines: +# The `update-dependencies` workflow requires a schedule trigger configured in +# CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: update-dependencies +# - Config source: update-dependencies.yml +# - Branch: develop +# - Schedule: Every day at 11:05 and 23:05 UTC (or a custom schedule) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci +version: '2.1' + +################################################################################ +# PARAMETERS +################################################################################ + +parameters: + run_update_dependencies: + type: boolean + default: false + +################################################################################ +# JOBS +################################################################################ + +jobs: + # Self-hosted dependency updates. + # Add the following environment variables to the CircleCI project: + # - RENOVATE_TOKEN: GitHub access token. + # - RENOVATE_REPOSITORIES: Repository to run Renovate on as `vendor/repository`. + # - RENOVATE_GIT_AUTHOR: Author for Renovate commits as `Name `. + # Variables provided below can be overridden in the CircleCI project settings. + update-dependencies: + docker: + - image: renovate/renovate:__VERSION__ + environment: + RENOVATE_PLATFORM: 'github' + RENOVATE_AUTODISCOVER: false + RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by CircleCI' + RENOVATE_DEPENDENCY_DASHBOARD: false + RENOVATE_DRY_RUN: false + LOG_LEVEL: 'debug' + + steps: + - checkout + - run: + name: Check if RENOVATE_TOKEN is set + command: | + if [ -z "${RENOVATE_TOKEN}" ]; then + echo "RENOVATE_TOKEN is not set. Skipping job." + circleci-agent step halt + fi + + if [ -z "${RENOVATE_REPOSITORIES}" ]; then + echo "Renovate repository is not set. Skipping job." + circleci-agent step halt + fi + + if [ -z "${RENOVATE_GIT_AUTHOR}" ]; then + echo "Renovate git author is not set. Skipping job." + circleci-agent step halt + fi + + - run: + name: Validate Renovate configuration + command: renovate-config-validator + + - run: + name: Run Renovate + command: renovate + +################################################################################ +# WORKFLOWS +################################################################################ + +workflows: + # Self-hosted Renovate workflow. + # Requires an "update-dependencies" schedule trigger configured in CircleCI UI. + update-dependencies: + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["update-dependencies", << pipeline.schedule.name >>] + jobs: + - update-dependencies + + update-dependencies-manual: + when: << pipeline.parameters.run_update_dependencies >> + jobs: + - update-dependencies diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml index cfc64fbaa..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -482,7 +474,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml index 0dce71cdd..a0ba1a34a 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -185,6 +176,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -491,7 +483,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml index cfc64fbaa..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -482,7 +474,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml index bbf7f0a95..eb8de42e1 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -458,7 +450,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml index 45ebcf0e3..6b292634e 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -413,7 +405,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml index 062cbc914..90082d00a 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -475,7 +467,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml index 0193e1369..3b8f81204 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -469,7 +461,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml index 4465a1da0..08cda9e0e 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -466,7 +458,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml index 062cbc914..90082d00a 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -475,7 +467,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml index 230ef7345..e18ac1dc9 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -476,7 +468,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml index 217c98e64..9fd82b7c8 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -476,7 +468,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml index a038fe64a..89c775a00 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -476,7 +468,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml index 7bc050b3e..05a2b68b5 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -429,7 +421,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml index 99dddf57d..bf6b2ad1d 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -476,7 +468,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/README.md b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/README.md deleted file mode 100644 index 533a875e9..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/README.md +++ /dev/null @@ -1,2 +0,0 @@ -You may add custom scripts, which would run only in CI, to this directory and -reference them from `config.yml` file. diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml index cfc64fbaa..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml @@ -1,4 +1,4 @@ -# CircleCI 2.0 configuration file. +# CircleCI configuration file for building, testing, and deploying. # # This configuration file uses the "docker" executor to run the Docker stack. # @@ -92,15 +92,6 @@ aliases: # Load variables from .env file, respecting existing values, and make them available for the next steps. command: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && export -p >> "$BASH_ENV" -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - ################################################################################ # JOBS ################################################################################ @@ -180,6 +171,7 @@ jobs: - /root/project/.data # Nightly database job. Same as above, but with additional variables set. + # Triggered by the "nightly-db" schedule configured in CircleCI UI. database-nightly: <<: *job-database environment: @@ -482,7 +474,6 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: jobs: diff --git a/.vortex/tests/CLAUDE.md b/.vortex/tests/CLAUDE.md index 0e55d2330..8a1b5a872 100644 --- a/.vortex/tests/CLAUDE.md +++ b/.vortex/tests/CLAUDE.md @@ -15,6 +15,18 @@ cd .vortex ahoy install # Install dependencies (run once) ``` +## Commands + +```bash +cd .vortex/installer + +composer install # Install dependencies +composer lint # Run phpcs, phpstan, rector --dry-run +composer lint-fix # Run rector, phpcbf +composer test # Run tests (no coverage) + +``` + ## BATS - Unit Testing Shell Scripts **Use when**: Changed a shell script in `scripts/vortex/*.sh` or provision logic. diff --git a/.vortex/tests/generate-vortex-dev-circleci b/.vortex/tests/generate-vortex-dev-circleci new file mode 100755 index 000000000..6f8c5ab78 --- /dev/null +++ b/.vortex/tests/generate-vortex-dev-circleci @@ -0,0 +1,224 @@ +#!/usr/bin/env php + 'url', + 'VORTEX_DOWNLOAD_DB_FORCE' => 1, + 'VORTEX_DB_IMAGE' => 'drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x', + 'VORTEX_DEPLOY_CONTAINER_REGISTRY_IMAGE_TAG' => 'vortex-dev-didi-database-fi', + 'VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED' => 1, + 'VORTEX_CI_DB_CACHE_BRANCH' => 'vortex-dev-didi-fi', + ]), + '', + build_variant_job('vortex-dev-didi-build-fi', '*job_build', [ + 'VORTEX_DB_IMAGE' => 'drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x:vortex-dev-didi-database-fi', + 'VORTEX_CI_DB_CACHE_BRANCH' => 'vortex-dev-didi-fi', + 'MIGRATION_SKIP' => 1, + ]), + '', + ' # DIDI-II variant jobs', + build_variant_job('vortex-dev-database-ii', '*job-database', [ + 'VORTEX_DOWNLOAD_DB_SOURCE' => 'VORTEX_CONTAINER_REGISTRY', + 'VORTEX_DOWNLOAD_DB_FORCE' => 1, + 'VORTEX_DB_IMAGE' => 'drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x', + 'VORTEX_DEPLOY_CONTAINER_REGISTRY_IMAGE_TAG' => 'vortex-dev-database-ii', + 'VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED' => 1, + 'VORTEX_CI_DB_CACHE_BRANCH' => 'vortex-dev-didi-ii', + ]), + '', + build_variant_job('vortex-dev-didi-build-ii', '*job_build', [ + 'VORTEX_DB_IMAGE' => 'drevops/vortex-dev-mariadb-drupal-data-demo-destination-11.x:vortex-dev-database-ii', + 'VORTEX_CI_DB_CACHE_BRANCH' => 'vortex-dev-didi-ii', + 'MIGRATION_SKIP' => 1, + ]), + '', + '################################################################################', + '# WORKFLOWS', + '################################################################################', + '', + 'workflows:', + ' vortex-dev-didi-fi:', + ' jobs:', + ' - vortex-dev-didi-database-fi', + ' - vortex-dev-didi-build-fi:', + ' requires:', + ' - vortex-dev-didi-database-fi', + '', + ' vortex-dev-didi-ii:', + ' jobs:', + ' - vortex-dev-database-ii', + ' - vortex-dev-didi-build-ii:', + ' requires:', + ' - vortex-dev-database-ii', + '', +]); + +if ($check_mode) { + if (!file_exists($output_file)) { + fwrite(STDERR, sprintf("Error: %s does not exist. Run without --check to generate.\n", $output_file)); + exit(1); + } + + $existing = file_get_contents($output_file); + if ($existing !== $output) { + fwrite(STDERR, sprintf("Error: %s is out of date. Run 'php .vortex/tests/generate-vortex-dev-circleci' to update.\n", $output_file)); + exit(1); + } + + echo sprintf("OK: %s is up to date.\n", $output_file); + exit(0); +} + +file_put_contents($output_file, $output); +echo sprintf("Generated: %s\n", $output_file); + +/** + * Extract the aliases section from the source lines. + * + * @param list $lines + * Source file lines. + */ +function extract_aliases(array $lines): string { + $start = NULL; + $end = count($lines); + + for ($i = 0, $count = count($lines); $i < $count; $i++) { + $line = $lines[$i]; + if ($start === NULL) { + if (preg_match('/^aliases:/', $line)) { + $start = $i; + } + continue; + } + + // Stop at first non-empty, non-indented line after aliases. + if ($line !== '' && !preg_match('/^\s/', $line)) { + $end = $i; + break; + } + } + + if ($start === NULL) { + fwrite(STDERR, "Error: Could not find aliases section.\n"); + exit(1); + } + + $result = array_slice($lines, $start, $end - $start); + + // Trim trailing blank lines. + while (!empty($result) && trim(end($result)) === '') { + array_pop($result); + } + + return implode("\n", $result); +} + +/** + * Extract a job block from the source lines. + * + * @param list $lines + * Source file lines. + */ +function extract_job(array $lines, string $pattern): string { + $start = NULL; + + for ($i = 0, $count = count($lines); $i < $count; $i++) { + if (preg_match($pattern, $lines[$i])) { + $start = $i; + break; + } + } + + if ($start === NULL) { + fwrite(STDERR, sprintf("Error: Could not find job matching %s.\n", $pattern)); + exit(1); + } + + $result = [$lines[$start]]; + + for ($i = $start + 1, $count = count($lines); $i < $count; $i++) { + $line = $lines[$i]; + // Stop at the next block at job level (2-space indent) or top level. + if ($line !== '' && (preg_match('/^ \S/', $line) || preg_match('/^\S/', $line))) { + break; + } + $result[] = $line; + } + + // Trim trailing blank lines. + while (!empty($result) && trim(end($result)) === '') { + array_pop($result); + } + + return implode("\n", $result); +} + +/** + * Build a DIDI variant job YAML block. + * + * @param array $env + * Environment variable overrides. + */ +function build_variant_job(string $name, string $anchor, array $env): string { + $lines = [ + sprintf(' %s:', $name), + sprintf(' <<: %s', $anchor), + ' environment:', + ]; + + foreach ($env as $key => $value) { + $lines[] = sprintf(' %s: %s', $key, $value); + } + + return implode("\n", $lines); +} diff --git a/.vortex/tests/lint.ci.sh b/.vortex/tests/lint.ci.sh new file mode 100755 index 000000000..4e3f74357 --- /dev/null +++ b/.vortex/tests/lint.ci.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +## +# Lint Vortex CI configurations. +# +# LCOV_EXCL_START + +set -eu +[ "${VORTEX_DEBUG-}" = "1" ] && set -x + +ROOT_DIR="$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)")" + +FIX=0 +for arg in "$@"; do + [ "${arg}" = "--fix" ] && FIX=1 +done + +echo "==> Linting CI configurations in ${ROOT_DIR}." + +if [ "${FIX}" = "1" ]; then + echo "Generating .circleci/vortex-test-common.yml." + php "${ROOT_DIR}/.vortex/tests/generate-vortex-dev-circleci" +else + echo "Checking that .circleci/vortex-test-common.yml is up to date." + php "${ROOT_DIR}/.vortex/tests/generate-vortex-dev-circleci" --check +fi diff --git a/.vortex/tests/phpcs.xml b/.vortex/tests/phpcs.xml index d49f8745b..05ec37262 100644 --- a/.vortex/tests/phpcs.xml +++ b/.vortex/tests/phpcs.xml @@ -19,6 +19,7 @@ phpunit + generate-vortex-dev-circleci @@ -27,6 +28,11 @@ *.test + + + generate-vortex-dev-circleci + + *.Test\.php diff --git a/.vortex/tests/phpstan.neon b/.vortex/tests/phpstan.neon index bcd1bce48..1624cc22d 100644 --- a/.vortex/tests/phpstan.neon +++ b/.vortex/tests/phpstan.neon @@ -8,6 +8,7 @@ parameters: paths: - phpunit + - generate-vortex-dev-circleci excludePaths: - vendor/*