From 42730f33c58665359fb7a1f85e4fb10214cc4b0c Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Wed, 25 Feb 2026 14:32:17 +1100 Subject: [PATCH 1/3] Split CircleCI configuration into multiple files. --- .circleci/README.md | 2 - .../build-test-deploy.yml | 227 +++-- .circleci/config.yml | 832 ------------------ .circleci/update-dependencies.yml | 91 ++ .circleci/vortex-test-common.yml | 476 ++++++++++ .github/workflows/vortex-test-common.yml | 1 + .vortex/.ahoy.yml | 8 + .../continuous-integration/circleci.mdx | 59 +- .../src/Prompts/Handlers/CiProvider.php | 2 +- .../Handlers/DependencyUpdatesProvider.php | 5 +- .../src/Prompts/Handlers/Internal.php | 8 + .../ciprovider_circleci/.circleci/README.md | 2 - .../.circleci/build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../.circleci/build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../.circleci/build-test-deploy.yml} | 40 +- .../.circleci/update-dependencies.yml | 91 ++ .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../.circleci/build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../timezone_circleci/.circleci/README.md | 2 - .../.circleci/build-test-deploy.yml | 537 +++++++++++ .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../.circleci/README.md | 2 - .../{config.yml => build-test-deploy.yml} | 40 +- .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/README.md | 2 - .../.circleci/build-test-deploy.yml | 537 +++++++++++ .../.circleci/config.yml | 539 ------------ .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../Handlers/CiProviderHandlerProcessTest.php | 4 +- .../Handlers/MigrationHandlerProcessTest.php | 4 +- .../Handlers/TimezoneHandlerProcessTest.php | 4 +- .../CiProviderHandlerDiscoveryTest.php | 2 +- ...ncyUpdatesProviderHandlerDiscoveryTest.php | 2 +- .vortex/tests/CLAUDE.md | 12 + .vortex/tests/generate-vortex-dev-circleci | 224 +++++ .vortex/tests/lint.ci.sh | 25 + .vortex/tests/phpcs.xml | 6 + .vortex/tests/phpstan.neon | 1 + .vortex/tests/phpunit/Traits/SutTrait.php | 6 +- tests/phpunit/CircleCiConfigTest.php | 2 +- 80 files changed, 2564 insertions(+), 1895 deletions(-) delete mode 100644 .circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml => .circleci/build-test-deploy.yml (78%) delete mode 100644 .circleci/config.yml create mode 100644 .circleci/update-dependencies.yml create mode 100644 .circleci/vortex-test-common.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/{deploy_types_all_circleci/.circleci/config.yml => ciprovider_circleci/.circleci/build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/{timezone_circleci/.circleci/config.yml => deploy_types_all_circleci/.circleci/build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/{migration_disabled_circleci/.circleci/config.yml => deps_updates_provider_ci_circleci/.circleci/build-test-deploy.yml} (96%) create mode 100644 .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/update-dependencies.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/{ciprovider_circleci/.circleci/config.yml => migration_disabled_circleci/.circleci/build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/README.md create mode 100644 .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/{config.yml => build-test-deploy.yml} (95%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/README.md rename .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/{config.yml => build-test-deploy.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/README.md create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml create mode 100755 .vortex/tests/generate-vortex-dev-circleci create mode 100755 .vortex/tests/lint.ci.sh 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/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml b/.circleci/build-test-deploy.yml similarity index 78% rename from .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml rename to .circleci/build-test-deploy.yml index de599d289..28140c9a8 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml +++ b/.circleci/build-test-deploy.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. # @@ -7,32 +7,45 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci +#; +#; Comments starting with '#;<' and '#;>' are internal Vortex comments +#; and will be removed during installation or update of Vortex. 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" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # 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:__VERSION__ + - image: drevops/ci-runner:26.2.0@sha256:fe1561c2984a1023e84eebe6461056b0b55afedbb2512e6c2c7f19aca6beb398 auth: username: ${VORTEX_CONTAINER_REGISTRY_USER} password: ${VORTEX_CONTAINER_REGISTRY_PASS} @@ -46,6 +59,7 @@ aliases: 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 @@ -54,6 +68,7 @@ aliases: 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. @@ -92,20 +107,12 @@ 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 ################################################################################ jobs: + #;< !PROVISION_TYPE_PROFILE # Database handling is a first step of the build. # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump # should be downloaded for the current build. Usually, a daily database dump @@ -142,16 +149,23 @@ jobs: # 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). - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - 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. - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}- + - 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 @@ -175,11 +189,12 @@ jobs: # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + 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 # 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: @@ -188,11 +203,12 @@ jobs: # Enforce fresh DB build (do not rely on fallback caches). VORTEX_CI_DB_CACHE_FALLBACK: 'no' # Always use fresh base image for the database (if database-in-image storage is used). - VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ + VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:26.1.0 # Deploy container image (if database-in-image storage is used). VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 # Do not build the Drupal front-end. VORTEX_FRONTEND_BUILD_SKIP: 1 + #;> !PROVISION_TYPE_PROFILE # Build and test is a second step of the build. The testing is performed # within the same job to save time on provisioning during the job. @@ -211,6 +227,7 @@ jobs: 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: | @@ -222,8 +239,9 @@ jobs: keys: # Use cached artifacts from previous builds of this branch. # https://circleci.com/docs/2.0/caching/#restoring-cache - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- + - 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 @@ -243,7 +261,7 @@ jobs: 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:__VERSION__ . || [ "${VORTEX_CI_DCLINT_IGNORE_FAILURE:-0}" -eq 1 ] + docker run --rm -v "${PWD}":/app zavoloklom/dclint:3.1.0 . || [ "${VORTEX_CI_DCLINT_IGNORE_FAILURE:-0}" -eq 1 ] - run: name: Build stack @@ -263,7 +281,9 @@ jobs: 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 @@ -275,29 +295,37 @@ jobs: [ "${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 @@ -305,23 +333,29 @@ jobs: [ "${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 @@ -330,9 +364,16 @@ jobs: 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: | @@ -385,7 +426,9 @@ jobs: 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: | @@ -395,6 +438,7 @@ jobs: 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 @@ -419,6 +463,7 @@ jobs: paths: - code + #;< DEPLOYMENT # Deploy primary branches. deploy: &job_deploy <<: *runner_config @@ -476,71 +521,79 @@ 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' - + #;> DEPLOYMENT + + #;============================================================================ + #; Vortex development section. Removed during Vortex installation/update. + #;============================================================================ + #;< VORTEX_DEV + #----------------------------------------------------------------------------- + # Test suite for Vortex. + #----------------------------------------------------------------------------- + + # Run Vortex tests after 'build' job to test CircleCI's configuration. + vortex-dev-test-ci-postbuild: + <<: *runner_config steps: - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + - *step_setup_remote_docker + - run: - name: Check if RENOVATE_TOKEN is set + name: Install Ahoy 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 + version=2.4.0 && \ + set -x && curl -L -o "/usr/local/bin/ahoy" "https://github.com/ahoy-cli/ahoy/releases/download/v${version}/ahoy-bin-$(uname -s)-amd64" && \ + chmod +x /usr/local/bin/ahoy && \ + ahoy --version - run: - name: Validate Renovate configuration - command: renovate-config-validator + name: Install test dependencies + command: | + cd .vortex/tests + composer install --no-interaction --prefer-dist - run: - name: Run Renovate - command: renovate + name: Run CircleCI post-build tests + command: | + cd .vortex/tests + ./vendor/bin/phpunit --group=postbuild + + - store_test_results: + path: *test_results + + - store_artifacts: + path: *artifacts + #============================================================================= + #;> VORTEX_DEV ################################################################################ # WORKFLOWS ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: + #;< !PROVISION_TYPE_PROFILE - database: filters: tags: only: /.*/ + #;> !PROVISION_TYPE_PROFILE - build: + #;< !PROVISION_TYPE_PROFILE requires: - database + #;> !PROVISION_TYPE_PROFILE filters: tags: only: /.*/ + #;< DEPLOYMENT - deploy: requires: - build @@ -552,9 +605,9 @@ workflows: # - deps/* # - feature/description, feature/123-description # - bugfix/description, bugfix/123-description - # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) + # - release/123.456.789, release/123.456.789-rc.123 (per https://semver.org/) # - release/2023-04-17, release/2023-04-17.123 (date-based) - # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) + # - hotfix/123.456.789, hotfix/123.456.789-rc.1213 (per https://semver.org/) # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ tags: @@ -567,35 +620,37 @@ workflows: ignore: /.*/ tags: # Allowed tags: - # - __VERSION__, __VERSION__ (per https://semver.org/) + # - 123.456.789, 123.456.789-rc.123 (per https://semver.org/) # - 2023-04-17, 2023-04-17.123 (date-based) only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + #;> DEPLOYMENT + + #;============================================================================ + #; Vortex development section. Removed during Vortex installation/update. + #;============================================================================ + #; + #;< VORTEX_DEV + # 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. + - vortex-dev-test-ci-postbuild: + requires: + - build + filters: + tags: + only: /.*/ + #============================================================================= + #;> VORTEX_DEV + #;< !PROVISION_TYPE_PROFILE # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] 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 + #;> !PROVISION_TYPE_PROFILE diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 270c3769c..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,832 +0,0 @@ -# CircleCI 2.0 configuration file. -# -# This configuration file uses the "docker" executor to run the Docker stack. -# -# A "runner" container, created from a specified container image, is used to -# checkout source code and run commands defined in this file. Application Docker -# containers defined in `docker-compose.yml` run on a *remote* Docker server -# controlled by CircleCI. -# The "runner" container uses Docker client to control the remote Docker server. -#; -#; Comments starting with '#;<' and '#;>' are internal Vortex comments -#; and will be removed during installation or update of Vortex. -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" - -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - -################################################################################ -# JOBS -################################################################################ - -jobs: - #;< !PROVISION_TYPE_PROFILE - # Database handling is a first step of the build. - # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump - # should be downloaded for the current build. Usually, a daily database dump - # is sufficient for development activities. - # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. - # This allows to rely on the cache from the previous days within the same branch. - 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 - - # Nightly database job. Same as above, but with additional variables set. - database-nightly: - <<: *job-database - environment: - VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint - VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint - # Enforce fresh DB build (do not rely on fallback caches). - VORTEX_CI_DB_CACHE_FALLBACK: 'no' - # Always use fresh base image for the database (if database-in-image storage is used). - VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:26.1.0 - # Deploy container image (if database-in-image storage is used). - VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 - # Do not build the Drupal front-end. - VORTEX_FRONTEND_BUILD_SKIP: 1 - #;> !PROVISION_TYPE_PROFILE - - # Build and test is a second step of the build. The testing is performed - # within the same job to save time on provisioning during the job. - 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 - - #;< DEPLOYMENT - # Deploy primary branches. - deploy: &job_deploy - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Check if deployment should be skipped - command: | - if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then - echo "Skipping deployment - PR from project/* branch" - circleci-agent step halt - fi - - - run: - name: Deploy - command: | - VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ - VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ - VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ - ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - path: *artifacts - - # Deploy tags. - deploy-tags: &job-deploy-tags - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Deploy - command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - 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. - #;============================================================================ - #;< VORTEX_DEV - #----------------------------------------------------------------------------- - # Test suite for Vortex. - #----------------------------------------------------------------------------- - - # Run Vortex tests after 'build' job to test CircleCI's configuration. - vortex-dev-test-ci-postbuild: - <<: *runner_config - steps: - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - *step_setup_remote_docker - - - run: - name: Install Ahoy - command: | - version=2.4.0 && \ - set -x && curl -L -o "/usr/local/bin/ahoy" "https://github.com/ahoy-cli/ahoy/releases/download/v${version}/ahoy-bin-$(uname -s)-amd64" && \ - chmod +x /usr/local/bin/ahoy && \ - ahoy --version - - - run: - name: Install test dependencies - command: | - cd .vortex/tests - composer install --no-interaction --prefer-dist - - - run: - name: Run CircleCI post-build tests - command: | - cd .vortex/tests - ./vendor/bin/phpunit --group=postbuild - - - store_test_results: - path: *test_results - - - 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 - -################################################################################ -# WORKFLOWS -################################################################################ - -workflows: - version: 2 - # Commit workflow. Runs for every commit push to the remote repository. - commit: - jobs: - #;< !PROVISION_TYPE_PROFILE - - database: - filters: - tags: - only: /.*/ - #;> !PROVISION_TYPE_PROFILE - - build: - #;< !PROVISION_TYPE_PROFILE - requires: - - database - #;> !PROVISION_TYPE_PROFILE - filters: - tags: - only: /.*/ - #;< DEPLOYMENT - - deploy: - requires: - - build - filters: - branches: - # Allowed branches: - # - production, main, master, develop, ci, cisomething - # - project/description - # - deps/* - # - feature/description, feature/123-description - # - bugfix/description, bugfix/123-description - # - release/123.456.789, release/123.456.789-rc.123 (per https://semver.org/) - # - release/2023-04-17, release/2023-04-17.123 (date-based) - # - hotfix/123.456.789, hotfix/123.456.789-rc.1213 (per https://semver.org/) - # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) - only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - tags: - ignore: /.*/ - - deploy-tags: - requires: - - build - filters: - branches: - ignore: /.*/ - tags: - # Allowed tags: - # - 123.456.789, 123.456.789-rc.123 (per https://semver.org/) - # - 2023-04-17, 2023-04-17.123 (date-based) - only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - #;> DEPLOYMENT - - #;============================================================================ - #; Vortex development section. Removed during Vortex installation/update. - #;============================================================================ - #; - #;< VORTEX_DEV - # Run functional tests for Vortex. - # Note that these jobs must run within the "commit" workflow, because they - # depend on the "build" job. - # Run tests after 'build' job. - - vortex-dev-test-ci-postbuild: - requires: - - build - 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 - - #;< !PROVISION_TYPE_PROFILE - # Nightly database workflow runs overnight to capture fresh database and cache it. - nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop - 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..838dddc93 --- /dev/null +++ b/.circleci/vortex-test-common.yml @@ -0,0 +1,476 @@ +# Auto-generated by .vortex/tests/generate-vortex-dev-circleci +# Source: .circleci/build-test-deploy.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" + + # 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..2e9bb6bb4 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 @@ -84,7 +84,7 @@ same provider, you can use a single key for both operations. CircleCI uses SSH key fingerprints to load the correct keys into the runner container. Update the YAML anchors in your -[`.circleci/config.yml`](https://github.com/drevops/vortex/blob/main/.circleci/config.yml) +[`.circleci/build-test-deploy.yml`](https://github.com/drevops/vortex/blob/main/.circleci/build-test-deploy.yml) file: - `db_ssh_fingerprint` - your database download SSH key fingerprint @@ -101,13 +101,53 @@ 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 + +Some workflows run on a schedule rather than on every push. These schedules must +be configured in the CircleCI UI. + +Go to **Project Settings → Triggers** and create the following scheduled +triggers: + +#### Nightly database + +Caches a fresh database dump overnight so that builds the next day start faster. + +| Setting | Value | +|---------------|-----------------------------| +| Trigger name | `nightly-db` | +| Config source | `build-test-deploy.yml` | +| Branch | `develop` | +| Schedule | Every day at 18:00 UTC | + +#### Update dependencies (optional) + +Runs [Renovate](https://docs.renovatebot.com/) to automatically update +project dependencies. Only needed if you use the self-hosted Renovate +workflow provided in +[`.circleci/update-dependencies.yml`](https://github.com/drevops/vortex/blob/main/.circleci/update-dependencies.yml). + +| 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 names (`nightly-db`, `update-dependencies`) must match exactly - +they are referenced in the workflow `when` conditions in the configuration files. + +::: + ## Maintenance ### Update deployment branches The `deploy` job only runs for specific branch patterns. To modify which branches trigger deployments, update the `only` filter regex in the `deploy` job under -the `workflows` section of `.circleci/config.yml`: +the `workflows` section of `.circleci/build-test-deploy.yml`: ```yaml filters: @@ -118,12 +158,11 @@ filters: ### Update nightly database schedule 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 -([cron format](https://crontab.guru/#0_18_*_*_*), UTC timezone): +day. To change the schedule, update the trigger in the CircleCI UI under +**Project Settings → Triggers → nightly-db**. -```yaml -- &nightly_db_schedule "0 18 * * *" # 6 PM UTC daily -``` +See [Configure schedule triggers](#6-configure-schedule-triggers) for the +recommended default values. ### Change runner resource class diff --git a/.vortex/installer/src/Prompts/Handlers/CiProvider.php b/.vortex/installer/src/Prompts/Handlers/CiProvider.php index 09244f097..9c54deee6 100644 --- a/.vortex/installer/src/Prompts/Handlers/CiProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/CiProvider.php @@ -64,7 +64,7 @@ public function discover(): null|string|bool|array { return self::GITHUB_ACTIONS; } - if (is_readable($this->dstDir . '/.circleci/config.yml')) { + if (is_readable($this->dstDir . '/.circleci/build-test-deploy.yml') || is_readable($this->dstDir . '/.circleci/config.yml')) { return self::CIRCLECI; } diff --git a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php index a2b5a88f4..0137fcad7 100644 --- a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php @@ -62,7 +62,8 @@ public function discover(): null|string|bool|array { return self::RENOVATEBOT_CI; } - if (File::contains($this->dstDir . '/.circleci/config.yml', 'update-dependencies')) { + if (File::contains($this->dstDir . '/.circleci/build-test-deploy.yml', 'update-dependencies') + || File::contains($this->dstDir . '/.circleci/config.yml', 'update-dependencies')) { return self::RENOVATEBOT_CI; } @@ -86,12 +87,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/deploy_types_all_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/build-test-deploy.yml index cfc64fbaa..8bea7ee4d 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +480,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,13 +527,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/timezone_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/build-test-deploy.yml index cfc64fbaa..8bea7ee4d 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +480,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,13 +527,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/build-test-deploy.yml index 1e081be9e..9c8f4fd02 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +422,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -440,13 +440,11 @@ workflows: only: /.*/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/migration_disabled_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/build-test-deploy.yml index cfc64fbaa..8bea7ee4d 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +480,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,13 +527,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly 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/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/ciprovider_circleci/.circleci/config.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/build-test-deploy.yml index cfc64fbaa..8bea7ee4d 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +480,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,13 +527,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/build-test-deploy.yml index 0dce71cdd..4b46a3c3a 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +182,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,9 +489,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -536,13 +536,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/build-test-deploy.yml new file mode 100644 index 000000000..8bea7ee4d --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/build-test-deploy.yml @@ -0,0 +1,537 @@ +# CircleCI configuration file for building, testing, and deploying. +# +# This configuration file uses the "docker" executor to run the Docker stack. +# +# A "runner" container, created from a specified container image, is used to +# checkout source code and run commands defined in this file. Application Docker +# containers defined in `docker-compose.yml` run on a *remote* Docker server +# controlled by CircleCI. +# The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci +version: '2.1' + +aliases: + # 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" + + # 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" + + # Shared runner container configuration applied to each job. + - &runner_config + working_directory: &working_directory ~/project + environment: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + 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:__VERSION__ + 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" + # 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" + # 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: + # Database handling is a first step of the build. + # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump + # should be downloaded for the current build. Usually, a daily database dump + # is sufficient for development activities. + # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. + # This allows to rely on the cache from the previous days within the same branch. + 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). + - __VERSION__{{ 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. + - __VERSION__{{ 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 + + # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + paths: + - /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: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint + # Enforce fresh DB build (do not rely on fallback caches). + VORTEX_CI_DB_CACHE_FALLBACK: 'no' + # Always use fresh base image for the database (if database-in-image storage is used). + VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ + # Deploy container image (if database-in-image storage is used). + VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 + # Do not build the Drupal front-end. + VORTEX_FRONTEND_BUILD_SKIP: 1 + + # Build and test is a second step of the build. The testing is performed + # within the same job to save time on provisioning during the job. + 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 ] + + - 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 + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- + + - *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:__VERSION__ . || [ "${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" + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh + no_output_timeout: 30m + + - 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 + + - 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 + + - 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 + + # Deploy primary branches. + deploy: &job_deploy + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Check if deployment should be skipped + command: | + if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then + echo "Skipping deployment - PR from project/* branch" + circleci-agent step halt + fi + + - run: + name: Deploy + command: | + VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ + VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ + VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ + ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + + # Deploy tags. + deploy-tags: &job-deploy-tags + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Deploy + command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + +################################################################################ +# WORKFLOWS +################################################################################ + +workflows: + # Commit workflow. Runs for every commit push to the remote repository. + commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] + jobs: + - database: + filters: + tags: + only: /.*/ + - build: + requires: + - database + filters: + tags: + only: /.*/ + - deploy: + requires: + - build + filters: + branches: + # Allowed branches: + # - production, main, master, develop, ci, cisomething + # - project/description + # - deps/* + # - feature/description, feature/123-description + # - bugfix/description, bugfix/123-description + # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) + # - release/2023-04-17, release/2023-04-17.123 (date-based) + # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) + # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) + only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + tags: + ignore: /.*/ + - deploy-tags: + requires: + - build + filters: + branches: + ignore: /.*/ + tags: + # Allowed tags: + # - __VERSION__, __VERSION__ (per https://semver.org/) + # - 2023-04-17, 2023-04-17.123 (date-based) + only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + + # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. + nightly-db: + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] + jobs: + - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/build-test-deploy.yml index bbf7f0a95..e486d1b89 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +456,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -503,13 +503,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php index 113f4f668..c299e4058 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -29,7 +29,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 95% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/build-test-deploy.yml index 45ebcf0e3..b5ce65850 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +411,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -458,13 +458,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/build-test-deploy.yml index 062cbc914..9bf0fc029 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +473,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -520,13 +520,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/build-test-deploy.yml index 0193e1369..a2e74e510 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +467,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -514,13 +514,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/build-test-deploy.yml index 4465a1da0..bee6680b1 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +464,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -511,13 +511,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/build-test-deploy.yml index 062cbc914..9bf0fc029 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +473,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -520,13 +520,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/build-test-deploy.yml index 230ef7345..ba17af584 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +474,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,13 +521,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php index 86f336226..7e8bdd340 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php @@ -30,7 +30,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/build-test-deploy.yml index 217c98e64..ea20d565b 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +474,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,13 +521,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php index 43859a8fc..a08c3184a 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php @@ -33,7 +33,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/build-test-deploy.yml index a038fe64a..8e4fcaa3d 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +474,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,13 +521,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/build-test-deploy.yml index 7bc050b3e..a6ef1504c 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +427,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -474,13 +474,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly 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/build-test-deploy.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/build-test-deploy.yml index 99dddf57d..4cbbe23e9 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/build-test-deploy.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. # @@ -7,6 +7,15 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -18,9 +27,6 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -92,15 +98,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 +177,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,9 +474,11 @@ jobs: ################################################################################ workflows: - version: 2 # Commit workflow. Runs for every commit push to the remote repository. commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,13 +521,11 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } 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/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/build-test-deploy.yml new file mode 100644 index 000000000..8bea7ee4d --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/build-test-deploy.yml @@ -0,0 +1,537 @@ +# CircleCI configuration file for building, testing, and deploying. +# +# This configuration file uses the "docker" executor to run the Docker stack. +# +# A "runner" container, created from a specified container image, is used to +# checkout source code and run commands defined in this file. Application Docker +# containers defined in `docker-compose.yml` run on a *remote* Docker server +# controlled by CircleCI. +# The "runner" container uses Docker client to control the remote Docker server. +# +# Scheduled pipelines: +# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. +# Go to Project Settings > Triggers > Add Scheduled Trigger: +# - Trigger name: nightly-db +# - Config source: build-test-deploy.yml +# - Branch: develop +# - Schedule: Every day at 18:00 UTC (or a custom time) +# See https://www.vortextemplate.com/docs/continuous-integration/circleci +version: '2.1' + +aliases: + # 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" + + # 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" + + # Shared runner container configuration applied to each job. + - &runner_config + working_directory: &working_directory ~/project + environment: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + 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:__VERSION__ + 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" + # 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" + # 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: + # Database handling is a first step of the build. + # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump + # should be downloaded for the current build. Usually, a daily database dump + # is sufficient for development activities. + # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. + # This allows to rely on the cache from the previous days within the same branch. + 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). + - __VERSION__{{ 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. + - __VERSION__{{ 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 + + # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + paths: + - /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: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint + # Enforce fresh DB build (do not rely on fallback caches). + VORTEX_CI_DB_CACHE_FALLBACK: 'no' + # Always use fresh base image for the database (if database-in-image storage is used). + VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ + # Deploy container image (if database-in-image storage is used). + VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 + # Do not build the Drupal front-end. + VORTEX_FRONTEND_BUILD_SKIP: 1 + + # Build and test is a second step of the build. The testing is performed + # within the same job to save time on provisioning during the job. + 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 ] + + - 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 + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- + + - *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:__VERSION__ . || [ "${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" + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh + no_output_timeout: 30m + + - 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 + + - 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 + + - 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 + + # Deploy primary branches. + deploy: &job_deploy + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Check if deployment should be skipped + command: | + if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then + echo "Skipping deployment - PR from project/* branch" + circleci-agent step halt + fi + + - run: + name: Deploy + command: | + VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ + VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ + VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ + ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + + # Deploy tags. + deploy-tags: &job-deploy-tags + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Deploy + command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + +################################################################################ +# WORKFLOWS +################################################################################ + +workflows: + # Commit workflow. Runs for every commit push to the remote repository. + commit: + when: + not: + equal: [scheduled_pipeline, << pipeline.trigger_source >>] + jobs: + - database: + filters: + tags: + only: /.*/ + - build: + requires: + - database + filters: + tags: + only: /.*/ + - deploy: + requires: + - build + filters: + branches: + # Allowed branches: + # - production, main, master, develop, ci, cisomething + # - project/description + # - deps/* + # - feature/description, feature/123-description + # - bugfix/description, bugfix/123-description + # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) + # - release/2023-04-17, release/2023-04-17.123 (date-based) + # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) + # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) + only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + tags: + ignore: /.*/ + - deploy-tags: + requires: + - build + filters: + branches: + ignore: /.*/ + tags: + # Allowed tags: + # - __VERSION__, __VERSION__ (per https://semver.org/) + # - 2023-04-17, 2023-04-17.123 (date-based) + only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + + # Nightly database workflow runs overnight to capture fresh database and cache it. + # Requires a "nightly-db" schedule trigger configured in CircleCI UI. + nightly-db: + when: + and: + - equal: [scheduled_pipeline, << pipeline.trigger_source >>] + - equal: ["nightly-db", << pipeline.schedule.name >>] + jobs: + - database-nightly 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 deleted file mode 100644 index cfc64fbaa..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml +++ /dev/null @@ -1,539 +0,0 @@ -# CircleCI 2.0 configuration file. -# -# This configuration file uses the "docker" executor to run the Docker stack. -# -# A "runner" container, created from a specified container image, is used to -# checkout source code and run commands defined in this file. Application Docker -# containers defined in `docker-compose.yml` run on a *remote* Docker server -# controlled by CircleCI. -# The "runner" container uses Docker client to control the remote Docker server. -version: '2.1' - -aliases: - # 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" - - # 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" - - # Schedule to run nightly database build (to cache the database for the next day). - - &nightly_db_schedule "0 18 * * *" - - # Shared runner container configuration applied to each job. - - &runner_config - working_directory: &working_directory ~/project - environment: - VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint - 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:__VERSION__ - 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" - # 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" - # 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" - -################################################################################ -# PARAMETERS -################################################################################ - -parameters: - run_update_dependencies: - type: boolean - default: false - -################################################################################ -# JOBS -################################################################################ - -jobs: - # Database handling is a first step of the build. - # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump - # should be downloaded for the current build. Usually, a daily database dump - # is sufficient for development activities. - # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. - # This allows to rely on the cache from the previous days within the same branch. - 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). - - __VERSION__{{ 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. - - __VERSION__{{ 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 - - # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} - paths: - - /root/project/.data - - # Nightly database job. Same as above, but with additional variables set. - database-nightly: - <<: *job-database - environment: - VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint - VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint - # Enforce fresh DB build (do not rely on fallback caches). - VORTEX_CI_DB_CACHE_FALLBACK: 'no' - # Always use fresh base image for the database (if database-in-image storage is used). - VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ - # Deploy container image (if database-in-image storage is used). - VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 - # Do not build the Drupal front-end. - VORTEX_FRONTEND_BUILD_SKIP: 1 - - # Build and test is a second step of the build. The testing is performed - # within the same job to save time on provisioning during the job. - 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 ] - - - 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 - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- - - - *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:__VERSION__ . || [ "${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" - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh - no_output_timeout: 30m - - - 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 - - - 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 - - - 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 - - # Deploy primary branches. - deploy: &job_deploy - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Check if deployment should be skipped - command: | - if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then - echo "Skipping deployment - PR from project/* branch" - circleci-agent step halt - fi - - - run: - name: Deploy - command: | - VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ - VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ - VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ - ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - path: *artifacts - - # Deploy tags. - deploy-tags: &job-deploy-tags - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Deploy - command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - path: *artifacts - -################################################################################ -# WORKFLOWS -################################################################################ - -workflows: - version: 2 - # Commit workflow. Runs for every commit push to the remote repository. - commit: - jobs: - - database: - filters: - tags: - only: /.*/ - - build: - requires: - - database - filters: - tags: - only: /.*/ - - deploy: - requires: - - build - filters: - branches: - # Allowed branches: - # - production, main, master, develop, ci, cisomething - # - project/description - # - deps/* - # - feature/description, feature/123-description - # - bugfix/description, bugfix/123-description - # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) - # - release/2023-04-17, release/2023-04-17.123 (date-based) - # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) - # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) - only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - tags: - ignore: /.*/ - - deploy-tags: - requires: - - build - filters: - branches: - ignore: /.*/ - tags: - # Allowed tags: - # - __VERSION__, __VERSION__ (per https://semver.org/) - # - 2023-04-17, 2023-04-17.123 (date-based) - only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - - # Nightly database workflow runs overnight to capture fresh database and cache it. - nightly-db: - triggers: - - schedule: - cron: *nightly_db_schedule - filters: - branches: - only: - - develop - jobs: - - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php index f79f32706..59f25d19c 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php index a6a02ae7d..b455fa2d2 100644 --- a/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php @@ -32,8 +32,8 @@ public static function dataProviderHandlerProcess(): array { Env::put(AiCodeInstructions::envName(), Env::TRUE); }), static::cw(function (FunctionalTestCase $test): void { - $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', '1.x'); - $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', '2.x'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', '1.x'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', '2.x'); }), ], ]; diff --git a/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php index c87b6470f..e2575549f 100644 --- a/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php @@ -50,7 +50,7 @@ public static function dataProviderHandlerProcess(): array { $test->assertDirectoryExists(static::$sut . '/web/modules/custom/ys_migrate'); $test->assertFileContainsString(static::$sut . '/composer.json', 'drupal/migrate_plus'); $test->assertFileContainsString(static::$sut . '/composer.json', 'drupal/migrate_tools'); - $test->assertFileContainsString(static::$sut . '/.circleci/config.yml', 'Download migration DB'); + $test->assertFileContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'Download migration DB'); }), ], @@ -88,7 +88,7 @@ public static function dataProviderHandlerProcess(): array { $test->assertDirectoryDoesNotExist(static::$sut . '/web/modules/custom/ys_migrate'); $test->assertFileNotContainsString(static::$sut . '/composer.json', 'drupal/migrate_plus'); $test->assertFileNotContainsString(static::$sut . '/composer.json', 'drupal/migrate_tools'); - $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', 'Download migration DB'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'Download migration DB'); }), ], diff --git a/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php index 803f87b96..37c272105 100644 --- a/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php @@ -49,8 +49,8 @@ public static function dataProviderHandlerProcess(): array { static::cw(function (FunctionalTestCase $test): void { // Timezone should not be replaced in CircleCI config in code as it // should be overridden via UI. - $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', 'TZ: America/New_York'); - $test->assertFileContainsString(static::$sut . '/.circleci/config.yml', 'TZ: UTC'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'TZ: America/New_York'); + $test->assertFileContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'TZ: UTC'); }), ], ]; diff --git a/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php b/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php index 93dc176b4..5cfb94cf4 100644 --- a/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php +++ b/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php @@ -37,7 +37,7 @@ function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { [CiProvider::id() => CiProvider::CIRCLECI] + $expected_installed, function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { $test->stubVortexProject($config); - File::dump(static::$sut . '/.circleci/config.yml'); + File::dump(static::$sut . '/.circleci/build-test-deploy.yml'); }, ], diff --git a/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php b/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php index a5bae6392..607460caf 100644 --- a/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php +++ b/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php @@ -43,7 +43,7 @@ function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { $test->stubVortexProject($config); File::dump(static::$sut . '/renovate.json'); - File::dump(static::$sut . '/.circleci/config.yml', 'update-dependencies'); + File::dump(static::$sut . '/.circleci/build-test-deploy.yml', 'update-dependencies'); }, ], 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..f93daa875 --- /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/* diff --git a/.vortex/tests/phpunit/Traits/SutTrait.php b/.vortex/tests/phpunit/Traits/SutTrait.php index f8e68f62a..898b53e93 100644 --- a/.vortex/tests/phpunit/Traits/SutTrait.php +++ b/.vortex/tests/phpunit/Traits/SutTrait.php @@ -267,7 +267,7 @@ protected function assertCommonFilesAbsent(string $webroot = 'web'): void { // Documentation and CI files that should not exist in some contexts. $this->assertFileDoesNotExist('.ahoy.yml'); - $this->assertFileDoesNotExist('.circleci/config.yml'); + $this->assertFileDoesNotExist('.circleci/build-test-deploy.yml'); $this->assertFileDoesNotExist('.github/workflows/build-test-deploy.yml'); $this->assertFileDoesNotExist('README.md'); $this->assertFileDoesNotExist('docs/faqs.md'); @@ -409,8 +409,8 @@ protected function assertVortexFilesPresent(string $webroot = 'web'): void { $this->assertFileDoesNotExist('.github/workflows/vortex-test-common.yml'); $this->assertFileDoesNotExist('.github/workflows/vortex-test-installer.yml'); - if (file_exists('.circleci/config.yml')) { - $this->assertFileNotContainsString('.circleci/config.yml', 'vortex-dev', 'CircleCI config should not contain development Vortex references'); + if (file_exists('.circleci/build-test-deploy.yml')) { + $this->assertFileNotContainsString('.circleci/build-test-deploy.yml', 'vortex-dev', 'CircleCI config should not contain development Vortex references'); } // Assert that documentation was processed correctly. diff --git a/tests/phpunit/CircleCiConfigTest.php b/tests/phpunit/CircleCiConfigTest.php index 5beaafefe..0cfe21908 100644 --- a/tests/phpunit/CircleCiConfigTest.php +++ b/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } From bc7fb07636e999f0ab57c9bfca835decf1467180 Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 9 Mar 2026 12:08:08 +1100 Subject: [PATCH 2/3] Switched back to `config.yml`. --- .../{build-test-deploy.yml => config.yml} | 29 +- .circleci/vortex-test-common.yml | 7 +- .../continuous-integration/circleci.mdx | 51 +- .../src/Prompts/Handlers/CiProvider.php | 2 +- .../Handlers/DependencyUpdatesProvider.php | 3 +- .../.circleci/config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 77 +++ .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 21 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/build-test-deploy.yml | 537 ------------------ .../timezone_circleci/.circleci/config.yml | 530 +++++++++++++++++ .../.github/workflows/-build-test-deploy.yml | 0 .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 27 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 78 +++ .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 20 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 25 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 31 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 20 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 54 ++ .../{build-test-deploy.yml => config.yml} | 27 +- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 + .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../.circleci/build-test-deploy.yml | 537 ------------------ .../.circleci/config.yml | 530 +++++++++++++++++ .../.github/workflows/-build-test-deploy.yml | 0 .../tests/phpunit/CircleCiConfigTest.php | 2 +- .../Handlers/CiProviderHandlerProcessTest.php | 4 +- .../Handlers/MigrationHandlerProcessTest.php | 4 +- .../Handlers/TimezoneHandlerProcessTest.php | 4 +- .../CiProviderHandlerDiscoveryTest.php | 2 +- ...ncyUpdatesProviderHandlerDiscoveryTest.php | 2 +- .vortex/tests/generate-vortex-dev-circleci | 6 +- .vortex/tests/phpunit/Traits/SutTrait.php | 6 +- tests/phpunit/CircleCiConfigTest.php | 2 +- 83 files changed, 1705 insertions(+), 1445 deletions(-) rename .circleci/{build-test-deploy.yml => config.yml} (97%) rename .vortex/installer/tests/Fixtures/handler_process/{deps_updates_provider_ci_circleci/.circleci/build-test-deploy.yml => ciprovider_circleci/.circleci/config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.github/workflows/-build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/{ciprovider_circleci/.circleci/build-test-deploy.yml => deploy_types_all_circleci/.circleci/config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.github/workflows/-build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/{build-test-deploy.yml => config.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/{migration_disabled_circleci/.circleci/build-test-deploy.yml => deps_updates_provider_ci_circleci/.circleci/config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.github/workflows/-build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/{deploy_types_all_circleci/.circleci/build-test-deploy.yml => migration_disabled_circleci/.circleci/config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.github/workflows/-build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/{build-test-deploy.yml => config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.github/workflows/-build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/{build-test-deploy.yml => config.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/{build-test-deploy.yml => config.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/{build-test-deploy.yml => config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/{build-test-deploy.yml => config.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/{build-test-deploy.yml => config.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/{build-test-deploy.yml => config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/{build-test-deploy.yml => config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/{build-test-deploy.yml => config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/{build-test-deploy.yml => config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/{build-test-deploy.yml => config.yml} (96%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml rename .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/{build-test-deploy.yml => config.yml} (97%) delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.github/workflows/-build-test-deploy.yml diff --git a/.circleci/build-test-deploy.yml b/.circleci/config.yml similarity index 97% rename from .circleci/build-test-deploy.yml rename to .circleci/config.yml index 28140c9a8..f8f76c5ca 100644 --- a/.circleci/build-test-deploy.yml +++ b/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci #; #; Comments starting with '#;<' and '#;>' are internal Vortex comments #; and will be removed during installation or update of Vortex. @@ -32,6 +23,11 @@ aliases: # 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 @@ -575,9 +571,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: #;< !PROVISION_TYPE_PROFILE - database: @@ -645,12 +638,14 @@ workflows: #;< !PROVISION_TYPE_PROFILE # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly #;> !PROVISION_TYPE_PROFILE diff --git a/.circleci/vortex-test-common.yml b/.circleci/vortex-test-common.yml index 838dddc93..f5bc22c8e 100644 --- a/.circleci/vortex-test-common.yml +++ b/.circleci/vortex-test-common.yml @@ -1,5 +1,5 @@ # Auto-generated by .vortex/tests/generate-vortex-dev-circleci -# Source: .circleci/build-test-deploy.yml +# Source: .circleci/config.yml # Do not edit directly. version: '2.1' @@ -14,6 +14,11 @@ aliases: # 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 diff --git a/.vortex/docs/content/continuous-integration/circleci.mdx b/.vortex/docs/content/continuous-integration/circleci.mdx index 2e9bb6bb4..173c4de25 100644 --- a/.vortex/docs/content/continuous-integration/circleci.mdx +++ b/.vortex/docs/content/continuous-integration/circleci.mdx @@ -84,7 +84,7 @@ same provider, you can use a single key for both operations. CircleCI uses SSH key fingerprints to load the correct keys into the runner container. Update the YAML anchors in your -[`.circleci/build-test-deploy.yml`](https://github.com/drevops/vortex/blob/main/.circleci/build-test-deploy.yml) +[`.circleci/config.yml`](https://github.com/drevops/vortex/blob/main/.circleci/config.yml) file: - `db_ssh_fingerprint` - your database download SSH key fingerprint @@ -103,29 +103,12 @@ Add the following variables in **Project Settings → Environment Variables**: ### 6. Configure schedule triggers -Some workflows run on a schedule rather than on every push. These schedules must -be configured in the CircleCI UI. +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 -triggers: - -#### Nightly database - -Caches a fresh database dump overnight so that builds the next day start faster. - -| Setting | Value | -|---------------|-----------------------------| -| Trigger name | `nightly-db` | -| Config source | `build-test-deploy.yml` | -| Branch | `develop` | -| Schedule | Every day at 18:00 UTC | - -#### Update dependencies (optional) - -Runs [Renovate](https://docs.renovatebot.com/) to automatically update -project dependencies. Only needed if you use the self-hosted Renovate -workflow provided in -[`.circleci/update-dependencies.yml`](https://github.com/drevops/vortex/blob/main/.circleci/update-dependencies.yml). +trigger: | Setting | Value | |---------------|------------------------------------| @@ -136,8 +119,16 @@ workflow provided in :::note -The trigger names (`nightly-db`, `update-dependencies`) must match exactly - -they are referenced in the workflow `when` conditions in the configuration files. +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. ::: @@ -147,7 +138,7 @@ they are referenced in the workflow `when` conditions in the configuration files The `deploy` job only runs for specific branch patterns. To modify which branches trigger deployments, update the `only` filter regex in the `deploy` job under -the `workflows` section of `.circleci/build-test-deploy.yml`: +the `workflows` section of `.circleci/config.yml`: ```yaml filters: @@ -158,11 +149,13 @@ filters: ### Update nightly database schedule The nightly database job caches a fresh database dump for faster builds the next -day. To change the schedule, update the trigger in the CircleCI UI under -**Project Settings → Triggers → nightly-db**. +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): -See [Configure schedule triggers](#6-configure-schedule-triggers) for the -recommended default values. +```yaml +- &nightly_db_schedule "0 18 * * *" # 6 PM UTC daily +``` ### Change runner resource class diff --git a/.vortex/installer/src/Prompts/Handlers/CiProvider.php b/.vortex/installer/src/Prompts/Handlers/CiProvider.php index 9c54deee6..09244f097 100644 --- a/.vortex/installer/src/Prompts/Handlers/CiProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/CiProvider.php @@ -64,7 +64,7 @@ public function discover(): null|string|bool|array { return self::GITHUB_ACTIONS; } - if (is_readable($this->dstDir . '/.circleci/build-test-deploy.yml') || is_readable($this->dstDir . '/.circleci/config.yml')) { + if (is_readable($this->dstDir . '/.circleci/config.yml')) { return self::CIRCLECI; } diff --git a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php index 0137fcad7..ef5973683 100644 --- a/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php +++ b/.vortex/installer/src/Prompts/Handlers/DependencyUpdatesProvider.php @@ -62,8 +62,7 @@ public function discover(): null|string|bool|array { return self::RENOVATEBOT_CI; } - if (File::contains($this->dstDir . '/.circleci/build-test-deploy.yml', 'update-dependencies') - || File::contains($this->dstDir . '/.circleci/config.yml', 'update-dependencies')) { + if (File::contains($this->dstDir . '/.circleci/config.yml', 'update-dependencies')) { return self::RENOVATEBOT_CI; } diff --git a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml index 8bea7ee4d..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -482,9 +476,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,11 +518,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml index 8bea7ee4d..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -482,9 +476,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,11 +518,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml index 9c8f4fd02..12d51b334 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -424,9 +418,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -440,11 +431,13 @@ workflows: only: /.*/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..09e1781d4 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,77 @@ +@@ -406,76 +406,3 @@ + timeout-minutes: 120 # Cancel the action after 15 minutes, regardless of whether a connection has been established. + with: + detached: true +- +- deploy: +- runs-on: ubuntu-latest +- needs: build +- if: ${{ github.event_name != 'schedule' && !startsWith(github.head_ref || github.ref_name, 'deps/') && (github.event_name == 'push' || !startsWith(github.head_ref, 'project/')) }} +- +- container: +- # https://hub.docker.com/r/drevops/ci-runner +- image: drevops/ci-runner:__VERSION__ +- env: +- TZ: ${{ vars.TZ || 'UTC' }} +- TERM: xterm-256color +- VORTEX_SSH_DISABLE_STRICT_HOST_KEY_CHECKING: "1" +- VORTEX_DEBUG: ${{ vars.VORTEX_DEBUG }} +- +- steps: +- - name: Preserve $HOME set in the container +- run: echo HOME=/root >> "$GITHUB_ENV" # https://github.com/actions/runner/issues/863 +- +- - name: Checkout code +- uses: actions/checkout@__HASH__ # __VERSION__ +- with: +- # Fetch all history for git repository. +- fetch-depth: 0 +- # Do not persist credentials after checkout +- # to allow using the custom credentials to push to a remote repo. +- persist-credentials: false +- ref: ${{ github.head_ref || github.ref_name }} +- +- - name: Load environment variables from .env +- run: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && env >> "$GITHUB_ENV" +- +- - name: Download exported codebase as an artifact +- uses: actions/download-artifact@__HASH__ # __VERSION__ +- if: ${{ contains(env.VORTEX_DEPLOY_TYPES, 'artifact') }} +- with: +- name: code-artifact +- path: "/tmp/artifacts" +- +- - name: Unpack downloaded exported codebase +- if: ${{ contains(env.VORTEX_DEPLOY_TYPES, 'artifact') }} +- run: | +- mkdir -p /tmp/workspace +- tar -xpf /tmp/artifacts/code.tar -C /tmp/workspace +- +- - name: Add SSH private key to the runner +- if: ${{ env.VORTEX_DEPLOY_SSH_PRIVATE_KEY != '' }} +- uses: shimataro/ssh-key-action@__VERSION__ +- with: +- key: ${{ secrets.VORTEX_DEPLOY_SSH_PRIVATE_KEY }} +- known_hosts: unnecessary +- env: +- VORTEX_DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.VORTEX_DEPLOY_SSH_PRIVATE_KEY }} +- +- - name: Deploy +- run: ./scripts/vortex/deploy.sh +- env: +- VORTEX_DEPLOY_MODE: ${{ startsWith(github.ref, 'refs/tags/') && 'tag' || 'branch' }} +- # Get branch for PR from 'head_ref' or for branch from 'ref_name'. +- VORTEX_DEPLOY_BRANCH: ${{ github.head_ref || github.ref_name }} +- VORTEX_DEPLOY_PR: ${{ github.event.number }} +- VORTEX_DEPLOY_PR_HEAD: ${{ github.event.pull_request.head.sha }} +- VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code +- VORTEX_DEPLOY_ARTIFACT_ROOT: ${{ github.workspace }} +- VORTEX_DEPLOY_ARTIFACT_GIT_REMOTE: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_REMOTE }} +- VORTEX_DEPLOY_ARTIFACT_GIT_USER_EMAIL: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_USER_EMAIL }} +- VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME }} +- VORTEX_DEPLOY_WEBHOOK_URL: ${{ vars.VORTEX_DEPLOY_WEBHOOK_URL }} +- VORTEX_DEPLOY_SKIP: ${{ vars.VORTEX_DEPLOY_SKIP }} +- VORTEX_DEPLOY_ALLOW_SKIP: ${{ vars.VORTEX_DEPLOY_ALLOW_SKIP }} +- VORTEX_DEPLOY_SKIP_PRS: ${{ vars.VORTEX_DEPLOY_SKIP_PRS }} +- VORTEX_DEPLOY_SKIP_BRANCHES: ${{ vars.VORTEX_DEPLOY_SKIP_BRANCHES }} +- timeout-minutes: 30 diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml index 8bea7ee4d..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -482,9 +476,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,11 +518,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml index 8bea7ee4d..8a07a8758 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -482,9 +476,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -527,11 +518,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml index 4b46a3c3a..a0ba1a34a 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -491,9 +485,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -536,11 +527,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..81974f68d --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,21 @@ +@@ -128,6 +128,9 @@ + echo "db_hash=${{ hashFiles('.data') }}" >> "$GITHUB_ENV" + timeout-minutes: 30 + ++ - name: Download migration DB ++ run: VORTEX_VAR_PREFIX=VORTEX_DOWNLOAD_DB2 ./scripts/vortex/download-db.sh ++ + - name: Export DB + run: | + if [ ! -f /tmp/download-db-success ]; then echo "==> Database download semaphore file is missing. DB export will not proceed."; exit 0; fi +@@ -310,6 +313,10 @@ + 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 ++ 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 + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh + timeout-minutes: 30 diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/build-test-deploy.yml deleted file mode 100644 index 8bea7ee4d..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/build-test-deploy.yml +++ /dev/null @@ -1,537 +0,0 @@ -# CircleCI configuration file for building, testing, and deploying. -# -# This configuration file uses the "docker" executor to run the Docker stack. -# -# A "runner" container, created from a specified container image, is used to -# checkout source code and run commands defined in this file. Application Docker -# containers defined in `docker-compose.yml` run on a *remote* Docker server -# controlled by CircleCI. -# The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci -version: '2.1' - -aliases: - # 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" - - # 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" - - # Shared runner container configuration applied to each job. - - &runner_config - working_directory: &working_directory ~/project - environment: - VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint - 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:__VERSION__ - 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" - # 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" - # 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: - # Database handling is a first step of the build. - # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump - # should be downloaded for the current build. Usually, a daily database dump - # is sufficient for development activities. - # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. - # This allows to rely on the cache from the previous days within the same branch. - 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). - - __VERSION__{{ 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. - - __VERSION__{{ 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 - - # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} - paths: - - /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: - VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint - VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint - # Enforce fresh DB build (do not rely on fallback caches). - VORTEX_CI_DB_CACHE_FALLBACK: 'no' - # Always use fresh base image for the database (if database-in-image storage is used). - VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ - # Deploy container image (if database-in-image storage is used). - VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 - # Do not build the Drupal front-end. - VORTEX_FRONTEND_BUILD_SKIP: 1 - - # Build and test is a second step of the build. The testing is performed - # within the same job to save time on provisioning during the job. - 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 ] - - - 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 - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- - - - *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:__VERSION__ . || [ "${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" - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh - no_output_timeout: 30m - - - 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 - - - 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 - - - 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 - - # Deploy primary branches. - deploy: &job_deploy - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Check if deployment should be skipped - command: | - if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then - echo "Skipping deployment - PR from project/* branch" - circleci-agent step halt - fi - - - run: - name: Deploy - command: | - VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ - VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ - VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ - ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - path: *artifacts - - # Deploy tags. - deploy-tags: &job-deploy-tags - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Deploy - command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - path: *artifacts - -################################################################################ -# WORKFLOWS -################################################################################ - -workflows: - # Commit workflow. Runs for every commit push to the remote repository. - commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - jobs: - - database: - filters: - tags: - only: /.*/ - - build: - requires: - - database - filters: - tags: - only: /.*/ - - deploy: - requires: - - build - filters: - branches: - # Allowed branches: - # - production, main, master, develop, ci, cisomething - # - project/description - # - deps/* - # - feature/description, feature/123-description - # - bugfix/description, bugfix/123-description - # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) - # - release/2023-04-17, release/2023-04-17.123 (date-based) - # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) - # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) - only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - tags: - ignore: /.*/ - - deploy-tags: - requires: - - build - filters: - branches: - ignore: /.*/ - tags: - # Allowed tags: - # - __VERSION__, __VERSION__ (per https://semver.org/) - # - 2023-04-17, 2023-04-17.123 (date-based) - only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - - # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. - nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] - jobs: - - database-nightly 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 new file mode 100644 index 000000000..8a07a8758 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.circleci/config.yml @@ -0,0 +1,530 @@ +# CircleCI configuration file for building, testing, and deploying. +# +# This configuration file uses the "docker" executor to run the Docker stack. +# +# A "runner" container, created from a specified container image, is used to +# checkout source code and run commands defined in this file. Application Docker +# containers defined in `docker-compose.yml` run on a *remote* Docker server +# controlled by CircleCI. +# The "runner" container uses Docker client to control the remote Docker server. +version: '2.1' + +aliases: + # 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" + + # 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" + + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + + # Shared runner container configuration applied to each job. + - &runner_config + working_directory: &working_directory ~/project + environment: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + 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:__VERSION__ + 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" + # 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" + # 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: + # Database handling is a first step of the build. + # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump + # should be downloaded for the current build. Usually, a daily database dump + # is sufficient for development activities. + # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. + # This allows to rely on the cache from the previous days within the same branch. + 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). + - __VERSION__{{ 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. + - __VERSION__{{ 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 + + # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + paths: + - /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: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint + # Enforce fresh DB build (do not rely on fallback caches). + VORTEX_CI_DB_CACHE_FALLBACK: 'no' + # Always use fresh base image for the database (if database-in-image storage is used). + VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ + # Deploy container image (if database-in-image storage is used). + VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 + # Do not build the Drupal front-end. + VORTEX_FRONTEND_BUILD_SKIP: 1 + + # Build and test is a second step of the build. The testing is performed + # within the same job to save time on provisioning during the job. + 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 ] + + - 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 + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- + + - *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:__VERSION__ . || [ "${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" + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh + no_output_timeout: 30m + + - 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 + + - 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 + + - 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 + + # Deploy primary branches. + deploy: &job_deploy + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Check if deployment should be skipped + command: | + if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then + echo "Skipping deployment - PR from project/* branch" + circleci-agent step halt + fi + + - run: + name: Deploy + command: | + VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ + VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ + VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ + ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + + # Deploy tags. + deploy-tags: &job-deploy-tags + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Deploy + command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + +################################################################################ +# WORKFLOWS +################################################################################ + +workflows: + # Commit workflow. Runs for every commit push to the remote repository. + commit: + jobs: + - database: + filters: + tags: + only: /.*/ + - build: + requires: + - database + filters: + tags: + only: /.*/ + - deploy: + requires: + - build + filters: + branches: + # Allowed branches: + # - production, main, master, develop, ci, cisomething + # - project/description + # - deps/* + # - feature/description, feature/123-description + # - bugfix/description, bugfix/123-description + # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) + # - release/2023-04-17, release/2023-04-17.123 (date-based) + # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) + # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) + only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + tags: + ignore: /.*/ + - deploy-tags: + requires: + - build + filters: + branches: + ignore: /.*/ + tags: + # Allowed tags: + # - __VERSION__, __VERSION__ (per https://semver.org/) + # - 2023-04-17, 2023-04-17.123 (date-based) + only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + + # Nightly database workflow runs overnight to capture fresh database and cache it. + nightly-db: + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop + jobs: + - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml index e486d1b89..eb8de42e1 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -458,9 +452,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -503,11 +494,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..af52839e0 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,27 @@ +@@ -265,26 +265,6 @@ + run: docker compose exec -T cli composer normalize --dry-run + continue-on-error: ${{ vars.VORTEX_CI_COMPOSER_NORMALIZE_IGNORE_FAILURE == '1' }} + +- - name: Lint code with PHPCS +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpcs +- continue-on-error: ${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE == '1' }} +- +- - name: Lint code with PHPStan +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpstan +- continue-on-error: ${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE == '1' }} +- +- - name: Lint code with Rector +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/rector --dry-run +- continue-on-error: ${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE == '1' }} +- +- - name: Lint code with PHPMD +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml +- continue-on-error: ${{ vars.VORTEX_CI_PHPMD_IGNORE_FAILURE == '1' }} +- + - name: Lint code with Twig CS Fixer + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/twig-cs-fixer diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php index c299e4058..113f4f668 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -29,7 +29,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml index b5ce65850..6b292634e 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -413,9 +407,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -458,11 +449,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..e3c6749dd --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,78 @@ +@@ -290,11 +290,6 @@ + run: docker compose exec -T cli vendor/bin/twig-cs-fixer + continue-on-error: ${{ vars.VORTEX_CI_TWIG_CS_FIXER_IGNORE_FAILURE == '1' }} + +- - name: Lint code with Gherkin Lint +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features +- continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} +- + - name: Lint module code with NodeJS linters + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli bash -c "yarn run lint" +@@ -312,65 +307,6 @@ + docker compose cp -L .data/db.sql cli:/app/.data/db.sql + fi + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh +- timeout-minutes: 30 +- +- - name: Test with PHPUnit +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpunit +- continue-on-error: ${{ vars.VORTEX_CI_PHPUNIT_IGNORE_FAILURE == '1' }} +- +- - name: Process PHPUnit logs and coverage +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: | +- mkdir -p ".logs" +- 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/. ".logs/" +- fi +- +- - name: Check code coverage threshold +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: | +- RATE=$(grep -om1 'line-rate="[0-9.]*"' .logs/coverage/phpunit/cobertura.xml | tr -cd '0-9.') +- PERCENT=$(awk "BEGIN {printf \"%.2f\", $RATE*100}") +- echo "Coverage: $PERCENT% (threshold: $VORTEX_CI_CODE_COVERAGE_THRESHOLD%)" | tee -a "$GITHUB_STEP_SUMMARY" +- if [ "${PERCENT//./}" -lt "$((VORTEX_CI_CODE_COVERAGE_THRESHOLD*100))" ]; then +- echo "FAIL: coverage too low" +- exit 1 +- fi +- { echo "COVERAGE_CONTENT<> "$GITHUB_ENV" +- env: +- VORTEX_CI_CODE_COVERAGE_THRESHOLD: ${{ vars.VORTEX_CI_CODE_COVERAGE_THRESHOLD || '90' }} +- +- - name: Post coverage summary as PR comment +- if: ${{ github.event_name == 'pull_request' && (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_CI_CODE_COVERAGE_PR_COMMENT_SKIP != '1' }} +- uses: marocchino/sticky-pull-request-comment@__HASH__ # __VERSION__ +- with: +- message: | +- ``` +- ${{ env.COVERAGE_CONTENT }} +- ``` +- hide_and_recreate: true +- +- - name: Upload coverage report to Codecov +- uses: codecov/codecov-action@__HASH__ # __VERSION__ +- if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && env.CODECOV_TOKEN != '' }} +- with: +- directory: .logs/coverage +- fail_ci_if_error: true +- token: ${{ secrets.CODECOV_TOKEN }} +- env: +- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} +- +- - name: Test with Behat +- run: | +- # shellcheck disable=SC2170 +- if [ ${{ strategy.job-total }} -gt 1 ]; then export VORTEX_CI_BEHAT_PROFILE="${VORTEX_CI_BEHAT_PROFILE:-p${{ strategy.job-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}" +- env: +- VORTEX_CI_BEHAT_PROFILE: ${{ vars.VORTEX_CI_BEHAT_PROFILE }} +- continue-on-error: ${{ vars.VORTEX_CI_BEHAT_IGNORE_FAILURE == '1' }} + timeout-minutes: 30 + + - name: Process test logs and artifacts diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml index 9bf0fc029..90082d00a 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -475,9 +469,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -520,11 +511,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..b2e441d2e --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,20 @@ +@@ -254,7 +254,6 @@ + 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" +- docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + + - name: Audit Composer packages + run: docker compose exec -T cli composer audit +@@ -294,11 +293,6 @@ + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features + continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} +- +- - name: Lint module code with NodeJS linters +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli bash -c "yarn run lint" +- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} + + - name: Lint theme code with NodeJS linters + if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_FRONTEND_BUILD_SKIP != '1' }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml index a2e74e510..3b8f81204 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -469,9 +463,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -514,11 +505,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..d82b3fbf3 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,25 @@ +@@ -254,7 +254,6 @@ + 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" +- docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + + - name: Audit Composer packages + run: docker compose exec -T cli composer audit +@@ -294,16 +293,6 @@ + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features + continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} +- +- - name: Lint module code with NodeJS linters +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli bash -c "yarn run lint" +- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} +- +- - name: Lint theme code with NodeJS linters +- if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_FRONTEND_BUILD_SKIP != '1' }} +- run: docker compose exec -T cli bash -c "yarn --cwd=\${WEBROOT}/themes/custom/\${DRUPAL_THEME} run lint" +- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} + + - name: Provision site + run: | diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml index bee6680b1..08cda9e0e 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -466,9 +460,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -511,11 +502,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..7870f224f --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,31 @@ +@@ -290,11 +290,6 @@ + run: docker compose exec -T cli vendor/bin/twig-cs-fixer + continue-on-error: ${{ vars.VORTEX_CI_TWIG_CS_FIXER_IGNORE_FAILURE == '1' }} + +- - name: Lint code with Gherkin Lint +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features +- continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} +- + - name: Lint module code with NodeJS linters + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli bash -c "yarn run lint" +@@ -360,18 +355,6 @@ + token: ${{ secrets.CODECOV_TOKEN }} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} +- +- - name: Test with Behat +- run: | +- # shellcheck disable=SC2170 +- if [ ${{ strategy.job-total }} -gt 1 ]; then export VORTEX_CI_BEHAT_PROFILE="${VORTEX_CI_BEHAT_PROFILE:-p${{ strategy.job-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}" +- env: +- VORTEX_CI_BEHAT_PROFILE: ${{ vars.VORTEX_CI_BEHAT_PROFILE }} +- continue-on-error: ${{ vars.VORTEX_CI_BEHAT_IGNORE_FAILURE == '1' }} +- timeout-minutes: 30 + + - name: Process test logs and artifacts + if: always() diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml index 9bf0fc029..90082d00a 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -475,9 +469,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -520,11 +511,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..b2e441d2e --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,20 @@ +@@ -254,7 +254,6 @@ + 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" +- docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + + - name: Audit Composer packages + run: docker compose exec -T cli composer audit +@@ -294,11 +293,6 @@ + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features + continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} +- +- - name: Lint module code with NodeJS linters +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli bash -c "yarn run lint" +- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} + + - name: Lint theme code with NodeJS linters + if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_FRONTEND_BUILD_SKIP != '1' }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml index ba17af584..e18ac1dc9 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -476,9 +470,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,11 +512,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..da501f94e --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,12 @@ +@@ -265,11 +265,6 @@ + run: docker compose exec -T cli composer normalize --dry-run + continue-on-error: ${{ vars.VORTEX_CI_COMPOSER_NORMALIZE_IGNORE_FAILURE == '1' }} + +- - name: Lint code with PHPCS +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpcs +- continue-on-error: ${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE == '1' }} +- + - name: Lint code with PHPStan + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/phpstan diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php index 7e8bdd340..86f336226 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/tests/phpunit/CircleCiConfigTest.php @@ -30,7 +30,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml index ea20d565b..9fd82b7c8 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -476,9 +470,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,11 +512,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..7a1641d9d --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,12 @@ +@@ -280,11 +280,6 @@ + run: docker compose exec -T cli vendor/bin/rector --dry-run + continue-on-error: ${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE == '1' }} + +- - name: Lint code with PHPMD +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml +- continue-on-error: ${{ vars.VORTEX_CI_PHPMD_IGNORE_FAILURE == '1' }} +- + - name: Lint code with Twig CS Fixer + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/twig-cs-fixer diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php index a08c3184a..43859a8fc 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/tests/phpunit/CircleCiConfigTest.php @@ -33,7 +33,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml index 8e4fcaa3d..89c775a00 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -476,9 +470,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,11 +512,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..0ccbfe13c --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,12 @@ +@@ -270,11 +270,6 @@ + run: docker compose exec -T cli vendor/bin/phpcs + continue-on-error: ${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE == '1' }} + +- - name: Lint code with PHPStan +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpstan +- continue-on-error: ${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE == '1' }} +- + - name: Lint code with Rector + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/rector --dry-run diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml similarity index 96% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml index a6ef1504c..05a2b68b5 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -429,9 +423,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -474,11 +465,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..8729e7c93 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,54 @@ +@@ -314,53 +314,6 @@ + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh + timeout-minutes: 30 + +- - name: Test with PHPUnit +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/phpunit +- continue-on-error: ${{ vars.VORTEX_CI_PHPUNIT_IGNORE_FAILURE == '1' }} +- +- - name: Process PHPUnit logs and coverage +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: | +- mkdir -p ".logs" +- 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/. ".logs/" +- fi +- +- - name: Check code coverage threshold +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: | +- RATE=$(grep -om1 'line-rate="[0-9.]*"' .logs/coverage/phpunit/cobertura.xml | tr -cd '0-9.') +- PERCENT=$(awk "BEGIN {printf \"%.2f\", $RATE*100}") +- echo "Coverage: $PERCENT% (threshold: $VORTEX_CI_CODE_COVERAGE_THRESHOLD%)" | tee -a "$GITHUB_STEP_SUMMARY" +- if [ "${PERCENT//./}" -lt "$((VORTEX_CI_CODE_COVERAGE_THRESHOLD*100))" ]; then +- echo "FAIL: coverage too low" +- exit 1 +- fi +- { echo "COVERAGE_CONTENT<> "$GITHUB_ENV" +- env: +- VORTEX_CI_CODE_COVERAGE_THRESHOLD: ${{ vars.VORTEX_CI_CODE_COVERAGE_THRESHOLD || '90' }} +- +- - name: Post coverage summary as PR comment +- if: ${{ github.event_name == 'pull_request' && (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_CI_CODE_COVERAGE_PR_COMMENT_SKIP != '1' }} +- uses: marocchino/sticky-pull-request-comment@__HASH__ # __VERSION__ +- with: +- message: | +- ``` +- ${{ env.COVERAGE_CONTENT }} +- ``` +- hide_and_recreate: true +- +- - name: Upload coverage report to Codecov +- uses: codecov/codecov-action@__HASH__ # __VERSION__ +- if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && env.CODECOV_TOKEN != '' }} +- with: +- directory: .logs/coverage +- fail_ci_if_error: true +- token: ${{ secrets.CODECOV_TOKEN }} +- env: +- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} +- + - name: Test with Behat + run: | + # shellcheck disable=SC2170 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml similarity index 97% rename from .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/build-test-deploy.yml rename to .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml index 4cbbe23e9..bf6b2ad1d 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/build-test-deploy.yml +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.circleci/config.yml @@ -7,15 +7,6 @@ # containers defined in `docker-compose.yml` run on a *remote* Docker server # controlled by CircleCI. # The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci version: '2.1' aliases: @@ -27,6 +18,9 @@ aliases: # Replace this key fingerprint with your own and remove this comment. - &deploy_ssh_fingerprint "SHA256:6d+U5QubT0eAWz+4N2wt+WM2qx6o4cvyvQ6xILETJ84" + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + # Shared runner container configuration applied to each job. - &runner_config working_directory: &working_directory ~/project @@ -476,9 +470,6 @@ jobs: workflows: # Commit workflow. Runs for every commit push to the remote repository. commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] jobs: - database: filters: @@ -521,11 +512,13 @@ workflows: only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop jobs: - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml new file mode 100644 index 000000000..06a056b92 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml @@ -0,0 +1,12 @@ +@@ -275,11 +275,6 @@ + run: docker compose exec -T cli vendor/bin/phpstan + continue-on-error: ${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE == '1' }} + +- - name: Lint code with Rector +- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} +- run: docker compose exec -T cli vendor/bin/rector --dry-run +- continue-on-error: ${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE == '1' }} +- + - name: Lint code with PHPMD + if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} + run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/build-test-deploy.yml deleted file mode 100644 index 8bea7ee4d..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/build-test-deploy.yml +++ /dev/null @@ -1,537 +0,0 @@ -# CircleCI configuration file for building, testing, and deploying. -# -# This configuration file uses the "docker" executor to run the Docker stack. -# -# A "runner" container, created from a specified container image, is used to -# checkout source code and run commands defined in this file. Application Docker -# containers defined in `docker-compose.yml` run on a *remote* Docker server -# controlled by CircleCI. -# The "runner" container uses Docker client to control the remote Docker server. -# -# Scheduled pipelines: -# The `nightly-db` workflow requires a schedule trigger configured in CircleCI UI. -# Go to Project Settings > Triggers > Add Scheduled Trigger: -# - Trigger name: nightly-db -# - Config source: build-test-deploy.yml -# - Branch: develop -# - Schedule: Every day at 18:00 UTC (or a custom time) -# See https://www.vortextemplate.com/docs/continuous-integration/circleci -version: '2.1' - -aliases: - # 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" - - # 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" - - # Shared runner container configuration applied to each job. - - &runner_config - working_directory: &working_directory ~/project - environment: - VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint - 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:__VERSION__ - 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" - # 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" - # 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: - # Database handling is a first step of the build. - # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump - # should be downloaded for the current build. Usually, a daily database dump - # is sufficient for development activities. - # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. - # This allows to rely on the cache from the previous days within the same branch. - 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). - - __VERSION__{{ 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. - - __VERSION__{{ 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 - - # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} - paths: - - /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: - VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint - VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint - # Enforce fresh DB build (do not rely on fallback caches). - VORTEX_CI_DB_CACHE_FALLBACK: 'no' - # Always use fresh base image for the database (if database-in-image storage is used). - VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ - # Deploy container image (if database-in-image storage is used). - VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 - # Do not build the Drupal front-end. - VORTEX_FRONTEND_BUILD_SKIP: 1 - - # Build and test is a second step of the build. The testing is performed - # within the same job to save time on provisioning during the job. - 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 ] - - - 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 - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} - - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- - - - *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:__VERSION__ . || [ "${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" - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 ] - - - 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 - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh - no_output_timeout: 30m - - - 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 - - - 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 - - - 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 - - # Deploy primary branches. - deploy: &job_deploy - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Check if deployment should be skipped - command: | - if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then - echo "Skipping deployment - PR from project/* branch" - circleci-agent step halt - fi - - - run: - name: Deploy - command: | - VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ - VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ - VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ - ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - path: *artifacts - - # Deploy tags. - deploy-tags: &job-deploy-tags - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - - checkout - - *step_process_codebase_for_ci - - *load_variables_from_dotenv - - - run: - name: Deploy - command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh - no_output_timeout: 30m - - - store_artifacts: - path: *artifacts - -################################################################################ -# WORKFLOWS -################################################################################ - -workflows: - # Commit workflow. Runs for every commit push to the remote repository. - commit: - when: - not: - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - jobs: - - database: - filters: - tags: - only: /.*/ - - build: - requires: - - database - filters: - tags: - only: /.*/ - - deploy: - requires: - - build - filters: - branches: - # Allowed branches: - # - production, main, master, develop, ci, cisomething - # - project/description - # - deps/* - # - feature/description, feature/123-description - # - bugfix/description, bugfix/123-description - # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) - # - release/2023-04-17, release/2023-04-17.123 (date-based) - # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) - # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) - only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - tags: - ignore: /.*/ - - deploy-tags: - requires: - - build - filters: - branches: - ignore: /.*/ - tags: - # Allowed tags: - # - __VERSION__, __VERSION__ (per https://semver.org/) - # - 2023-04-17, 2023-04-17.123 (date-based) - only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ - - # Nightly database workflow runs overnight to capture fresh database and cache it. - # Requires a "nightly-db" schedule trigger configured in CircleCI UI. - nightly-db: - when: - and: - - equal: [scheduled_pipeline, << pipeline.trigger_source >>] - - equal: ["nightly-db", << pipeline.schedule.name >>] - jobs: - - database-nightly 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 new file mode 100644 index 000000000..8a07a8758 --- /dev/null +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.circleci/config.yml @@ -0,0 +1,530 @@ +# CircleCI configuration file for building, testing, and deploying. +# +# This configuration file uses the "docker" executor to run the Docker stack. +# +# A "runner" container, created from a specified container image, is used to +# checkout source code and run commands defined in this file. Application Docker +# containers defined in `docker-compose.yml` run on a *remote* Docker server +# controlled by CircleCI. +# The "runner" container uses Docker client to control the remote Docker server. +version: '2.1' + +aliases: + # 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" + + # 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" + + # Schedule to run nightly database build (to cache the database for the next day). + - &nightly_db_schedule "0 18 * * *" + + # Shared runner container configuration applied to each job. + - &runner_config + working_directory: &working_directory ~/project + environment: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + 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:__VERSION__ + 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" + # 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" + # 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: + # Database handling is a first step of the build. + # - $VORTEX_CI_DB_CACHE_TIMESTAMP is used to determine if a fresh DB dump + # should be downloaded for the current build. Usually, a daily database dump + # is sufficient for development activities. + # - $VORTEX_CI_DB_CACHE_FALLBACK is used if the cache did not match $VORTEX_CI_DB_CACHE_TIMESTAMP. + # This allows to rely on the cache from the previous days within the same branch. + 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). + - __VERSION__{{ 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. + - __VERSION__{{ 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 + + # 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: __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + paths: + - /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: + VORTEX_DOWNLOAD_DB_SSH_FINGERPRINT: *db_ssh_fingerprint + VORTEX_DEPLOY_SSH_FINGERPRINT: *deploy_ssh_fingerprint + # Enforce fresh DB build (do not rely on fallback caches). + VORTEX_CI_DB_CACHE_FALLBACK: 'no' + # Always use fresh base image for the database (if database-in-image storage is used). + VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:__VERSION__ + # Deploy container image (if database-in-image storage is used). + VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 + # Do not build the Drupal front-end. + VORTEX_FRONTEND_BUILD_SKIP: 1 + + # Build and test is a second step of the build. The testing is performed + # within the same job to save time on provisioning during the job. + 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 ] + + - 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 + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - __VERSION__{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- + + - *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:__VERSION__ . || [ "${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" + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 ] + + - 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 + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh + no_output_timeout: 30m + + - 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 + + - 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 + + - 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 + + # Deploy primary branches. + deploy: &job_deploy + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Check if deployment should be skipped + command: | + if [ "${CIRCLE_PULL_REQUEST}" != "" ] && echo "${CIRCLE_BRANCH}" | grep -q "^project/"; then + echo "Skipping deployment - PR from project/* branch" + circleci-agent step halt + fi + + - run: + name: Deploy + command: | + VORTEX_DEPLOY_BRANCH="${CIRCLE_BRANCH}" \ + VORTEX_DEPLOY_PR="$(echo ${CIRCLE_PULL_REQUEST} | cut -d'/' -f 7)" \ + VORTEX_DEPLOY_PR_HEAD=${CIRCLE_SHA1} \ + ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + + # Deploy tags. + deploy-tags: &job-deploy-tags + <<: *runner_config + steps: + - attach_workspace: + at: /tmp/workspace + + - add_ssh_keys: + fingerprints: + - *deploy_ssh_fingerprint + + - checkout + - *step_process_codebase_for_ci + - *load_variables_from_dotenv + + - run: + name: Deploy + command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh + no_output_timeout: 30m + + - store_artifacts: + path: *artifacts + +################################################################################ +# WORKFLOWS +################################################################################ + +workflows: + # Commit workflow. Runs for every commit push to the remote repository. + commit: + jobs: + - database: + filters: + tags: + only: /.*/ + - build: + requires: + - database + filters: + tags: + only: /.*/ + - deploy: + requires: + - build + filters: + branches: + # Allowed branches: + # - production, main, master, develop, ci, cisomething + # - project/description + # - deps/* + # - feature/description, feature/123-description + # - bugfix/description, bugfix/123-description + # - release/__VERSION__, release/__VERSION__ (per https://semver.org/) + # - release/2023-04-17, release/2023-04-17.123 (date-based) + # - hotfix/__VERSION__, hotfix/__VERSION__ (per https://semver.org/) + # - hotfix/2023-04-17, hotfix/2023-04-17.123 (date-based) + only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^(release|hotfix)\/[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^(release|hotfix)\/[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + tags: + ignore: /.*/ + - deploy-tags: + requires: + - build + filters: + branches: + ignore: /.*/ + tags: + # Allowed tags: + # - __VERSION__, __VERSION__ (per https://semver.org/) + # - 2023-04-17, 2023-04-17.123 (date-based) + only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + + # Nightly database workflow runs overnight to capture fresh database and cache it. + nightly-db: + triggers: + - schedule: + cron: *nightly_db_schedule + filters: + branches: + only: + - develop + jobs: + - database-nightly diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.github/workflows/-build-test-deploy.yml deleted file mode 100644 index e69de29bb..000000000 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php index 59f25d19c..f79f32706 100644 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php +++ b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } diff --git a/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php index b455fa2d2..a6a02ae7d 100644 --- a/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/CiProviderHandlerProcessTest.php @@ -32,8 +32,8 @@ public static function dataProviderHandlerProcess(): array { Env::put(AiCodeInstructions::envName(), Env::TRUE); }), static::cw(function (FunctionalTestCase $test): void { - $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', '1.x'); - $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', '2.x'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', '1.x'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', '2.x'); }), ], ]; diff --git a/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php index e2575549f..c87b6470f 100644 --- a/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/MigrationHandlerProcessTest.php @@ -50,7 +50,7 @@ public static function dataProviderHandlerProcess(): array { $test->assertDirectoryExists(static::$sut . '/web/modules/custom/ys_migrate'); $test->assertFileContainsString(static::$sut . '/composer.json', 'drupal/migrate_plus'); $test->assertFileContainsString(static::$sut . '/composer.json', 'drupal/migrate_tools'); - $test->assertFileContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'Download migration DB'); + $test->assertFileContainsString(static::$sut . '/.circleci/config.yml', 'Download migration DB'); }), ], @@ -88,7 +88,7 @@ public static function dataProviderHandlerProcess(): array { $test->assertDirectoryDoesNotExist(static::$sut . '/web/modules/custom/ys_migrate'); $test->assertFileNotContainsString(static::$sut . '/composer.json', 'drupal/migrate_plus'); $test->assertFileNotContainsString(static::$sut . '/composer.json', 'drupal/migrate_tools'); - $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'Download migration DB'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', 'Download migration DB'); }), ], diff --git a/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php b/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php index 37c272105..803f87b96 100644 --- a/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php +++ b/.vortex/installer/tests/Functional/Handlers/TimezoneHandlerProcessTest.php @@ -49,8 +49,8 @@ public static function dataProviderHandlerProcess(): array { static::cw(function (FunctionalTestCase $test): void { // Timezone should not be replaced in CircleCI config in code as it // should be overridden via UI. - $test->assertFileNotContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'TZ: America/New_York'); - $test->assertFileContainsString(static::$sut . '/.circleci/build-test-deploy.yml', 'TZ: UTC'); + $test->assertFileNotContainsString(static::$sut . '/.circleci/config.yml', 'TZ: America/New_York'); + $test->assertFileContainsString(static::$sut . '/.circleci/config.yml', 'TZ: UTC'); }), ], ]; diff --git a/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php b/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php index 5cfb94cf4..93dc176b4 100644 --- a/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php +++ b/.vortex/installer/tests/Unit/Handlers/CiProviderHandlerDiscoveryTest.php @@ -37,7 +37,7 @@ function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { [CiProvider::id() => CiProvider::CIRCLECI] + $expected_installed, function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { $test->stubVortexProject($config); - File::dump(static::$sut . '/.circleci/build-test-deploy.yml'); + File::dump(static::$sut . '/.circleci/config.yml'); }, ], diff --git a/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php b/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php index 607460caf..a5bae6392 100644 --- a/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php +++ b/.vortex/installer/tests/Unit/Handlers/DependencyUpdatesProviderHandlerDiscoveryTest.php @@ -43,7 +43,7 @@ function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { function (AbstractHandlerDiscoveryTestCase $test, Config $config): void { $test->stubVortexProject($config); File::dump(static::$sut . '/renovate.json'); - File::dump(static::$sut . '/.circleci/build-test-deploy.yml', 'update-dependencies'); + File::dump(static::$sut . '/.circleci/config.yml', 'update-dependencies'); }, ], diff --git a/.vortex/tests/generate-vortex-dev-circleci b/.vortex/tests/generate-vortex-dev-circleci index f93daa875..6f8c5ab78 100755 --- a/.vortex/tests/generate-vortex-dev-circleci +++ b/.vortex/tests/generate-vortex-dev-circleci @@ -4,7 +4,7 @@ declare(strict_types=1); /** - * Generate .circleci/vortex-test-common.yml from build-test-deploy.yml. + * Generate .circleci/vortex-test-common.yml from config.yml. * * Extracts aliases, database and build jobs from the main CircleCI config * and assembles them with DIDI variant jobs into a single test config. @@ -17,7 +17,7 @@ declare(strict_types=1); $check_mode = in_array('--check', $argv ?? []); $root_dir = dirname(__DIR__, 2); -$source_file = $root_dir . '/.circleci/build-test-deploy.yml'; +$source_file = $root_dir . '/.circleci/config.yml'; $output_file = $root_dir . '/.circleci/vortex-test-common.yml'; $content = file_get_contents($source_file); @@ -34,7 +34,7 @@ $build_job = extract_job($lines, '/^ build: &job_build/'); $output = implode("\n", [ '# Auto-generated by .vortex/tests/generate-vortex-dev-circleci', - '# Source: .circleci/build-test-deploy.yml', + '# Source: .circleci/config.yml', '# Do not edit directly.', "version: '2.1'", '', diff --git a/.vortex/tests/phpunit/Traits/SutTrait.php b/.vortex/tests/phpunit/Traits/SutTrait.php index 898b53e93..f8e68f62a 100644 --- a/.vortex/tests/phpunit/Traits/SutTrait.php +++ b/.vortex/tests/phpunit/Traits/SutTrait.php @@ -267,7 +267,7 @@ protected function assertCommonFilesAbsent(string $webroot = 'web'): void { // Documentation and CI files that should not exist in some contexts. $this->assertFileDoesNotExist('.ahoy.yml'); - $this->assertFileDoesNotExist('.circleci/build-test-deploy.yml'); + $this->assertFileDoesNotExist('.circleci/config.yml'); $this->assertFileDoesNotExist('.github/workflows/build-test-deploy.yml'); $this->assertFileDoesNotExist('README.md'); $this->assertFileDoesNotExist('docs/faqs.md'); @@ -409,8 +409,8 @@ protected function assertVortexFilesPresent(string $webroot = 'web'): void { $this->assertFileDoesNotExist('.github/workflows/vortex-test-common.yml'); $this->assertFileDoesNotExist('.github/workflows/vortex-test-installer.yml'); - if (file_exists('.circleci/build-test-deploy.yml')) { - $this->assertFileNotContainsString('.circleci/build-test-deploy.yml', 'vortex-dev', 'CircleCI config should not contain development Vortex references'); + if (file_exists('.circleci/config.yml')) { + $this->assertFileNotContainsString('.circleci/config.yml', 'vortex-dev', 'CircleCI config should not contain development Vortex references'); } // Assert that documentation was processed correctly. diff --git a/tests/phpunit/CircleCiConfigTest.php b/tests/phpunit/CircleCiConfigTest.php index 0cfe21908..5beaafefe 100644 --- a/tests/phpunit/CircleCiConfigTest.php +++ b/tests/phpunit/CircleCiConfigTest.php @@ -34,7 +34,7 @@ class CircleCiConfigTest extends TestCase { */ protected function setUp(): void { parent::setUp(); - $file = file_get_contents(__DIR__ . '/../../.circleci/build-test-deploy.yml'); + $file = file_get_contents(__DIR__ . '/../../.circleci/config.yml'); if (!$file) { throw new \RuntimeException('Unable to read CircleCI config file.'); } From d77692a007cbf648d92025f3e5729e3891b248bb Mon Sep 17 00:00:00 2001 From: Alex Skrypnyk Date: Mon, 9 Mar 2026 14:50:11 +1100 Subject: [PATCH 3/3] Updated snapshots. --- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 77 ------------------ .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 21 ----- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 27 ------- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 78 ------------------- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 20 ----- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 25 ------ .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 31 -------- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 20 ----- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 --- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 --- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 --- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 54 ------------- .../.github/workflows/-build-test-deploy.yml | 0 .../.github/workflows/build-test-deploy.yml | 12 --- .../.github/workflows/-build-test-deploy.yml | 0 32 files changed, 401 deletions(-) create mode 100644 .vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.github/workflows/-build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/-build-test-deploy.yml delete mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml create mode 100644 .vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.github/workflows/-build-test-deploy.yml diff --git a/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/ciprovider_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_all_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index 09e1781d4..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/deploy_types_none_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,77 +0,0 @@ -@@ -406,76 +406,3 @@ - timeout-minutes: 120 # Cancel the action after 15 minutes, regardless of whether a connection has been established. - with: - detached: true -- -- deploy: -- runs-on: ubuntu-latest -- needs: build -- if: ${{ github.event_name != 'schedule' && !startsWith(github.head_ref || github.ref_name, 'deps/') && (github.event_name == 'push' || !startsWith(github.head_ref, 'project/')) }} -- -- container: -- # https://hub.docker.com/r/drevops/ci-runner -- image: drevops/ci-runner:__VERSION__ -- env: -- TZ: ${{ vars.TZ || 'UTC' }} -- TERM: xterm-256color -- VORTEX_SSH_DISABLE_STRICT_HOST_KEY_CHECKING: "1" -- VORTEX_DEBUG: ${{ vars.VORTEX_DEBUG }} -- -- steps: -- - name: Preserve $HOME set in the container -- run: echo HOME=/root >> "$GITHUB_ENV" # https://github.com/actions/runner/issues/863 -- -- - name: Checkout code -- uses: actions/checkout@__HASH__ # __VERSION__ -- with: -- # Fetch all history for git repository. -- fetch-depth: 0 -- # Do not persist credentials after checkout -- # to allow using the custom credentials to push to a remote repo. -- persist-credentials: false -- ref: ${{ github.head_ref || github.ref_name }} -- -- - name: Load environment variables from .env -- run: t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && set +a && . "${t}" && env >> "$GITHUB_ENV" -- -- - name: Download exported codebase as an artifact -- uses: actions/download-artifact@__HASH__ # __VERSION__ -- if: ${{ contains(env.VORTEX_DEPLOY_TYPES, 'artifact') }} -- with: -- name: code-artifact -- path: "/tmp/artifacts" -- -- - name: Unpack downloaded exported codebase -- if: ${{ contains(env.VORTEX_DEPLOY_TYPES, 'artifact') }} -- run: | -- mkdir -p /tmp/workspace -- tar -xpf /tmp/artifacts/code.tar -C /tmp/workspace -- -- - name: Add SSH private key to the runner -- if: ${{ env.VORTEX_DEPLOY_SSH_PRIVATE_KEY != '' }} -- uses: shimataro/ssh-key-action@__VERSION__ -- with: -- key: ${{ secrets.VORTEX_DEPLOY_SSH_PRIVATE_KEY }} -- known_hosts: unnecessary -- env: -- VORTEX_DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.VORTEX_DEPLOY_SSH_PRIVATE_KEY }} -- -- - name: Deploy -- run: ./scripts/vortex/deploy.sh -- env: -- VORTEX_DEPLOY_MODE: ${{ startsWith(github.ref, 'refs/tags/') && 'tag' || 'branch' }} -- # Get branch for PR from 'head_ref' or for branch from 'ref_name'. -- VORTEX_DEPLOY_BRANCH: ${{ github.head_ref || github.ref_name }} -- VORTEX_DEPLOY_PR: ${{ github.event.number }} -- VORTEX_DEPLOY_PR_HEAD: ${{ github.event.pull_request.head.sha }} -- VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code -- VORTEX_DEPLOY_ARTIFACT_ROOT: ${{ github.workspace }} -- VORTEX_DEPLOY_ARTIFACT_GIT_REMOTE: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_REMOTE }} -- VORTEX_DEPLOY_ARTIFACT_GIT_USER_EMAIL: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_USER_EMAIL }} -- VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME }} -- VORTEX_DEPLOY_WEBHOOK_URL: ${{ vars.VORTEX_DEPLOY_WEBHOOK_URL }} -- VORTEX_DEPLOY_SKIP: ${{ vars.VORTEX_DEPLOY_SKIP }} -- VORTEX_DEPLOY_ALLOW_SKIP: ${{ vars.VORTEX_DEPLOY_ALLOW_SKIP }} -- VORTEX_DEPLOY_SKIP_PRS: ${{ vars.VORTEX_DEPLOY_SKIP_PRS }} -- VORTEX_DEPLOY_SKIP_BRANCHES: ${{ vars.VORTEX_DEPLOY_SKIP_BRANCHES }} -- timeout-minutes: 30 diff --git a/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/deps_updates_provider_ci_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_disabled_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index 81974f68d..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,21 +0,0 @@ -@@ -128,6 +128,9 @@ - echo "db_hash=${{ hashFiles('.data') }}" >> "$GITHUB_ENV" - timeout-minutes: 30 - -+ - name: Download migration DB -+ run: VORTEX_VAR_PREFIX=VORTEX_DOWNLOAD_DB2 ./scripts/vortex/download-db.sh -+ - - name: Export DB - run: | - if [ ! -f /tmp/download-db-success ]; then echo "==> Database download semaphore file is missing. DB export will not proceed."; exit 0; fi -@@ -310,6 +313,10 @@ - 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 -+ 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 - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh - timeout-minutes: 30 diff --git a/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/timezone_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index af52839e0..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_lint_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,27 +0,0 @@ -@@ -265,26 +265,6 @@ - run: docker compose exec -T cli composer normalize --dry-run - continue-on-error: ${{ vars.VORTEX_CI_COMPOSER_NORMALIZE_IGNORE_FAILURE == '1' }} - -- - name: Lint code with PHPCS -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpcs -- continue-on-error: ${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE == '1' }} -- -- - name: Lint code with PHPStan -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpstan -- continue-on-error: ${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE == '1' }} -- -- - name: Lint code with Rector -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/rector --dry-run -- continue-on-error: ${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE == '1' }} -- -- - name: Lint code with PHPMD -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml -- continue-on-error: ${{ vars.VORTEX_CI_PHPMD_IGNORE_FAILURE == '1' }} -- - - name: Lint code with Twig CS Fixer - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/twig-cs-fixer diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index e3c6749dd..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,78 +0,0 @@ -@@ -290,11 +290,6 @@ - run: docker compose exec -T cli vendor/bin/twig-cs-fixer - continue-on-error: ${{ vars.VORTEX_CI_TWIG_CS_FIXER_IGNORE_FAILURE == '1' }} - -- - name: Lint code with Gherkin Lint -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features -- continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} -- - - name: Lint module code with NodeJS linters - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli bash -c "yarn run lint" -@@ -312,65 +307,6 @@ - docker compose cp -L .data/db.sql cli:/app/.data/db.sql - fi - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh -- timeout-minutes: 30 -- -- - name: Test with PHPUnit -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpunit -- continue-on-error: ${{ vars.VORTEX_CI_PHPUNIT_IGNORE_FAILURE == '1' }} -- -- - name: Process PHPUnit logs and coverage -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: | -- mkdir -p ".logs" -- 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/. ".logs/" -- fi -- -- - name: Check code coverage threshold -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: | -- RATE=$(grep -om1 'line-rate="[0-9.]*"' .logs/coverage/phpunit/cobertura.xml | tr -cd '0-9.') -- PERCENT=$(awk "BEGIN {printf \"%.2f\", $RATE*100}") -- echo "Coverage: $PERCENT% (threshold: $VORTEX_CI_CODE_COVERAGE_THRESHOLD%)" | tee -a "$GITHUB_STEP_SUMMARY" -- if [ "${PERCENT//./}" -lt "$((VORTEX_CI_CODE_COVERAGE_THRESHOLD*100))" ]; then -- echo "FAIL: coverage too low" -- exit 1 -- fi -- { echo "COVERAGE_CONTENT<> "$GITHUB_ENV" -- env: -- VORTEX_CI_CODE_COVERAGE_THRESHOLD: ${{ vars.VORTEX_CI_CODE_COVERAGE_THRESHOLD || '90' }} -- -- - name: Post coverage summary as PR comment -- if: ${{ github.event_name == 'pull_request' && (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_CI_CODE_COVERAGE_PR_COMMENT_SKIP != '1' }} -- uses: marocchino/sticky-pull-request-comment@__HASH__ # __VERSION__ -- with: -- message: | -- ``` -- ${{ env.COVERAGE_CONTENT }} -- ``` -- hide_and_recreate: true -- -- - name: Upload coverage report to Codecov -- uses: codecov/codecov-action@__HASH__ # __VERSION__ -- if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && env.CODECOV_TOKEN != '' }} -- with: -- directory: .logs/coverage -- fail_ci_if_error: true -- token: ${{ secrets.CODECOV_TOKEN }} -- env: -- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} -- -- - name: Test with Behat -- run: | -- # shellcheck disable=SC2170 -- if [ ${{ strategy.job-total }} -gt 1 ]; then export VORTEX_CI_BEHAT_PROFILE="${VORTEX_CI_BEHAT_PROFILE:-p${{ strategy.job-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}" -- env: -- VORTEX_CI_BEHAT_PROFILE: ${{ vars.VORTEX_CI_BEHAT_PROFILE }} -- continue-on-error: ${{ vars.VORTEX_CI_BEHAT_IGNORE_FAILURE == '1' }} - timeout-minutes: 30 - - - name: Process test logs and artifacts diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index b2e441d2e..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,20 +0,0 @@ -@@ -254,7 +254,6 @@ - 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" -- docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" - - - name: Audit Composer packages - run: docker compose exec -T cli composer audit -@@ -294,11 +293,6 @@ - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features - continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} -- -- - name: Lint module code with NodeJS linters -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli bash -c "yarn run lint" -- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} - - - name: Lint theme code with NodeJS linters - if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_FRONTEND_BUILD_SKIP != '1' }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index d82b3fbf3..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,25 +0,0 @@ -@@ -254,7 +254,6 @@ - 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" -- docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" - - - name: Audit Composer packages - run: docker compose exec -T cli composer audit -@@ -294,16 +293,6 @@ - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features - continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} -- -- - name: Lint module code with NodeJS linters -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli bash -c "yarn run lint" -- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} -- -- - name: Lint theme code with NodeJS linters -- if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_FRONTEND_BUILD_SKIP != '1' }} -- run: docker compose exec -T cli bash -c "yarn --cwd=\${WEBROOT}/themes/custom/\${DRUPAL_THEME} run lint" -- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} - - - name: Provision site - run: | diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index 7870f224f..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_behat_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,31 +0,0 @@ -@@ -290,11 +290,6 @@ - run: docker compose exec -T cli vendor/bin/twig-cs-fixer - continue-on-error: ${{ vars.VORTEX_CI_TWIG_CS_FIXER_IGNORE_FAILURE == '1' }} - -- - name: Lint code with Gherkin Lint -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features -- continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} -- - - name: Lint module code with NodeJS linters - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli bash -c "yarn run lint" -@@ -360,18 +355,6 @@ - token: ${{ secrets.CODECOV_TOKEN }} - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} -- -- - name: Test with Behat -- run: | -- # shellcheck disable=SC2170 -- if [ ${{ strategy.job-total }} -gt 1 ]; then export VORTEX_CI_BEHAT_PROFILE="${VORTEX_CI_BEHAT_PROFILE:-p${{ strategy.job-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}" -- env: -- VORTEX_CI_BEHAT_PROFILE: ${{ vars.VORTEX_CI_BEHAT_PROFILE }} -- continue-on-error: ${{ vars.VORTEX_CI_BEHAT_IGNORE_FAILURE == '1' }} -- timeout-minutes: 30 - - - name: Process test logs and artifacts - if: always() diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index b2e441d2e..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_eslint_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,20 +0,0 @@ -@@ -254,7 +254,6 @@ - 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" -- docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c "yarn install --frozen-lockfile" - - - name: Audit Composer packages - run: docker compose exec -T cli composer audit -@@ -294,11 +293,6 @@ - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features - continue-on-error: ${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE == '1' }} -- -- - name: Lint module code with NodeJS linters -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli bash -c "yarn run lint" -- continue-on-error: ${{ vars.VORTEX_CI_NODEJS_LINT_IGNORE_FAILURE == '1' }} - - - name: Lint theme code with NodeJS linters - if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_FRONTEND_BUILD_SKIP != '1' }} diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index da501f94e..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpcs_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,12 +0,0 @@ -@@ -265,11 +265,6 @@ - run: docker compose exec -T cli composer normalize --dry-run - continue-on-error: ${{ vars.VORTEX_CI_COMPOSER_NORMALIZE_IGNORE_FAILURE == '1' }} - -- - name: Lint code with PHPCS -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpcs -- continue-on-error: ${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE == '1' }} -- - - name: Lint code with PHPStan - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/phpstan diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index 7a1641d9d..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpmd_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,12 +0,0 @@ -@@ -280,11 +280,6 @@ - run: docker compose exec -T cli vendor/bin/rector --dry-run - continue-on-error: ${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE == '1' }} - -- - name: Lint code with PHPMD -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml -- continue-on-error: ${{ vars.VORTEX_CI_PHPMD_IGNORE_FAILURE == '1' }} -- - - name: Lint code with Twig CS Fixer - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/twig-cs-fixer diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index 0ccbfe13c..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpstan_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,12 +0,0 @@ -@@ -270,11 +270,6 @@ - run: docker compose exec -T cli vendor/bin/phpcs - continue-on-error: ${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE == '1' }} - -- - name: Lint code with PHPStan -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpstan -- continue-on-error: ${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE == '1' }} -- - - name: Lint code with Rector - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/rector --dry-run diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index 8729e7c93..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_phpunit_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,54 +0,0 @@ -@@ -314,53 +314,6 @@ - docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli ./scripts/vortex/provision.sh - timeout-minutes: 30 - -- - name: Test with PHPUnit -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/phpunit -- continue-on-error: ${{ vars.VORTEX_CI_PHPUNIT_IGNORE_FAILURE == '1' }} -- -- - name: Process PHPUnit logs and coverage -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: | -- mkdir -p ".logs" -- 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/. ".logs/" -- fi -- -- - name: Check code coverage threshold -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: | -- RATE=$(grep -om1 'line-rate="[0-9.]*"' .logs/coverage/phpunit/cobertura.xml | tr -cd '0-9.') -- PERCENT=$(awk "BEGIN {printf \"%.2f\", $RATE*100}") -- echo "Coverage: $PERCENT% (threshold: $VORTEX_CI_CODE_COVERAGE_THRESHOLD%)" | tee -a "$GITHUB_STEP_SUMMARY" -- if [ "${PERCENT//./}" -lt "$((VORTEX_CI_CODE_COVERAGE_THRESHOLD*100))" ]; then -- echo "FAIL: coverage too low" -- exit 1 -- fi -- { echo "COVERAGE_CONTENT<> "$GITHUB_ENV" -- env: -- VORTEX_CI_CODE_COVERAGE_THRESHOLD: ${{ vars.VORTEX_CI_CODE_COVERAGE_THRESHOLD || '90' }} -- -- - name: Post coverage summary as PR comment -- if: ${{ github.event_name == 'pull_request' && (matrix.instance == 0 || strategy.job-total == 1) && vars.VORTEX_CI_CODE_COVERAGE_PR_COMMENT_SKIP != '1' }} -- uses: marocchino/sticky-pull-request-comment@__HASH__ # __VERSION__ -- with: -- message: | -- ``` -- ${{ env.COVERAGE_CONTENT }} -- ``` -- hide_and_recreate: true -- -- - name: Upload coverage report to Codecov -- uses: codecov/codecov-action@__HASH__ # __VERSION__ -- if: ${{ (matrix.instance == 0 || strategy.job-total == 1) && env.CODECOV_TOKEN != '' }} -- with: -- directory: .logs/coverage -- fail_ci_if_error: true -- token: ${{ secrets.CODECOV_TOKEN }} -- env: -- CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} -- - - name: Test with Behat - run: | - # shellcheck disable=SC2170 diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml deleted file mode 100644 index 06a056b92..000000000 --- a/.vortex/installer/tests/Fixtures/handler_process/tools_no_rector_circleci/.github/workflows/build-test-deploy.yml +++ /dev/null @@ -1,12 +0,0 @@ -@@ -275,11 +275,6 @@ - run: docker compose exec -T cli vendor/bin/phpstan - continue-on-error: ${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE == '1' }} - -- - name: Lint code with Rector -- if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} -- run: docker compose exec -T cli vendor/bin/rector --dry-run -- continue-on-error: ${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE == '1' }} -- - - name: Lint code with PHPMD - if: ${{ matrix.instance == 0 || strategy.job-total == 1 }} - run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml diff --git a/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.github/workflows/-build-test-deploy.yml b/.vortex/installer/tests/Fixtures/handler_process/tools_no_stylelint_circleci/.github/workflows/-build-test-deploy.yml new file mode 100644 index 000000000..e69de29bb