diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index ac4866706..3e821562f 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -1,40 +1,380 @@ +# GitHub Actions configuration file. +# +# This configuration file uses a custom "container" executor to run the +# Docker stack to speed up the build process. +#; +#; Comments starting with '#;<' and '#;>' are internal Vortex comments +#; and will be removed during installation or update of Vortex. name: Database, Build, Test and Deploy on: + # Pushes to the following branches will trigger the workflow. push: branches: + - production - main + - master - develop + - release/** + - hotfix/** + - project/** + + # Pull requests to the following branches will trigger the workflow. pull_request: types: - opened - synchronize - reopened branches: + - production - main + - master - develop - - 'feature/**' + - release/** + - hotfix/** + - project/** + + workflow_dispatch: + inputs: + enable_terminal: + type: boolean + description: 'Enable terminal session.' + required: false + default: false + #;< !PROVISION_USE_PROFILE + schedule: + - cron: '0 18 * * *' + #;> !PROVISION_USE_PROFILE + +defaults: + run: + shell: bash jobs: + #;< !PROVISION_USE_PROFILE database: runs-on: ubuntu-latest container: image: drevops/ci-runner:24.9.0 + env: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_CONTAINER_REGISTRY_USER: ${{ secrets.VORTEX_CONTAINER_REGISTRY_USER }} + VORTEX_CONTAINER_REGISTRY_PASS: ${{ secrets.VORTEX_CONTAINER_REGISTRY_PASS }} + VORTEX_DEBUG: ${{ vars.VORTEX_DEBUG }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # 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" + steps: - - name: Debug vars - run: | - echo VORTEX_DEPLOY_BRANCH - echo "${{ github.ref_name }}" - echo --- - echo VORTEX_DEPLOY_PR - echo 1 - echo "${{ github.event.number }}" - echo 2 - echo "${{ github.pull_request.number }}" - echo 3 - echo "${{ github.ref }}" - echo --- - echo VORTEX_DEPLOY_PR_HEAD - echo "${{ github.sha }}" + - name: Preserve $HOME set in the container + run: echo HOME=/root >> "$GITHUB_ENV" # @see https://github.com/actions/runner/issues/863 + + - name: Check out code + uses: actions/checkout@v4 + + - name: Process the codebase to run in CI + run: find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e '/###/d' {} && sed -i -e 's/##//' {}" + + - name: Create cache keys files for database caching + run: | + echo "${VORTEX_CI_DB_CACHE_BRANCH}" | tee db_cache_branch + echo "${VORTEX_CI_DB_CACHE_FALLBACK/no/"${GITHUB_RUN_NUMBER}"}" | tee db_cache_fallback + echo "yes" | tee db_cache_fallback_yes + date "${VORTEX_CI_DB_CACHE_TIMESTAMP}" | tee db_cache_timestamp + + # Restore DB cache based on the cache strategy set by the cache keys below. + # 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). + - name: Restore DB cache + uses: actions/cache/restore@v4 + with: + path: .data + key: v24.9.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback') }}-${{ hashFiles('db_cache_timestamp') }} + # Fallback to caching by default branch name only. Allows to use + # cache from the branch build on the previous day. + restore-keys: | + v24.9.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback') }}- + + - name: Download DB + run: | + VORTEX_DB_DOWNLOAD_SEMAPHORE=/tmp/download-db-success ./scripts/vortex/download-db.sh + echo "db_hash=${{ hashFiles('.data') }}" >> "$GITHUB_ENV" + timeout-minutes: 30 + + - 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 + ./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 cli bash -c "VORTEX_PROVISION_POST_OPERATIONS_SKIP=1 ./scripts/vortex/provision.sh" + ./scripts/vortex/export-db.sh db.sql + timeout-minutes: 30 + continue-on-error: true + + # 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. + - name: Save DB cache + uses: actions/cache/save@v4 + if: env.db_hash != hashFiles('.data') + with: + path: .data + key: v24.9.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }} + #;> !PROVISION_USE_PROFILE + + build: + runs-on: ubuntu-latest + needs: database + #;< !PROVISION_USE_PROFILE + if: github.event_name != 'schedule' + #;> !PROVISION_USE_PROFILE + + strategy: + matrix: + instance: [0, 1] + fail-fast: false + + container: + image: drevops/ci-runner:24.9.0 + + env: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_CONTAINER_REGISTRY_USER: ${{ secrets.VORTEX_CONTAINER_REGISTRY_USER }} + VORTEX_CONTAINER_REGISTRY_PASS: ${{ secrets.VORTEX_CONTAINER_REGISTRY_PASS }} + VORTEX_DEBUG: ${{ vars.VORTEX_DEBUG }} + #;< !PROVISION_USE_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_USE_PROFILE + + steps: + - name: Preserve $HOME set in the container + run: echo HOME=/root >> "$GITHUB_ENV" # @see https://github.com/actions/runner/issues/863 + + - name: Check out code + uses: actions/checkout@v4 + + - name: Process the codebase to run in CI + run: find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e '/###/d' {} && sed -i -e 's/##//' {}" + + #;< !PROVISION_USE_PROFILE + - name: Create cache keys files for database caching + run: | + echo "${VORTEX_CI_DB_CACHE_BRANCH}" | tee db_cache_branch + echo "yes" | tee db_cache_fallback_yes + date "${VORTEX_CI_DB_CACHE_TIMESTAMP}" | tee db_cache_timestamp + + - name: Show cache key for database caching + run: echo 'v24.9.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }}' + + # Restore DB cache based on the cache strategy set by the cache keys below. + # 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). + - name: Restore DB cache + uses: actions/cache/restore@v4 + with: + path: .data + fail-on-cache-miss: true + # Use cached database from previous builds of this branch. + key: v24.9.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }} + restore-keys: | + v24.9.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}- + #;> !PROVISION_USE_PROFILE + + - name: Lint Dockerfiles with Hadolint + run: | + find .docker -name 'Dockerfile' -o -name '*.dockerfile' | while read -r file; do + echo "Linting ${file}" && cat "${file}" | docker run --rm -i hadolint/hadolint || [ "${{ vars.VORTEX_CI_HADOLINT_IGNORE_FAILURE }}" = "1" ] + done + + - name: Login to container registry + run: ./scripts/vortex/login-container-registry.sh + + - name: Build stack + run: docker compose up -d + + - name: Export built codebase + if: matrix.instance == 0 + run: | + mkdir -p "/tmp/workspace/code" + docker compose cp -L cli:"/app/." "/tmp/workspace/code" + + - name: Upload exported codebase as artifact + uses: actions/upload-artifact@v4 + if: matrix.instance == 0 + with: + name: code-artifact + path: "/tmp/workspace/code" + include-hidden-files: true + if-no-files-found: error + + - name: Validate Composer configuration + run: docker compose exec cli composer validate --strict || [ "${{ vars.VORTEX_CI_COMPOSER_VALIDATE_IGNORE_FAILURE }}" = "1" ] + + - name: Install development dependencies + run: | + docker compose exec $(env | cut -f1 -d= | sed 's/^/-e /') -T cli bash -c " \ + if [ -n \"${GITHUB_TOKEN:-}\" ]; then export COMPOSER_AUTH='{\"github-oauth\": {\"github.com\": \"${GITHUB_TOKEN-}\"}}'; fi && \ + COMPOSER_MEMORY_LIMIT=-1 composer --ansi install --prefer-dist" + + - name: Lint code with PHPCS + run: docker compose exec -T cli vendor/bin/phpcs || [ "${{ vars.VORTEX_CI_PHPCS_IGNORE_FAILURE }}" = "1" ] + + - name: Lint code with PHPStan + run: docker compose exec -T cli vendor/bin/phpstan || [ "${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE }}" = "1" ] + + - name: Lint code with Rector + run: docker compose exec -T cli vendor/bin/rector --clear-cache --dry-run || [ "${{ vars.VORTEX_CI_RECTOR_IGNORE_FAILURE }}" = "1" ] + + - name: Lint code with PHPMD + run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml || [ "${{ vars.VORTEX_CI_PHPMD_IGNORE_FAILURE }}" = "1" ] + + - name: Lint code with Twig CS Fixer + run: docker compose exec -T cli vendor/bin/twig-cs-fixer || [ "${{ vars.VORTEX_CI_TWIG_CS_FIXER_IGNORE_FAILURE }}" = "1" ] + + - name: Lint code with Gherkin Lint + run: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features || [ "${{ vars.VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE }}" = "1" ] + + - name: Lint code with NPM linters + run: docker compose exec -T cli bash -c "npm run --prefix \${VORTEX_WEBROOT}/themes/custom/\${DRUPAL_THEME} lint" || [ "${{ vars.VORTEX_CI_NPM_LINT_IGNORE_FAILURE }}" = "1" ] + + - name: Provision site + run: | + 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 + timeout-minutes: 30 + + - name: Test with PHPUnit + run: | + XDEBUG_ENABLE=true docker compose up -d cli php nginx # Restart stack with XDEBUG enabled for coverage. + docker compose exec -T -e XDEBUG_MODE=coverage cli vendor/bin/phpunit || [ "${{ vars.VORTEX_CI_PHPUNIT_IGNORE_FAILURE }}" = "1" ] + docker compose up -d cli php nginx # Restart stack without XDEBUG enabled for coverage. + + - 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}" || \ + [ "${{ vars.VORTEX_CI_BEHAT_IGNORE_FAILURE }}" = "1" ] + env: + VORTEX_CI_BEHAT_PROFILE: ${{ vars.VORTEX_CI_BEHAT_PROFILE }} + timeout-minutes: 30 + + - name: Process test logs and artifacts + if: always() + 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: Upload test artifacts + uses: actions/upload-artifact@v4 + with: + name: test-artifacts-${{ matrix.instance }} + path: .logs + include-hidden-files: true + if-no-files-found: error + + - name: Upload coverage report to Codecov + uses: codecov/codecov-action@v4 + if: ${{ env.CODECOV_TOKEN != '' }} + with: + directory: .logs/coverage + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + - name: Setup tmate session + if: ${{ !cancelled() && github.event.inputs.enable_terminal }} + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 120 # Cancel the action after 15 minutes, regardless of whether a connection has been established. + with: + detached: true + + #;< DEPLOYMENT + deploy: + + runs-on: ubuntu-latest + needs: build + #;< !PROVISION_USE_PROFILE + if: github.event_name != 'schedule' + #;> !PROVISION_USE_PROFILE + + container: + image: drevops/ci-runner:24.9.0 + env: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_DEBUG: ${{ vars.VORTEX_DEBUG }} + + steps: + - name: Preserve $HOME set in the container + run: echo HOME=/root >> "$GITHUB_ENV" # @see https://github.com/actions/runner/issues/863 + + - name: Checkout code + uses: actions/checkout@v4 + 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: Download exported codebase as an artifact + uses: actions/download-artifact@v4 + with: + name: code-artifact + path: "/tmp/workspace/code" + + - name: Add SSH private key to the runner + if: ${{ env.VORTEX_DEPLOY_SSH_PRIVATE_KEY != '' }} + uses: shimataro/ssh-key-action@v2 + with: + key: ${{ secrets.VORTEX_DEPLOY_SSH_PRIVATE_KEY }} + known_hosts: ${{ secrets.VORTEX_DEPLOY_SSH_KNOWN_HOSTS }} + env: + VORTEX_DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.VORTEX_DEPLOY_SSH_PRIVATE_KEY }} + + - name: Deploy + run: ./scripts/vortex/deploy.sh + env: + # 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.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 }} + timeout-minutes: 30 + #;> DEPLOYMENT diff --git a/.github/workflows/vortex-test-common.yml b/.github/workflows/vortex-test-common.yml index 1a65ba443..983772646 100644 --- a/.github/workflows/vortex-test-common.yml +++ b/.github/workflows/vortex-test-common.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest container: - image: drevops/ci-runner:latest + image: drevops/ci-runner:24.9.0 env: # Prevent GitHub overriding the Docker config. DOCKER_CONFIG: /root/.docker @@ -89,7 +89,7 @@ jobs: batch: [0, 1, 2] container: - image: drevops/ci-runner:latest + image: drevops/ci-runner:24.9.0 env: # Prevent GitHub overriding the Docker config. DOCKER_CONFIG: /root/.docker @@ -141,7 +141,7 @@ jobs: batch: [0, 1] container: - image: drevops/ci-runner:latest + image: drevops/ci-runner:24.9.0 env: # Prevent GitHub overriding the Docker config. DOCKER_CONFIG: /root/.docker @@ -179,6 +179,7 @@ jobs: - name: Run tests run: ./tests/test.deployment.sh working-directory: .vortex + timeout-minutes: 10 - name: Upload coverage report as an artifact uses: actions/upload-artifact@v4 diff --git a/.vortex/docs/static/img/diagram-dark.png b/.vortex/docs/static/img/diagram-dark.png index c2ee3bd37..ee86e35f9 100644 Binary files a/.vortex/docs/static/img/diagram-dark.png and b/.vortex/docs/static/img/diagram-dark.png differ diff --git a/.vortex/docs/static/img/diagram-light.png b/.vortex/docs/static/img/diagram-light.png index eb38c02d8..5148064db 100644 Binary files a/.vortex/docs/static/img/diagram-light.png and b/.vortex/docs/static/img/diagram-light.png differ diff --git a/.vortex/installer/src/Command/InstallCommand.php b/.vortex/installer/src/Command/InstallCommand.php index 27fcfbef6..7a358da8d 100644 --- a/.vortex/installer/src/Command/InstallCommand.php +++ b/.vortex/installer/src/Command/InstallCommand.php @@ -167,6 +167,7 @@ protected function replaceTokens() { 'database_download_source', 'database_image', 'override_existing_db', + 'ci_provider', 'deploy_type', 'preserve_acquia', 'preserve_lagoon', @@ -415,6 +416,46 @@ protected function processOverrideExistingDb(string $dir) { } } + protected function processCiProvider(string $dir) { + $type = $this->getAnswer('ci_provider'); + + $remove_gha = FALSE; + $remove_circleci = FALSE; + + switch ($type) { + case 'CircleCI': + $remove_gha = TRUE; + break; + + case 'GitHub Actions': + $remove_circleci = TRUE; + break; + + default: + $remove_circleci = TRUE; + $remove_gha = TRUE; + } + + if ($remove_gha) { + @unlink($dir . '/.github/workflows/build-test-deploy.yml'); + $this->removeTokenWithContent('CI_PROVIDER_GHA', $dir); + } + + if ($remove_circleci) { + static::rmdirRecursive($dir . '/.circleci'); + @unlink($dir . '/tests/phpunit/CircleCiConfigTest.php'); + $this->removeTokenWithContent('CI_PROVIDER_CIRCLECI', $dir); + } + + if ($remove_gha && $remove_circleci) { + @unlink($dir . '/docs/ci.md'); + $this->removeTokenWithContent('CI_PROVIDER_ANY', $dir); + } + else { + $this->removeTokenWithContent('!CI_PROVIDER_ANY', $dir); + } + } + protected function processDeployType(string $dir) { $type = $this->getAnswer('deploy_type'); if ($type != 'none') { @@ -762,6 +803,8 @@ protected function collectAnswers() { $this->askForAnswer('override_existing_db', 'Do you want to override existing database in the environment?'); + $this->askForAnswer('ci_provider', 'Which provider do you want to use for CI ([c]ircleci, [g]ithub actions, [n]one)?'); + $this->askForAnswer('deploy_type', 'How do you deploy your code to the hosting ([w]ebhook call, [c]ode artifact, [d]ocker image, [l]agoon, [n]one as a comma-separated list)?'); if ($this->getAnswer('database_download_source') != 'ftp') { @@ -1059,6 +1102,10 @@ protected function getDefaultValueOverrideExistingDb(): string { return self::ANSWER_NO; } + protected function getDefaultValueCiProvider(): string { + return 'GitHub Actions'; + } + protected function getDefaultValueDeployType(): string { return 'artifact'; } @@ -1294,6 +1341,18 @@ protected function discoverValueOverrideExistingDb(): string { return $this->getValueFromDstDotenv('VORTEX_PROVISION_OVERRIDE_DB') ? self::ANSWER_YES : self::ANSWER_NO; } + protected function discoverValueCiProvider() { + if (is_readable($this->getDstDir() . '/.github/workflows/build-test-deploy.yml')) { + return 'GitHub Actions'; + } + + if (is_readable($this->getDstDir() . '/.circleci/config.yml')) { + return 'CircleCI'; + } + + return $this->isInstalled() ? 'none' : NULL; + } + protected function discoverValueDeployType() { return $this->getValueFromDstDotenv('VORTEX_DEPLOY_TYPES'); } @@ -1501,6 +1560,23 @@ protected function normaliseAnswerOverrideExistingDb($value): string { return strtolower((string) $value) !== self::ANSWER_YES ? self::ANSWER_NO : self::ANSWER_YES; } + protected function normaliseAnswerCiProvider($value): string { + $value = trim(strtolower((string) $value)); + + switch ($value) { + case 'c': + case 'circleci': + return 'CircleCI'; + + case 'g': + case 'gha': + case 'github actions': + return 'GitHub Actions'; + } + + return 'none'; + } + protected function normaliseAnswerDeployType($value): ?string { $types = explode(',', (string) $value); @@ -1669,6 +1745,7 @@ protected function printSummary() { } $values['Override existing database'] = $this->formatYesNo($this->getAnswer('override_existing_db')); + $values['CI provider'] = $this->formatNotEmpty($this->getAnswer('ci_provider'), 'None'); $values['Deployment'] = $this->formatNotEmpty($this->getAnswer('deploy_type'), 'Disabled'); $values['FTP integration'] = $this->formatEnabled($this->getAnswer('preserve_ftp')); $values['Acquia integration'] = $this->formatEnabled($this->getAnswer('preserve_acquia')); diff --git a/.vortex/tests/bats/_helper.bash b/.vortex/tests/bats/_helper.bash index 3c9b1d45f..d1934c044 100644 --- a/.vortex/tests/bats/_helper.bash +++ b/.vortex/tests/bats/_helper.bash @@ -34,7 +34,9 @@ setup() { fi if [ -n "${DOCKER_DEFAULT_PLATFORM:-}" ]; then - step "Using ${DOCKER_DEFAULT_PLATFORM} platform architecture." + if [ "${BATS_VERBOSE_RUN:-}" = "1" ] || [ "${TEST_VORTEX_DEBUG:-}" = "1" ]; then + step "Using ${DOCKER_DEFAULT_PLATFORM} platform architecture." + fi fi # LCOV_EXCL_STOP @@ -283,6 +285,7 @@ assert_files_not_present_common() { assert_file_not_exists ".ahoy.yml" assert_file_not_exists "README.md" + assert_file_not_exists ".github/workflows/build-test-deploy.yml" assert_file_not_exists ".circleci/config.yml" assert_file_not_exists "${webroot}/sites/default/settings.php" assert_file_not_exists "${webroot}/sites/default/services.yml" @@ -305,8 +308,6 @@ assert_files_present_vortex() { pushd "${dir}" >/dev/null || exit 1 - assert_file_exists ".circleci/config.yml" - assert_file_exists ".docker/cli.dockerfile" assert_file_exists ".docker/mariadb.dockerfile" assert_file_exists ".docker/nginx-drupal.dockerfile" @@ -403,7 +404,6 @@ assert_files_present_vortex() { assert_file_exists "phpunit.xml" # Documentation information present. - assert_file_exists "docs/ci.md" assert_file_exists "docs/faqs.md" assert_file_exists "README.md" assert_file_exists "docs/releasing.md" @@ -415,8 +415,14 @@ assert_files_present_vortex() { assert_file_not_exists "CODE_OF_CONDUCT.md" assert_file_not_exists ".github/FUNDING.yml" - assert_file_not_exists ".github/vortex-publish-docs.yml" - assert_file_not_exists ".github/vortex-test-docs.yml" + assert_file_exists ".github/workflows/assign-author.yml" + assert_file_exists ".github/workflows/label-merge-conflict.yml" + assert_file_exists ".github/workflows/draft-release-notes.yml" + + assert_file_not_exists ".github/workflows/vortex-release-docs.yml" + assert_file_not_exists ".github/workflows/vortex-test-docs.yml" + assert_file_not_exists ".github/workflows/vortex-test-common.yml" + assert_file_not_exists ".github/workflows/vortex-test-installer.yml" assert_file_not_contains ".circleci/config.yml" "vortex-dev-test" assert_file_not_contains ".circleci/config.yml" "vortex-dev-test-workflow" @@ -596,6 +602,16 @@ assert_files_present_provision_use_profile() { assert_file_not_contains "README.md" "ahoy download-db" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "database:" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "schedule:" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "VORTEX_CI_DB_CACHE_TIMESTAMP" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "VORTEX_CI_DB_CACHE_FALLBACK" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "VORTEX_CI_DB_CACHE_BRANCH" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "Save DB cache" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "Restore DB cache" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "Create cache keys files for database caching" + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "Show cache key for database caching" + assert_file_not_contains ".circleci/config.yml" "db_ssh_fingerprint" assert_file_not_contains ".circleci/config.yml" "/root/project/.data" assert_file_not_contains ".circleci/config.yml" "nightly_db_schedule" @@ -624,17 +640,31 @@ assert_files_present_no_provision_use_profile() { assert_file_contains "README.md" "ahoy download-db" - assert_file_contains ".circleci/config.yml" "db_ssh_fingerprint" - assert_file_contains ".circleci/config.yml" "/root/project/.data" - assert_file_contains ".circleci/config.yml" "nightly_db_schedule" - assert_file_contains ".circleci/config.yml" "VORTEX_DB_DOWNLOAD_SSH_FINGERPRINT" - assert_file_contains ".circleci/config.yml" "VORTEX_CI_DB_CACHE_TIMESTAMP" - assert_file_contains ".circleci/config.yml" "VORTEX_CI_DB_CACHE_FALLBACK" - assert_file_contains ".circleci/config.yml" "VORTEX_CI_DB_CACHE_BRANCH" - assert_file_contains ".circleci/config.yml" "database: &job-database" - assert_file_contains ".circleci/config.yml" "database-nightly" - assert_file_contains ".circleci/config.yml" "name: Set cache keys for database caching" - assert_file_contains ".circleci/config.yml" "- database:" + if [ -f ".github/workflows/build-test-deploy.yml" ]; then + assert_file_contains ".github/workflows/build-test-deploy.yml" "database:" + assert_file_contains ".github/workflows/build-test-deploy.yml" "schedule:" + assert_file_contains ".github/workflows/build-test-deploy.yml" "VORTEX_CI_DB_CACHE_TIMESTAMP" + assert_file_contains ".github/workflows/build-test-deploy.yml" "VORTEX_CI_DB_CACHE_FALLBACK" + assert_file_contains ".github/workflows/build-test-deploy.yml" "VORTEX_CI_DB_CACHE_BRANCH" + assert_file_contains ".github/workflows/build-test-deploy.yml" "Save DB cache" + assert_file_contains ".github/workflows/build-test-deploy.yml" "Restore DB cache" + assert_file_contains ".github/workflows/build-test-deploy.yml" "Create cache keys files for database caching" + assert_file_contains ".github/workflows/build-test-deploy.yml" "Show cache key for database caching" + fi + + if [ -f ".circleci/config.yml" ]; then + assert_file_contains ".circleci/config.yml" "db_ssh_fingerprint" + assert_file_contains ".circleci/config.yml" "/root/project/.data" + assert_file_contains ".circleci/config.yml" "nightly_db_schedule" + assert_file_contains ".circleci/config.yml" "VORTEX_DB_DOWNLOAD_SSH_FINGERPRINT" + assert_file_contains ".circleci/config.yml" "VORTEX_CI_DB_CACHE_TIMESTAMP" + assert_file_contains ".circleci/config.yml" "VORTEX_CI_DB_CACHE_FALLBACK" + assert_file_contains ".circleci/config.yml" "VORTEX_CI_DB_CACHE_BRANCH" + assert_file_contains ".circleci/config.yml" "database: &job-database" + assert_file_contains ".circleci/config.yml" "database-nightly" + assert_file_contains ".circleci/config.yml" "name: Set cache keys for database caching" + assert_file_contains ".circleci/config.yml" "- database:" + fi popd >/dev/null || exit 1 } @@ -661,6 +691,79 @@ assert_files_present_no_override_existing_db() { popd >/dev/null || exit 1 } +assert_files_present_ci_provider_gha() { + local dir="${1:-$(pwd)}" + local suffix="${2:-star_wars}" + + pushd "${dir}" >/dev/null || exit 1 + + assert_file_exists ".github/workflows/build-test-deploy.yml" + assert_file_contains "README.md" "[![Database, Build, Test and Deploy" + assert_file_contains "README.md" "docs/ci.md" + assert_file_contains "docs/ci.md" "GitHub Actions" + + assert_files_present_no_ci_provider_circleci "$dir" "$suffix" + + popd >/dev/null || exit 1 +} + +assert_files_present_no_ci_provider_gha() { + local dir="${1:-$(pwd)}" + local suffix="${2:-star_wars}" + + pushd "${dir}" >/dev/null || exit 1 + + assert_file_not_exists ".github/workflows/build-test-deploy.yml" + assert_file_not_contains "README.md" "[![Database, Build, Test and Deploy" + assert_file_not_contains "docs/ci.md" "GitHub Actions" + + popd >/dev/null || exit 1 +} + +assert_files_present_ci_provider_circleci() { + local dir="${1:-$(pwd)}" + local suffix="${2:-star_wars}" + + pushd "${dir}" >/dev/null || exit 1 + + assert_file_exists ".circleci/config.yml" + assert_file_contains "README.md" "[![CircleCI" + assert_file_contains "README.md" "docs/ci.md" + assert_file_contains "docs/ci.md" "CircleCI" + + assert_files_present_no_ci_provider_gha "$dir" "$suffix" + + popd >/dev/null || exit 1 +} + +assert_files_present_no_ci_provider_circleci() { + local dir="${1:-$(pwd)}" + local suffix="${2:-star_wars}" + + pushd "${dir}" >/dev/null || exit 1 + + assert_file_not_exists ".circleci/config.yml" + assert_file_not_contains "README.md" "[![CircleCI" + assert_file_not_contains "docs/ci.md" "CircleCI" + + popd >/dev/null || exit 1 +} + +assert_files_present_ci_provider_none() { + local dir="${1:-$(pwd)}" + local suffix="${2:-star_wars}" + + pushd "${dir}" >/dev/null || exit 1 + + assert_files_present_no_ci_provider_gha "$dir" "$suffix" + assert_files_present_no_ci_provider_circleci "$dir" "$suffix" + + assert_file_not_exists "docs/ci.md" + assert_file_not_contains "README.md" "docs/ci.md" + + popd >/dev/null || exit 1 +} + assert_files_present_deployment() { local dir="${1:-$(pwd)}" local suffix="${2:-star_wars}" @@ -668,8 +771,15 @@ assert_files_present_deployment() { pushd "${dir}" >/dev/null || exit 1 assert_file_exists "docs/deployment.md" - assert_file_contains ".circleci/config.yml" "deploy: &job_deploy" - assert_file_contains ".circleci/config.yml" "deploy-tags: &job-deploy-tags" + + if [ -f ".github/workflows/build-test-deploy.yml" ]; then + assert_file_contains ".github/workflows/build-test-deploy.yml" "deploy:" + fi + + if [ -f ".circleci/config.yml" ]; then + assert_file_contains ".circleci/config.yml" "deploy: &job_deploy" + assert_file_contains ".circleci/config.yml" "deploy-tags: &job-deploy-tags" + fi popd >/dev/null || exit 1 } @@ -687,6 +797,8 @@ assert_files_present_no_deployment() { # 'Required' files can be asserted for modifications only if they were not # committed. if [ "${has_committed_files:-}" -eq 0 ]; then + assert_file_not_contains ".github/workflows/build-test-deploy.yml" "deploy:" + assert_file_not_contains ".circleci/config.yml" "deploy: &job_deploy" assert_file_not_contains ".circleci/config.yml" "deploy-tags: &job-deploy-tags" assert_file_not_contains ".circleci/config.yml" "- deploy:" @@ -853,8 +965,12 @@ assert_files_present_integration_renovatebot() { assert_file_exists "renovate.json" - assert_file_contains ".circleci/config.yml" "renovatebot-self-hosted" - assert_file_contains ".circleci/config.yml" "renovatebot_schedule" + if [ -f ".circleci/config.yml" ]; then + assert_file_contains ".circleci/config.yml" "renovatebot-self-hosted" + assert_file_contains ".circleci/config.yml" "renovatebot_schedule" + fi + + # @todo Add assertions for self-hosted Renovatebot in GitHub Actions. popd >/dev/null || exit 1 } @@ -872,6 +988,7 @@ assert_files_present_no_integration_renovatebot() { assert_file_not_contains ".circleci/config.yml" "renovatebot-self-hosted" assert_file_not_contains ".circleci/config.yml" "renovatebot_schedule" + # @todo Add assertions for self-hosted Renovatebot in GitHub Actions. popd >/dev/null || exit 1 } @@ -1101,8 +1218,8 @@ prepare_local_repo() { fi git_init 0 "${dir}" - [ "$(git config --global user.name)" = "" ] && echo "Configuring global git user name." && git config --global user.name "Some User" - [ "$(git config --global user.email)" = "" ] && echo "Configuring global git user email." && git config --global user.email "some.user@example.com" + [ "$(git config --global user.name)" = "" ] && echo "Configuring global test git user name." && git config --global user.name "Some User" + [ "$(git config --global user.email)" = "" ] && echo "Configuring global test git user email." && git config --global user.email "some.user@example.com" commit=$(git_add_all_commit "Initial commit" "${dir}") echo "${commit}" diff --git a/.vortex/tests/bats/deployment1.bats b/.vortex/tests/bats/deployment1.bats index 7bd8ea1a0..76931debb 100644 --- a/.vortex/tests/bats/deployment1.bats +++ b/.vortex/tests/bats/deployment1.bats @@ -136,6 +136,7 @@ load _helper.deployment.bash "nothing" # database_download_source "nothing" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "lagoon" # deploy_type "n" # preserve_ftp "n" # preserve_acquia @@ -235,6 +236,7 @@ load _helper.deployment.bash "nothing" # webroot "y" # provision_use_profile "n" # override_existing_db + "nothing" # ci_provider "lagoon" # deploy_type "n" # preserve_ftp "n" # preserve_acquia diff --git a/.vortex/tests/bats/install.existing.bats b/.vortex/tests/bats/install.existing.bats index 73eb919cb..53e63fc31 100644 --- a/.vortex/tests/bats/install.existing.bats +++ b/.vortex/tests/bats/install.existing.bats @@ -378,6 +378,7 @@ load _helper.bash assert_files_present_common assert_files_present_provision_use_profile + assert_files_present_ci_provider_gha assert_files_present_deployment assert_files_present_no_integration_acquia assert_files_present_no_integration_lagoon @@ -399,6 +400,7 @@ load _helper.bash assert_files_present_common assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_gha assert_files_present_deployment assert_files_present_no_integration_acquia assert_files_present_no_integration_lagoon @@ -408,6 +410,94 @@ load _helper.bash assert_files_present_override_existing_db } +@test "Install into existing: previously installed project; CI Provider - GHA; discovery; quiet" { + # Populate current dir with a project at current version. + run_installer_quiet + + # Assert files at current version. + assert_files_present + assert_git_repo + + mktouch "${CURRENT_PROJECT_DIR}/.github/workflows/build-test-deploy.yml" + rm -Rf "${CURRENT_PROJECT_DIR}/.circleci/config.yml" + + output=$(run_installer_quiet) + assert_output_contains "WELCOME TO VORTEX QUIET INSTALLER" + assert_output_contains "It looks like Vortex is already installed into this project" + + assert_git_repo + + install_dependencies_stub + + assert_files_present_common + assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_gha + assert_files_present_deployment + assert_files_present_no_integration_acquia + assert_files_present_no_integration_lagoon + assert_files_present_no_integration_ftp + assert_files_present_integration_renovatebot +} + +@test "Install into existing: previously installed project; CI Provider - CircleCI; discovery; quiet" { + # Populate current dir with a project at current version. + run_installer_quiet + + # Assert files at current version. + assert_files_present + assert_git_repo + + rm -Rf "${CURRENT_PROJECT_DIR}/.github/workflows/build-test-deploy.yml" + mktouch "${CURRENT_PROJECT_DIR}/.circleci/config.yml" + + output=$(run_installer_quiet) + assert_output_contains "WELCOME TO VORTEX QUIET INSTALLER" + assert_output_contains "It looks like Vortex is already installed into this project" + + assert_git_repo + + install_dependencies_stub + + assert_files_present_common + assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_circleci + assert_files_present_deployment + assert_files_present_no_integration_acquia + assert_files_present_no_integration_lagoon + assert_files_present_no_integration_ftp + assert_files_present_integration_renovatebot +} + +@test "Install into existing: previously installed project; CI Provider - None; discovery; quiet" { + # Populate current dir with a project at current version. + run_installer_quiet + + # Assert files at current version. + assert_files_present + assert_git_repo + + rm -Rf "${CURRENT_PROJECT_DIR}/.github/workflows/build-test-deploy.yml" + rm -Rf "${CURRENT_PROJECT_DIR}/.circleci/config.yml" + rm -Rf "${CURRENT_PROJECT_DIR}/docs/ci.md" + + output=$(run_installer_quiet) + assert_output_contains "WELCOME TO VORTEX QUIET INSTALLER" + assert_output_contains "It looks like Vortex is already installed into this project" + + assert_git_repo + + install_dependencies_stub + + assert_files_present_common + assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_none + assert_files_present_deployment + assert_files_present_no_integration_acquia + assert_files_present_no_integration_lagoon + assert_files_present_no_integration_ftp + assert_files_present_integration_renovatebot +} + @test "Install into existing: previously installed project; Deployment; discovery; quiet" { echo "VORTEX_DEPLOY_TYPES=lagoon" >>".env" @@ -421,6 +511,7 @@ load _helper.bash assert_files_present_common assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_gha assert_files_present_deployment assert_files_present_no_integration_acquia assert_files_present_integration_lagoon @@ -448,6 +539,7 @@ load _helper.bash assert_files_present_common assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_gha assert_files_present_deployment assert_files_present_integration_acquia assert_files_present_no_integration_lagoon @@ -475,6 +567,7 @@ load _helper.bash assert_files_present_common assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_gha assert_files_present_deployment assert_files_present_no_integration_acquia assert_files_present_integration_lagoon @@ -502,6 +595,7 @@ load _helper.bash assert_files_present_common assert_files_present_no_provision_use_profile + assert_files_present_ci_provider_gha assert_files_present_deployment assert_files_present_no_integration_acquia assert_files_present_no_integration_lagoon diff --git a/.vortex/tests/bats/install.initial.bats b/.vortex/tests/bats/install.initial.bats index 48f6e58d0..48f7690bf 100644 --- a/.vortex/tests/bats/install.initial.bats +++ b/.vortex/tests/bats/install.initial.bats @@ -108,6 +108,7 @@ load _helper.bash "nothing" # download_db_source "nothing" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "nothing" # deploy_type "nothing" # preserve_ftp "nothing" # preserve_acquia @@ -137,10 +138,10 @@ load _helper.bash "nothing" # URL "nothing" # webroot "nothing" # provision_use_profile - "nothing" # download_db_type "nothing" # download_db_source "nothing" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "nothing" # deploy_type "nothing" # preserve_ftp "nothing" # preserve_acquia @@ -179,10 +180,10 @@ load _helper.bash "nothing" # URL "nothing" # webroot "nothing" # provision_use_profile - "nothing" # download_db_type "nothing" # download_db_source "nothing" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "nothing" # deploy_type "nothing" # preserve_ftp "nothing" # preserve_acquia diff --git a/.vortex/tests/bats/install.integrations.bats b/.vortex/tests/bats/install.integrations.bats index 9620f0fab..5eec8b4b7 100644 --- a/.vortex/tests/bats/install.integrations.bats +++ b/.vortex/tests/bats/install.integrations.bats @@ -22,6 +22,7 @@ load _helper.bash "nothing" # database_download_source "nothing" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "none" # deploy_type "no" # preserve_ftp "no" # preserve_acquia @@ -60,6 +61,7 @@ load _helper.bash "curl" # database_download_source "file" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "nothing" # deploy_type "y" # preserve_ftp "y" # preserve_acquia @@ -102,6 +104,7 @@ load _helper.bash "curl" # database_download_source "file" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "artifact" # deploy_type "y" # preserve_ftp "y" # preserve_acquia @@ -142,6 +145,7 @@ load _helper.bash "nothing" # webroot "y" # provision_use_profile "nothing" # override_existing_db + "nothing" # ci_provider "artifact" # deploy_type "n" # preserve_ftp "n" # preserve_acquia @@ -178,6 +182,7 @@ load _helper.bash "nothing" # webroot "y" # provision_use_profile "nothing" # override_existing_db + "nothing" # ci_provider "artifact" # deploy_type "n" # preserve_ftp "n" # preserve_acquia diff --git a/.vortex/tests/bats/install.parameters.bats b/.vortex/tests/bats/install.parameters.bats index 8ed68a8e1..9bec299bf 100644 --- a/.vortex/tests/bats/install.parameters.bats +++ b/.vortex/tests/bats/install.parameters.bats @@ -57,26 +57,27 @@ load _helper.bash assert_output_contains "WELCOME TO VORTEX QUIET INSTALLER" assert_output_contains "Aborting project installation. No files were changed" - assert_output_contains " Name: Star wars " - assert_output_contains " Machine name: star_wars " - assert_output_contains " Organisation: Star wars Org " - assert_output_contains " Organisation machine name: star_wars_org " - assert_output_contains " Module prefix: sw " - assert_output_contains " Profile: standard " - assert_output_contains " Theme name: star_wars " - assert_output_contains " URL: star-wars.com " - assert_output_contains " Web root: web " - assert_output_contains " Install from profile: No " - assert_output_contains " Database download source: curl " - assert_output_contains " Database store type: file " - assert_output_contains " Override existing database: No " - assert_output_contains " Deployment: artifact " - assert_output_contains " FTP integration: Disabled " - assert_output_contains " Acquia integration: Disabled " - assert_output_contains " Lagoon integration: Disabled " - assert_output_contains " RenovateBot integration: Enabled " - assert_output_contains " Preserve docs in comments: Yes " - assert_output_contains " Preserve Vortex comments: No " + assert_output_contains " Name: Star wars " + assert_output_contains " Machine name: star_wars " + assert_output_contains " Organisation: Star wars Org " + assert_output_contains " Organisation machine name: star_wars_org " + assert_output_contains " Module prefix: sw " + assert_output_contains " Profile: standard " + assert_output_contains " Theme name: star_wars " + assert_output_contains " URL: star-wars.com " + assert_output_contains " Web root: web " + assert_output_contains " Install from profile: No " + assert_output_contains " Database download source: curl " + assert_output_contains " Database store type: file " + assert_output_contains " Override existing database: No " + assert_output_contains " CI provider: GitHub Actions " + assert_output_contains " Deployment: artifact " + assert_output_contains " FTP integration: Disabled " + assert_output_contains " Acquia integration: Disabled " + assert_output_contains " Lagoon integration: Disabled " + assert_output_contains " RenovateBot integration: Enabled " + assert_output_contains " Preserve docs in comments: Yes " + assert_output_contains " Preserve Vortex comments: No " } @test "Install parameters: empty dir; defaults; interactive" { @@ -95,6 +96,7 @@ load _helper.bash "nothing" # provision_use_profile "nothing" # database_download_source "nothing" # database_store_type + "nothing" # ci_provider "nothing" # deploy_type "nothing" # preserve_ftp "nothing" # preserve_acquia @@ -107,26 +109,27 @@ load _helper.bash assert_output_contains "WELCOME TO VORTEX INTERACTIVE INSTALLER" assert_output_contains "Aborting project installation. No files were changed" - assert_output_contains " Name: Star wars " - assert_output_contains " Machine name: star_wars " - assert_output_contains " Organisation: Star wars Org " - assert_output_contains " Organisation machine name: star_wars_org " - assert_output_contains " Module prefix: sw " - assert_output_contains " Profile: standard " - assert_output_contains " Theme name: star_wars " - assert_output_contains " URL: star-wars.com " - assert_output_contains " Web root: web " - assert_output_contains " Install from profile: No " - assert_output_contains " Database download source: curl " - assert_output_contains " Database store type: file " - assert_output_contains " Override existing database: No " - assert_output_contains " Deployment: artifact " - assert_output_contains " FTP integration: Disabled " - assert_output_contains " Acquia integration: Disabled " - assert_output_contains " Lagoon integration: Disabled " - assert_output_contains " RenovateBot integration: Enabled " - assert_output_contains " Preserve docs in comments: Yes " - assert_output_contains " Preserve Vortex comments: No " + assert_output_contains " Name: Star wars " + assert_output_contains " Machine name: star_wars " + assert_output_contains " Organisation: Star wars Org " + assert_output_contains " Organisation machine name: star_wars_org " + assert_output_contains " Module prefix: sw " + assert_output_contains " Profile: standard " + assert_output_contains " Theme name: star_wars " + assert_output_contains " URL: star-wars.com " + assert_output_contains " Web root: web " + assert_output_contains " Install from profile: No " + assert_output_contains " Database download source: curl " + assert_output_contains " Database store type: file " + assert_output_contains " Override existing database: No " + assert_output_contains " CI provider: GitHub Actions " + assert_output_contains " Deployment: artifact " + assert_output_contains " FTP integration: Disabled " + assert_output_contains " Acquia integration: Disabled " + assert_output_contains " Lagoon integration: Disabled " + assert_output_contains " RenovateBot integration: Enabled " + assert_output_contains " Preserve docs in comments: Yes " + assert_output_contains " Preserve Vortex comments: No " } # Note that there is no quiet test for this scenario. @@ -137,17 +140,17 @@ load _helper.bash "star Wars" # name "star wars MaCHine" # machine_name "The Empire" # org - "the new empire" # morh_machine_name + "the new empire" # org_machine_name "s W" # module_prefix "S w Profile" # profile "light saber" # theme "resistance forever.com" # URL "nothing" # webroot "nah" # provision_use_profile - "something" # download_db_type "other thing" # database_download_source "dunno" # database_store_type - "nnnnnno" #override_existing_db + "nnnnnno" # override_existing_db + "nah" # ci_provider "nnnooo" # deploy_type "nope" # preserve_ftp "dunno" # preserve_acquia @@ -173,6 +176,7 @@ load _helper.bash assert_output_contains " Database download source: curl " assert_output_contains " Database store type: file " assert_output_contains " Override existing database: No " + assert_output_contains " CI provider: None " assert_output_contains " Deployment: Disabled " assert_output_contains " FTP integration: Disabled " assert_output_contains " Acquia integration: Disabled " @@ -189,17 +193,17 @@ load _helper.bash "star Wars" # name "star wars MaCHine" # machine_name "The Empire" # org - "the new empire" # morh_machine_name + "the new empire" # org_machine_name "s W" # module_prefix "S w Profile" # profile "light saber" # theme "resistance forever.com" # URL "rootdoc" # webroot "nah" # provision_use_profile - "something" # download_db_type "other thing" # database_download_source "dunno" # database_store_type - "nnnnnno" #override_existing_db + "nnnnnno" # override_existing_db + "nah" # ci_provider "nnnooo" # deploy_type "nope" # preserve_ftp "dunno" # preserve_acquia @@ -225,6 +229,7 @@ load _helper.bash assert_output_contains " Database download source: curl " assert_output_contains " Database store type: file " assert_output_contains " Override existing database: No " + assert_output_contains " CI provider: None " assert_output_contains " Deployment: Disabled " assert_output_contains " FTP integration: Disabled " assert_output_contains " Acquia integration: Disabled " @@ -256,6 +261,7 @@ load _helper.bash assert_output_contains " Database download source: curl " assert_output_contains " Database store type: file " assert_output_contains " Override existing database: No " + assert_output_contains " CI provider: GitHub Actions " assert_output_contains " Deployment: artifact " assert_output_contains " FTP integration: Disabled " assert_output_contains " Acquia integration: Enabled " @@ -284,6 +290,7 @@ load _helper.bash "nothing" # database_download_source "nothing" # database_store_type "nothing" # override_existing_db + "nothing" # ci_provider "nothing" # deploy_type "nothing" # preserve_ftp "nothing" # preserve_acquia @@ -310,6 +317,7 @@ load _helper.bash assert_output_contains " Database download source: curl " assert_output_contains " Database store type: file " assert_output_contains " Override existing database: No " + assert_output_contains " CI provider: GitHub Actions " assert_output_contains " Deployment: artifact " assert_output_contains " FTP integration: Disabled " assert_output_contains " Acquia integration: Enabled " @@ -332,7 +340,7 @@ load _helper.bash "star Wars" # name "star wars MaCHine" # machine_name "The Empire" # org - "the new empire" # morh_machine_name + "the new empire" # org_machine_name "W s" # module_prefix "S w Profile" # profile "light saber" # theme @@ -342,6 +350,7 @@ load _helper.bash "image" # database_download_source "image" # database_store_type "no" # override_existing_db + "circleci" # ci_provider "no" # deploy_type "Y" # preserve_ftp "nothing" # preserve_acquia - testing NOTHING value - should be 'Enabled' as exists in fixture. @@ -370,6 +379,7 @@ load _helper.bash assert_output_contains " Database download source: container_registry " assert_output_contains " Database store type: container_image " assert_output_contains " Override existing database: No " + assert_output_contains " CI provider: CircleCI " assert_output_contains " Deployment: Disabled " assert_output_contains " FTP integration: Enabled " assert_output_contains " Acquia integration: Enabled " @@ -379,7 +389,6 @@ load _helper.bash assert_output_contains " Preserve Vortex comments: No " } -# # # Helper to create fixture files to fake pre-installed state. # @@ -410,6 +419,9 @@ fixture_preinstalled() { mkdir -p "${webroot}/sites/default" echo " \$config['stage_file_proxy.settings']['origin'] = 'http://www.resistance-star-wars.com/';" >"${webroot}/sites/default/settings.php" + # Sets 'ci_provider' to 'GitHub Actions'. + mktouch ".github/workflows/build-test-deploy.yml" + # Sets 'preserve_acquia' to 'Yes'. mkdir -p hooks # Sets 'preserve_lagoon' to 'Yes'. diff --git a/.vortex/tests/test.common.sh b/.vortex/tests/test.common.sh index 972ce06a3..f8f5b602e 100755 --- a/.vortex/tests/test.common.sh +++ b/.vortex/tests/test.common.sh @@ -16,8 +16,8 @@ TEST_DIR="${ROOT_DIR}/.vortex/tests" # ------------------------------------------------------------------------------ # Configure git username and email if it is not set. -[ "$(git config --global user.name)" = "" ] && echo "==> Configuring global git user name" && git config --global user.name "Test user" -[ "$(git config --global user.email)" = "" ] && echo "==> Configuring global git user email" && git config --global user.email "someone@example.com" +[ "$(git config --global user.name)" = "" ] && echo "==> Configuring global test git user name" && git config --global user.name "Test user" +[ "$(git config --global user.email)" = "" ] && echo "==> Configuring global test git user email" && git config --global user.email "someone@example.com" # Create stub of local framework. docker network create amazeeio-network 2>/dev/null || true diff --git a/.vortex/tests/test.deployment.sh b/.vortex/tests/test.deployment.sh index 48893379b..5ab2bd568 100755 --- a/.vortex/tests/test.deployment.sh +++ b/.vortex/tests/test.deployment.sh @@ -16,8 +16,8 @@ TEST_DIR="${ROOT_DIR}/.vortex/tests" # ------------------------------------------------------------------------------ # Configure git username and email if it is not set. -[ "$(git config --global user.name)" = "" ] && echo "==> Configuring global git user name" && git config --global user.name "Test user" -[ "$(git config --global user.email)" = "" ] && echo "==> Configuring global git user email" && git config --global user.email "someone@example.com" +[ "$(git config --global user.name)" = "" ] && echo "==> Configuring global test git user name" && git config --global user.name "Test user" +[ "$(git config --global user.email)" = "" ] && echo "==> Configuring global test git user email" && git config --global user.email "someone@example.com" # Create stub of local framework. docker network create amazeeio-network 2>/dev/null || true diff --git a/.vortex/tests/test.workflow.sh b/.vortex/tests/test.workflow.sh index 923c383c1..614b4394c 100755 --- a/.vortex/tests/test.workflow.sh +++ b/.vortex/tests/test.workflow.sh @@ -16,8 +16,8 @@ TEST_DIR="${ROOT_DIR}/.vortex/tests" # ------------------------------------------------------------------------------ # Configure git username and email if it is not set. -[ "$(git config --global user.name)" = "" ] && echo "==> Configuring global git user name" && git config --global user.name "Test user" -[ "$(git config --global user.email)" = "" ] && echo "==> Configuring global git user email" && git config --global user.email "someone@example.com" +[ "$(git config --global user.name)" = "" ] && echo "==> Configuring global test git user name" && git config --global user.name "Test user" +[ "$(git config --global user.email)" = "" ] && echo "==> Configuring global test git user email" && git config --global user.email "someone@example.com" # Create stub of local framework. docker network create amazeeio-network 2>/dev/null || true diff --git a/README.dist.md b/README.dist.md index 7dac7075b..2d2cafb52 100644 --- a/README.dist.md +++ b/README.dist.md @@ -1,7 +1,18 @@ # YOURSITE Drupal 10 implementation of YOURSITE for YOURORG +[//]: # (#;< CI_PROVIDER_CIRCLECI) + [![CircleCI](https://circleci.com/gh/your_org/your_site.svg?style=shield)](https://circleci.com/gh/your_org/your_site) + +[//]: # (#;> CI_PROVIDER_CIRCLECI) + +[//]: # (#;< CI_PROVIDER_GHA) + +[![Database, Build, Test and Deploy](https://github.com/your_org/your_site/actions/workflows/build-test-deploy.yml/badge.svg)](https://github.com/your_org/your_site/actions/workflows/build-test-deploy.yml) + +[//]: # (#;> CI_PROVIDER_GHA) + ![Drupal 10](https://img.shields.io/badge/Drupal-10-blue.svg) [![codecov](https://codecov.io/gh/your_org/your_site/graph/badge.svg)](https://codecov.io/gh/your_org/your_site) @@ -59,7 +70,13 @@ to Vortex progress. Remove this section once onboarding is finished. - [FAQs](docs/faqs.md) - [Testing](docs/testing.md) + +[//]: # (#;< CI_PROVIDER_ANY) + - [CI](docs/ci.md) + +[//]: # (#;> CI_PROVIDER_ANY) + - [Releasing](docs/releasing.md) - [Deployment](docs/deployment.md) diff --git a/docs/ci.md b/docs/ci.md index 953b2f335..96e9113a6 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -5,20 +5,53 @@ all developer working copies to a shared mainline several times a day. Before feature changes can be merged into a shared mainline, a complete build must run and pass all tests on CI server. +[//]: # (#;< CI_PROVIDER_CIRCLECI) + +## Circle CI + This project uses [Circle CI](https://circleci.com/) as a CI server: it imports production backups into fully built codebase and runs code linting and tests. When tests pass, a deployment process is triggered for nominated branches -(usually, `master` and `develop`). +(usually, `main` and `develop`). Refer to https://vortex.drevops.com/latest/usage/ci for more information. -## Skipping CI build +### Skipping CI build Add `[skip ci]` to the commit subject to skip CI build. Useful for documentation changes. -## SSH +### SSH Circle CI supports shell access to the build for 120 minutes after the build is finished when the build is started with SSH support. Use "Rerun job with SSH" button in Circle CI UI to start build with SSH support. + +[//]: # (#;> CI_PROVIDER_CIRCLECI) + +[//]: # (#;< CI_PROVIDER_GHA) + +## GitHub Actions + +This project uses [GitHub Actions](https://github.com/features/actions) as a +CI server: it imports production backups into fully built codebase and runs +code linting and tests. When tests pass, a deployment process is triggered for +nominated branches (usually, `main` and `develop`). + +Refer to https://vortex.drevops.com/latest/usage/ci for more information. + +### Skipping CI build + +Add `[skip ci]` to the commit subject to skip CI build. Useful for documentation +changes. + +### SSH + +GitHub Actions does not supports shell access to the build, but there is an +action provided withing the `build` job that allows you to run a build with SSH +support. + +Use "Run workflow" button in GitHub Actions UI to start build with SSH support +that will be available for 120 minutes after the build is finished. + +[//]: # (#;> CI_PROVIDER_GHA) diff --git a/scripts/vortex/setup-ssh.sh b/scripts/vortex/setup-ssh.sh index 17e835ff2..52b13e736 100755 --- a/scripts/vortex/setup-ssh.sh +++ b/scripts/vortex/setup-ssh.sh @@ -87,11 +87,9 @@ fi note "Using SSH key file ${file}." export "${file_var}=${file}" -if [ -z "${SSH_AGENT_PID:-}" ]; then - if ! ps aux | grep "[s]sh-agent" | awk '{print $2}' >/dev/null; then - note "Starting SSH agent." - eval "$(ssh-agent)" - fi +if [ "$(ps ax | grep -c "[s]sh-agent")" -eq 0 ]; then + note "Starting SSH agent." + eval "$(ssh-agent)" fi if ssh-add -l | grep -q "${file}"; then