diff --git a/.circleci/config.yml b/.circleci/_config.yml similarity index 100% rename from .circleci/config.yml rename to .circleci/_config.yml index 3c84c34ba..b0513710e 100644 --- a/.circleci/config.yml +++ b/.circleci/_config.yml @@ -149,8 +149,8 @@ jobs: 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 - echo "$(date ${VORTEX_CI_DB_CACHE_TIMESTAMP})" | tee /tmp/db_cache_timestamp echo "yes" | tee /tmp/db_cache_fallback_yes + echo "$(date ${VORTEX_CI_DB_CACHE_TIMESTAMP})" | tee /tmp/db_cache_timestamp echo 'v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }}' - restore_cache: diff --git a/.github/workflows/assign-author.yml b/.github/workflows/assign-author.yml deleted file mode 100644 index a5e7fe1e0..000000000 --- a/.github/workflows/assign-author.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: 'Auto Author Assign' - -on: - pull_request_target: - types: - - opened - - reopened - -permissions: - pull-requests: write - -jobs: - assign-author: - runs-on: ubuntu-latest - - steps: - - name: Assign author - uses: toshimaru/auto-author-assign@v2.1.1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..885cec52a --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,394 @@ +name: Database, Build and Deploy + +on: + push: + branches: + # @todo Add properregex. + - main + - develop + pull_request: +# types: +# - opened +# - synchronize +# - reopened +# branches: + # @todo Add properregex. +# - feature/** + # schedule: + # - cron: '0 18 * * *' + + workflow_dispatch: + inputs: + enable_terminal: + type: boolean + description: 'Enable terminal session.' + required: false + default: false + +defaults: + run: + shell: bash + +jobs: + database: + runs-on: ubuntu-latest + + container: + image: drevops/ci-runner:24.8.0 + + 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 }}" +#jobs: +# database: +# runs-on: ubuntu-latest +# +# container: +# image: drevops/ci-runner:24.8.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 }} +# #;< !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" +# +# - 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 +# echo "$(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.8.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.8.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: | +# # [ ! -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 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.8.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }} +# +# build: +# runs-on: ubuntu-latest +# needs: database +# +# strategy: +# matrix: +# instance: [0, 1] +## fail-fast: false +# +# container: +# image: drevops/ci-runner:24.8.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" +# +# - 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 "yes" | tee db_cache_fallback_yes +# echo "$(date ${VORTEX_CI_DB_CACHE_TIMESTAMP})" | tee db_cache_timestamp +# +# - name: Show cache key for database caching +# run: echo 'v24.8.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.8.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}-${{ hashFiles('db_cache_timestamp') }} +# restore-keys: | +# v24.8.0-db10-${{ hashFiles('db_cache_branch') }}-${{ hashFiles('db_cache_fallback_yes') }}- +# +# - name: Lint Dockerfiles with Hadolint +# run: | +# for file in $(find .docker -name 'Dockerfile' -o -name '*.dockerfile'); do +# echo "Linting ${file}" && cat "${file}" | docker run --rm -i hadolint/hadolint || [ "${{ vars.VORTEX_CI_HADOLINT_IGNORE_FAILURE }}" -eq 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 }}" -eq 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 }}" -eq 1 ] +## +## - name: Lint code with PHPStan +## run: docker compose exec -T cli vendor/bin/phpstan || [ "${{ vars.VORTEX_CI_PHPSTAN_IGNORE_FAILURE }}" -eq 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 }}" -eq 1 ] +## +## - name: Lint code with PHPMD +## run: docker compose exec -T cli vendor/bin/phpmd . text phpmd.xml || [ "${{ vars.VORTEX_CI_PHPMD_IGNORE_FAILURE }}" -eq 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 }}" -eq 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 }}" -eq 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 }}" -eq 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 }}" -eq 1 ] +## docker compose up -d cli php nginx # Restart stack without XDEBUG enabled for coverage. +## +## - name: Test with Behat +## run: | +## 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 }}" -eq 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: 5 +## with: +## detached: true +# +# deploy: +# +# runs-on: ubuntu-latest +# needs: build +# +# container: +# image: drevops/ci-runner:24.8.0 +# env: +# TZ: Australia/Melbourne +# TERM: xterm-256color +# +# steps: +# +# - name: Preserve $HOME set in the container +# run: echo HOME=/root >> "$GITHUB_ENV" +# +# - 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: Setup 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 }} +# +# - name: Download exported codebase as artifact +# uses: actions/download-artifact@v4 +# with: +# name: code-artifact +# path: "/tmp/workspace/code" +# +# - 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: Deploy +# run: | +# VORTEX_DEPLOY_BRANCH="${{ 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} \ +# ./scripts/vortex/deploy.sh +# env: +# 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 +# +## - name: Setup tmate session +## if: always() +## uses: mxschmitt/action-tmate@v3 +## timeout-minutes: 5 +## with: +## detached: true diff --git a/.github/workflows/close-pull-request.yml b/.github/workflows/close-pull-request.yml deleted file mode 100644 index 1fcfae00c..000000000 --- a/.github/workflows/close-pull-request.yml +++ /dev/null @@ -1,26 +0,0 @@ -## -# GitHub Actions workflow to action on Pull Request closure. -# - -name: Close Pull Request - -on: - pull_request: - types: - - closed - -jobs: - remove_lagoon_environment: - runs-on: ubuntu-latest - steps: - - name: Remove environment after a PR is closed - run: | - cat "$GITHUB_EVENT_PATH" | curl \ - -X POST \ - --header "Content-Type: application/json" \ - --header "X-GitHub-Delivery: ${RUNNER_TRACKING_ID:7}" \ - --header "X-GitHub-Event: pull_request" \ - --data-binary @- \ - "${LAGOON_WEBHOOK_ENDPOINT:-https://hooks.lagoon.amazeeio.cloud/}" - env: - LAGOON_WEBHOOK_ENDPOINT: ${{ env.LAGOON_WEBHOOK_ENDPOINT }} diff --git a/.github/workflows/draft-release-notes.yml b/.github/workflows/draft-release-notes.yml deleted file mode 100644 index 605e3d0c8..000000000 --- a/.github/workflows/draft-release-notes.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Draft release notes - -on: - push: - tags: - - '*' - branches: - - develop - -permissions: - contents: write - -jobs: - release-drafter: - permissions: - contents: write - pull-requests: write - - runs-on: ubuntu-latest - - steps: - - name: Generate CalVer version - if: vars.VORTEX_RELEASE_VERSION_SCHEME == 'calver' - id: calver - run: | - export VERSION="$(date "+%y.%-m").0" - echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" - echo "Version set to ${VERSION}" - - - name: Draft release notes - uses: release-drafter/release-drafter@v6 - with: - tag: ${{ steps.calver.outputs.version }} - name: ${{ steps.calver.outputs.version }} - version: ${{ steps.calver.outputs.version }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/label-merge-conflict.yml b/.github/workflows/label-merge-conflict.yml deleted file mode 100644 index ee127e3a3..000000000 --- a/.github/workflows/label-merge-conflict.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: "Auto-label a PR with a conflict" - -on: - push: - pull_request_target: - types: - - synchronize - -jobs: - main: - runs-on: ubuntu-latest - steps: - - name: Check if PRs have conflicts - uses: eps1lon/actions-label-merge-conflict@v3 - with: - dirtyLabel: "PR: CONFLICT" - removeOnDirtyLabel: "Needs review" - repoToken: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml deleted file mode 100644 index 6a1a591a7..000000000 --- a/.github/workflows/renovate.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Renovate - -on: - schedule: - - cron: '45 11,23 * * *' - -jobs: - renovate: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4.1.7 - - - uses: suzuki-shunsuke/github-action-renovate-config-validator@v1.1.0 - - - name: Self-hosted Renovate - uses: renovatebot/github-action@v40.2.7 - with: - configurationFile: renovate.json - token: ${{ secrets.RENOVATE_TOKEN }} - env: - RENOVATE_PLATFORM: 'github' - RENOVATE_AUTODISCOVER: false - RENOVATE_REPOSITORIES: ${{ vars.RENOVATE_REPOSITORIES || github.repository }} - RENOVATE_DEPENDENCY_DASHBOARD_TITLE: 'Renovate Dependency Dashboard (self-hosted) by GitHub Actions' - RENOVATE_DEPENDENCY_DASHBOARD: ${{ vars.RENOVATE_DEPENDENCY_DASHBOARD || 'false' }} - RENOVATE_DRY_RUN: ${{ vars.RENOVATE_DRY_RUN || 'false' }} - RENOVATE_GIT_AUTHOR: ${{ vars.RENOVATE_GIT_AUTHOR || 'Renovate Self Hosted ' }} diff --git a/.github/workflows/vortex-release-docs.yml b/.github/workflows/vortex-release-docs.yml deleted file mode 100644 index 2993ac3d1..000000000 --- a/.github/workflows/vortex-release-docs.yml +++ /dev/null @@ -1,123 +0,0 @@ -# This action is used for Vortex maintenance. It will not be used in the scaffolded project. -name: Vortex - Release docs - -on: - push: - tags: - - '*' - branches: - - '**release-docs**' - - '**release-installer**' - -permissions: - contents: read - pages: write - id-token: write - -concurrency: - group: pages - cancel-in-progress: true - -jobs: - - vortex-release-installer: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Cache Composer dependencies - uses: actions/cache@v4 - with: - path: /tmp/composer-cache - key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - - - name: Install dependencies - run: composer install - working-directory: .vortex/installer - - - name: Add version - run: | - TAG=${{ github.ref_type == 'tag' && github.ref_name || '' }} - SHA=${{ github.ref_type == 'branch' && github.sha || '' }} - sed -i "s/\"git-tag-ci\": \"dev\"/\"git-tag-ci\": \"${TAG:-${SHA}}\"/g" box.json - working-directory: .vortex/installer - - - name: Build PHAR - run: composer build - working-directory: .vortex/installer - - - name: Test PHAR - run: ./build/installer --quiet || exit 1 - working-directory: .vortex/installer - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: vortex-installer - path: .vortex/installer/build/installer - - vortex-release-docs: - needs: vortex-release-installer - - environment: - name: github-pages - - runs-on: ubuntu-latest - - defaults: - run: - working-directory: docs - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - - - name: Download installer - uses: actions/download-artifact@v4 - with: - name: vortex-installer - - - name: Copy installer to docs - run: | - cp ../installer ../.vortex/docs/static/install - php ../.vortex/docs/static/install --version - - - name: Check docs up-to-date - run: | - composer --working-dir=.utils install - npm run update-variables - git diff --quiet HEAD || { echo "Docs not up-to-date. Run 'cd .vortex && ahoy update-docs' and commit changes."; git diff; exit 1; } - working-directory: .vortex/docs - - - name: Install dependencies - run: npm install - working-directory: .vortex/docs - - - name: Build documentation site - run: npm run build - working-directory: .vortex/docs - - - name: Upload documentation site - uses: actions/upload-pages-artifact@v3 - with: - path: .vortex/docs/build - - - name: Deploy to GitHub Pages - uses: actions/deploy-pages@v4 diff --git a/.github/workflows/vortex-test-common.yml b/.github/workflows/vortex-test-common.yml deleted file mode 100644 index 474360f0c..000000000 --- a/.github/workflows/vortex-test-common.yml +++ /dev/null @@ -1,210 +0,0 @@ -# This action is used for Vortex maintenance. It will not be used in the scaffolded project. -name: Vortex - Test - -on: - push: - branches: - - develop - pull_request: - branches: - - develop - - 'feature/**' - - 'bugfix/**' - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - vortex-test-common: - runs-on: ubuntu-latest - - container: - image: drevops/ci-runner:latest - env: - # Prevent GitHub overriding the Docker config. - DOCKER_CONFIG: /root/.docker - VORTEX_DOCTOR_CHECK_MINIMAL: 1 - TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} - TEST_VORTEX_CONTAINER_REGISTRY_USER: ${{ secrets.TEST_VORTEX_CONTAINER_REGISTRY_USER }} - TEST_VORTEX_CONTAINER_REGISTRY_PASS: ${{ secrets.TEST_VORTEX_CONTAINER_REGISTRY_PASS }} - VORTEX_DEV_VOLUMES_MOUNTED: 0 - VORTEX_DEV_TEST_COVERAGE_DIR: /tmp/.vortex-coverage-html - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Process 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: Adjust git config to allow running git-related tests - run: git config --global safe.directory '*' - - - name: Generate test SSH key pair used for deployment tests - run: | - mkdir -p "$HOME/.ssh" - ssh-keygen -t rsa -b 4096 -m PEM -N '' -f "$HOME/.ssh/id_rsa" - chmod 600 "$HOME/.ssh/id_rsa" - ssh-agent -a "${HOME}/ssh-agent.sock" > ssh-agent-output - export SSH_AUTH_SOCK=$(grep SSH_AUTH_SOCK ssh-agent-output | cut -d';' -f1 | cut -d= -f2) - echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "$GITHUB_ENV" - - - name: Install dependencies - run: npm ci - working-directory: .vortex/tests - - - name: Lint code - run: | - ./tests/lint.scripts.sh - ./tests/lint.dockerfiles.sh - working-directory: .vortex - - - name: Run tests - run: ./tests/test.common.sh - working-directory: .vortex - - - name: Upload coverage report as an artifact - uses: actions/upload-artifact@v4 - with: - name: ${{github.job}}-code-coverage-report - path: /tmp/.vortex-coverage-html - - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - directory: /tmp/.vortex-coverage-html - fail_ci_if_error: false - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - vortex-test-workflow: - runs-on: ubuntu-latest - - strategy: - matrix: - batch: [0, 1, 2] - - container: - image: drevops/ci-runner:latest - env: - # Prevent GitHub overriding the Docker config. - DOCKER_CONFIG: /root/.docker - VORTEX_DOCTOR_CHECK_MINIMAL: 1 - TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} - TEST_VORTEX_CONTAINER_REGISTRY_USER: ${{ secrets.TEST_VORTEX_CONTAINER_REGISTRY_USER }} - TEST_VORTEX_CONTAINER_REGISTRY_PASS: ${{ secrets.TEST_VORTEX_CONTAINER_REGISTRY_PASS }} - VORTEX_DEV_VOLUMES_MOUNTED: 0 - VORTEX_DEV_TEST_COVERAGE_DIR: /tmp/.vortex-coverage-html - TEST_NODE_INDEX: ${{ matrix.batch }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Adjust git config to allow running git-related tests - run: git config --global safe.directory '*' - - - name: Install dependencies - run: npm ci - working-directory: .vortex/tests - - - name: Run tests - run: ./tests/test.workflow.sh - working-directory: .vortex - - - name: Upload coverage report as an artifact - uses: actions/upload-artifact@v4 - with: - name: ${{github.job}}-${{ matrix.batch }}-code-coverage-report - path: /tmp/.vortex-coverage-html - - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - directory: /tmp/.vortex-coverage-html - fail_ci_if_error: false - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - vortex-test-deployment: - runs-on: ubuntu-latest - - strategy: - matrix: - batch: [0, 1] - - container: - image: drevops/ci-runner:latest - env: - # Prevent GitHub overriding the Docker config. - DOCKER_CONFIG: /root/.docker - VORTEX_DOCTOR_CHECK_MINIMAL: 1 - TEST_GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }} - TEST_VORTEX_CONTAINER_REGISTRY_USER: ${{ secrets.TEST_VORTEX_CONTAINER_REGISTRY_USER }} - TEST_VORTEX_CONTAINER_REGISTRY_PASS: ${{ secrets.TEST_VORTEX_CONTAINER_REGISTRY_PASS }} - VORTEX_DEV_VOLUMES_MOUNTED: 0 - VORTEX_DEV_TEST_COVERAGE_DIR: /tmp/.vortex-coverage-html - TEST_NODE_INDEX: ${{ matrix.batch }} - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - persist-credentials: false - - - name: Adjust git config to allow running git-related tests - run: git config --global safe.directory '*' - - - name: Generate test SSH key pair used for deployment tests - run: | - mkdir -p "$HOME/.ssh" - ssh-keygen -t rsa -b 4096 -m PEM -N '' -f "$HOME/.ssh/id_rsa" - chmod 600 "$HOME/.ssh/id_rsa" - ssh-agent -a "${HOME}/ssh-agent.sock" > ssh-agent-output - export SSH_AUTH_SOCK="$(grep SSH_AUTH_SOCK ssh-agent-output | cut -d';' -f1 | cut -d= -f2)" - echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "$GITHUB_ENV" - - - name: Install dependencies - run: npm ci - working-directory: .vortex/tests - - - name: Run tests - run: ./tests/test.deployment.sh - working-directory: .vortex - - - name: Upload coverage report as an artifact - uses: actions/upload-artifact@v4 - with: - name: ${{github.job}}-${{ matrix.batch }}-code-coverage-report - path: /tmp/.vortex-coverage-html - - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - directory: /tmp/.vortex-coverage-html - fail_ci_if_error: false - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - vortex-test-actions: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Check coding standards with yamllint - run: yamllint --config-file .vortex/tests/.yamllint-for-gha.yml .github/workflows - continue-on-error: ${{ vars.VORTEX_CI_YAMLLINT_IGNORE_FAILURE == '1' }} - - - name: Check coding standards with actionlint - run: docker run --rm -v "${GITHUB_WORKSPACE:-.}":/app --workdir /app rhysd/actionlint:1.6.27 -ignore 'SC2002:' -ignore 'SC2155:' - continue-on-error: ${{ vars.VORTEX_CI_ACTIONLINT_IGNORE_FAILURE == '1' }} diff --git a/.github/workflows/vortex-test-docs.yml b/.github/workflows/vortex-test-docs.yml deleted file mode 100644 index 5c48992f7..000000000 --- a/.github/workflows/vortex-test-docs.yml +++ /dev/null @@ -1,59 +0,0 @@ -# This action is used for Vortex maintenance. It will not be used in the scaffolded project. -name: Vortex - Test docs - -on: - push: - tags: - - '**' - branches: - - '**' - -jobs: - vortex-test-docs: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - - - name: Check docs up-to-date - run: | - composer --working-dir=.utils install - npm run update-variables - git diff --quiet HEAD || { echo "Docs not up-to-date. Run 'cd .vortex && ahoy update-docs' and commit changes."; git diff; exit 1; } - working-directory: '${{ github.workspace }}/.vortex/docs' - - - name: Install dependencies - run: npm install - working-directory: '${{ github.workspace }}/.vortex/docs' - - - name: Build documentation site - run: npm run build - working-directory: '${{ github.workspace }}/.vortex/docs' - - - name: Run tests - run: npm run test - working-directory: '${{ github.workspace }}/.vortex/docs' - - - name: Deploy to Netlify - uses: nwtgck/actions-netlify@v3.0 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - publish-dir: '.vortex/docs/build' - production-branch: develop - deploy-message: "Deploy from GitHub Actions" - enable-pull-request-comment: true - enable-commit-comment: true - overwrites-pull-request-comment: true - env: - NETLIFY_SITE_ID: ${{ secrets.DOCS_NETLIFY_SITE_ID }} - NETLIFY_AUTH_TOKEN: ${{ secrets.DOCS_NETLIFY_AUTH_TOKEN }} - timeout-minutes: 1 diff --git a/.github/workflows/vortex-test-installer.yml b/.github/workflows/vortex-test-installer.yml deleted file mode 100644 index 1579acfb8..000000000 --- a/.github/workflows/vortex-test-installer.yml +++ /dev/null @@ -1,61 +0,0 @@ -# This action is used for Vortex maintenance. It will not be used in the scaffolded project. -name: Vortex - Test installer - -on: - push: - branches: - - main - pull_request: - branches: - - main - - 'feature/**' - -jobs: - vortex-test-installer: - runs-on: ubuntu-latest - - strategy: - matrix: - php-versions: ['8.1', '8.2', '8.3'] - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-versions }} - - - name: Install dependencies - run: composer install - working-directory: .vortex/installer - - - name: Check coding standards - run: composer lint - working-directory: .vortex/installer - - - name: Run tests - run: XDEBUG_MODE=coverage composer test - working-directory: .vortex/installer - - - name: Upload coverage report as an artifact - uses: actions/upload-artifact@v4 - with: - name: ${{github.job}}-code-coverage-report-${{ matrix.php-versions }} - path: .vortex/installer/.coverage-html - - - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v4 - with: - files: .vortex/installer/cobertura.xml - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} - - # Smoke test for PHAR. - - name: Build PHAR - run: composer build - working-directory: .vortex/installer - - - name: Test PHAR - run: .vortex/installer/build/installer --quiet || exit 1 diff --git a/1.yml b/1.yml new file mode 100644 index 000000000..68ca2ac7e --- /dev/null +++ b/1.yml @@ -0,0 +1,426 @@ +version: 2 +jobs: + + database: + working_directory: ~/project + environment: + - VORTEX_DB_DOWNLOAD_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - VORTEX_DEPLOY_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + docker: + - image: drevops/ci-runner:24.8.0 + auth: + username: ${VORTEX_CONTAINER_REGISTRY_USER} + password: ${VORTEX_CONTAINER_REGISTRY_PASS} + environment: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_CI_DB_CACHE_TIMESTAMP: +%Y%m%d + VORTEX_CI_DB_CACHE_FALLBACK: 'yes' + VORTEX_CI_DB_CACHE_BRANCH: develop + VORTEX_CI_TEST_RESULTS: /tmp/tests + VORTEX_CI_ARTIFACTS: /tmp/artifacts + VORTEX_EXPORT_CODE_DIR: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_ROOT: ~/project + VORTEX_DEPLOY_ARTIFACT_LOG: /tmp/artifacts/deployment_log.txt + VORTEX_DOCTOR_CHECK_MINIMAL: 1 + resource_class: medium + steps: + - attach_workspace: + at: /tmp/workspace + - add_ssh_keys: + fingerprints: + - 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - checkout + - 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 + - setup_remote_docker: + docker_layer_caching: false + version: default + - run: + command: docker network prune -f >/dev/null 2>&1 && docker network inspect amazeeio-network >/dev/null 2>&1 || docker network create amazeeio-network >/dev/null 2>&1 || true + - 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 + echo "$(date ${VORTEX_CI_DB_CACHE_TIMESTAMP})" | tee /tmp/db_cache_timestamp + echo "yes" | tee /tmp/db_cache_fallback_yes + echo 'v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }}' + - restore_cache: + keys: + - v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}- + - run: + name: Download DB + command: VORTEX_DB_DOWNLOAD_SEMAPHORE=/tmp/download-db-success ./scripts/vortex/download-db.sh + no_output_timeout: 30m + - 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 -d && 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: + key: v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + paths: + - /root/project/.data + + database-nightly: + working_directory: ~/project + environment: + - VORTEX_DB_DOWNLOAD_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - VORTEX_DEPLOY_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - VORTEX_CI_DB_CACHE_FALLBACK: 'no' + - VORTEX_DB_IMAGE_BASE: drevops/mariadb-drupal-data:24.4.0 + - VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED: 1 + docker: + - image: drevops/ci-runner:24.8.0 + auth: + username: ${VORTEX_CONTAINER_REGISTRY_USER} + password: ${VORTEX_CONTAINER_REGISTRY_PASS} + environment: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_CI_DB_CACHE_TIMESTAMP: +%Y%m%d + VORTEX_CI_DB_CACHE_FALLBACK: 'yes' + VORTEX_CI_DB_CACHE_BRANCH: develop + VORTEX_CI_TEST_RESULTS: /tmp/tests + VORTEX_CI_ARTIFACTS: /tmp/artifacts + VORTEX_EXPORT_CODE_DIR: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_ROOT: ~/project + VORTEX_DEPLOY_ARTIFACT_LOG: /tmp/artifacts/deployment_log.txt + VORTEX_DOCTOR_CHECK_MINIMAL: 1 + resource_class: medium + steps: + - attach_workspace: + at: /tmp/workspace + - add_ssh_keys: + fingerprints: + - 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - checkout + - 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 + - setup_remote_docker: + docker_layer_caching: false + version: default + - run: + command: docker network prune -f >/dev/null 2>&1 && docker network inspect amazeeio-network >/dev/null 2>&1 || docker network create amazeeio-network >/dev/null 2>&1 || true + - 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 + echo "$(date ${VORTEX_CI_DB_CACHE_TIMESTAMP})" | tee /tmp/db_cache_timestamp + echo "yes" | tee /tmp/db_cache_fallback_yes + echo 'v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }}' + - restore_cache: + keys: + - v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback" }}- + - run: + name: Download DB + command: VORTEX_DB_DOWNLOAD_SEMAPHORE=/tmp/download-db-success ./scripts/vortex/download-db.sh + no_output_timeout: 30m + - 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 -d && 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: + key: v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + paths: + - /root/project/.data + + build: + working_directory: ~/project + environment: + - VORTEX_DB_DOWNLOAD_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - VORTEX_DEPLOY_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + docker: + - image: drevops/ci-runner:24.8.0 + auth: + username: ${VORTEX_CONTAINER_REGISTRY_USER} + password: ${VORTEX_CONTAINER_REGISTRY_PASS} + environment: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_CI_DB_CACHE_TIMESTAMP: +%Y%m%d + VORTEX_CI_DB_CACHE_FALLBACK: 'yes' + VORTEX_CI_DB_CACHE_BRANCH: develop + VORTEX_CI_TEST_RESULTS: /tmp/tests + VORTEX_CI_ARTIFACTS: /tmp/artifacts + VORTEX_EXPORT_CODE_DIR: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_ROOT: ~/project + VORTEX_DEPLOY_ARTIFACT_LOG: /tmp/artifacts/deployment_log.txt + VORTEX_DOCTOR_CHECK_MINIMAL: 1 + resource_class: medium + parallelism: 2 + steps: + - attach_workspace: + at: /tmp/workspace + - checkout + - 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 + - setup_remote_docker: + docker_layer_caching: false + version: default + - run: + command: docker network prune -f >/dev/null 2>&1 && docker network inspect amazeeio-network >/dev/null 2>&1 || docker network create amazeeio-network >/dev/null 2>&1 || true + - 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: + - v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}-{{ checksum "/tmp/db_cache_timestamp" }} + - v24.8.0-db10-{{ checksum "/tmp/db_cache_branch" }}-{{ checksum "/tmp/db_cache_fallback_yes" }}- + - run: + name: Lint Dockerfiles with Hadolint + command: | + 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: Login to container registry + command: ./scripts/vortex/login-container-registry.sh + - run: + name: Build stack + command: docker compose up -d + - run: + name: Export built codebase + command: | + mkdir -p "${VORTEX_EXPORT_CODE_DIR}" + docker compose cp -L cli:"/app/." "${VORTEX_EXPORT_CODE_DIR}" + - run: + name: Validate Composer configuration + command: docker compose exec cli composer validate --strict || [ "${VORTEX_CI_COMPOSER_VALIDATE_IGNORE_FAILURE:-0}" -eq 1 ] + - run: + name: Install development dependencies + command: | + 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" + - run: + name: Lint code with PHPCS + command: docker compose exec -T cli vendor/bin/phpcs || [ "${VORTEX_CI_PHPCS_IGNORE_FAILURE:-0}" -eq 1 ] + - run: + name: Lint code with PHPStan + command: docker compose exec -T cli vendor/bin/phpstan || [ "${VORTEX_CI_PHPSTAN_IGNORE_FAILURE:-0}" -eq 1 ] + - run: + name: Lint code with Rector + command: docker compose exec -T cli vendor/bin/rector --clear-cache --dry-run || [ "${VORTEX_CI_RECTOR_IGNORE_FAILURE:-0}" -eq 1 ] + - run: + name: Lint code with PHPMD + command: 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: 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: docker compose exec -T cli vendor/bin/gherkinlint lint tests/behat/features || [ "${VORTEX_CI_GHERKIN_LINT_IGNORE_FAILURE:-0}" -eq 1 ] + - run: + name: Lint code with NPM linters + command: docker compose exec -T cli bash -c "npm run --prefix \${VORTEX_WEBROOT}/themes/custom/\${DRUPAL_THEME} lint" || [ "${VORTEX_CI_NPM_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: | + 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 || [ "${VORTEX_CI_PHPUNIT_IGNORE_FAILURE:-0}" -eq 1 ] + docker compose up -d cli php nginx # Restart stack without XDEBUG enabled for coverage. + - 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: /tmp/tests + - store_artifacts: + path: /tmp/artifacts + - run: + name: Upload code coverage reports to Codecov + command: if [ -n "${CODECOV_TOKEN}" ] && [ -d /tmp/artifacts/coverage ]; then codecov -Z -s /tmp/artifacts/coverage; fi + - persist_to_workspace: + root: /tmp/workspace + paths: + - code + + + deploy: + working_directory: ~/project + environment: + - VORTEX_DB_DOWNLOAD_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - VORTEX_DEPLOY_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + docker: + - image: drevops/ci-runner:24.8.0 + auth: + username: ${VORTEX_CONTAINER_REGISTRY_USER} + password: ${VORTEX_CONTAINER_REGISTRY_PASS} + environment: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_CI_DB_CACHE_TIMESTAMP: +%Y%m%d + VORTEX_CI_DB_CACHE_FALLBACK: 'yes' + VORTEX_CI_DB_CACHE_BRANCH: develop + VORTEX_CI_TEST_RESULTS: /tmp/tests + VORTEX_CI_ARTIFACTS: /tmp/artifacts + VORTEX_EXPORT_CODE_DIR: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_ROOT: ~/project + VORTEX_DEPLOY_ARTIFACT_LOG: /tmp/artifacts/deployment_log.txt + VORTEX_DOCTOR_CHECK_MINIMAL: 1 + resource_class: medium + steps: + - attach_workspace: + at: /tmp/workspace + - add_ssh_keys: + fingerprints: + - 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - checkout + - 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 + - run: + 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: /tmp/artifacts + + deploy-tags: + working_directory: ~/project + environment: + - VORTEX_DB_DOWNLOAD_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - VORTEX_DEPLOY_SSH_FINGERPRINT: 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + docker: + - image: drevops/ci-runner:24.8.0 + auth: + username: ${VORTEX_CONTAINER_REGISTRY_USER} + password: ${VORTEX_CONTAINER_REGISTRY_PASS} + environment: + TZ: Australia/Melbourne + TERM: xterm-256color + VORTEX_CI_DB_CACHE_TIMESTAMP: +%Y%m%d + VORTEX_CI_DB_CACHE_FALLBACK: 'yes' + VORTEX_CI_DB_CACHE_BRANCH: develop + VORTEX_CI_TEST_RESULTS: /tmp/tests + VORTEX_CI_ARTIFACTS: /tmp/artifacts + VORTEX_EXPORT_CODE_DIR: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_SRC: /tmp/workspace/code + VORTEX_DEPLOY_ARTIFACT_ROOT: ~/project + VORTEX_DEPLOY_ARTIFACT_LOG: /tmp/artifacts/deployment_log.txt + VORTEX_DOCTOR_CHECK_MINIMAL: 1 + resource_class: medium + steps: + - attach_workspace: + at: /tmp/workspace + - add_ssh_keys: + fingerprints: + - 56:f3:3f:51:c3:8f:b3:75:01:90:6e:26:48:e7:48:e1 + - checkout + - 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 + - run: + command: VORTEX_DEPLOY_MODE="tag" ./scripts/vortex/deploy.sh + no_output_timeout: 30m + - store_artifacts: + path: /tmp/artifacts + +workflows: + version: 2 + commit: + jobs: + - database: + filters: + tags: + only: /.*/ + - build: + filters: + tags: + only: /.*/ + requires: + - database + - deploy: + filters: + branches: + only: /^(production|main|master|develop)$|^project\/[a-zA-z0-9\-\.]+|^(feature|bugfix)\/[a-zA-Z0-9\-\.\,_]+$|^ci.*|^deps\/.*|^(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: /.*/ + requires: + - build + - deploy-tags: + filters: + branches: + ignore: /.*/ + tags: + only: /^[0-9]+(\.[0-9]+){2}(-rc\.[0-9]+)?$|^[0-9]{4}-[0-9]{2}-[0-9]{2}(\.[0-9]+)?$/ + requires: + - build + + nightly-db: + triggers: + - schedule: + cron: 0 18 * * * + filters: + branches: + only: + - develop + jobs: + - database-nightly + diff --git a/docker-compose.yml b/docker-compose.yml index 8acfc936c..85a49eebf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -120,8 +120,8 @@ services: depends_on: - cli networks: - - amazeeio-network # This network is supported by Pygmy and used to route all requests to host machine. - default # This is a standard network and is used for all other environments, where requests routing is not required and/or not supported. + - amazeeio-network ### This network is supported by Pygmy and used to route all requests to host machine locally. Removed in CI. #;< LAGOON labels: lagoon.type: nginx-php-persistent # See https://docs.lagoon.sh/using-lagoon-advanced/service-types/ @@ -244,9 +244,9 @@ services: lagoon.type: none # Do not deploy in Lagoon. #;> LAGOON -networks: - amazeeio-network: - external: true +networks: ### Use networks locally. Automatically removed in CI. + amazeeio-network: ### Automatically removed in CI. + external: true ### Automatically removed in CI. volumes: app: {} diff --git a/scripts/vortex/setup-ssh.sh b/scripts/vortex/setup-ssh.sh index 17e835ff2..0468574f4 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 [ -z "${SSH_AGENT_PID:-}" ] || ! ps -p "$SSH_AGENT_PID"; then + note "Starting SSH agent." + eval "$(ssh-agent)" fi if ssh-add -l | grep -q "${file}"; then diff --git a/tests/phpunit/CircleCiConfigTest.php b/tests/phpunit/CircleCiConfigTest.php deleted file mode 100644 index 9047a7813..000000000 --- a/tests/phpunit/CircleCiConfigTest.php +++ /dev/null @@ -1,263 +0,0 @@ -config = Yaml::decode($file); - } - - /** - * Tests for deploy branch regex. - * - * @see https://semver.org/ - * - * @dataProvider dataProviderDeployBranchRegex - */ - public function testDeployBranchRegex(string $branch, bool $expected = TRUE): void { - $this->assertEquals($expected, preg_match($this->config['workflows']['commit']['jobs'][2]['deploy']['filters']['branches']['only'], $branch)); - } - - /** - * Data provider for testDeployBranchRegex(). - */ - public static function dataProviderDeployBranchRegex(): array { - return [ - // Positive branches. - ['production'], - ['main'], - ['master'], - ['develop'], - - ['ci'], - ['cisomething'], - - ['deps/something'], - - ['release/123.456.789'], - ['release/123.456.789-rc.123'], - ['hotfix/123.456.789'], - ['hotfix/123.456.789-rc.123'], - - ['release/2023-04-17'], - ['release/2023-04-17.1'], - ['hotfix/2023-04-17'], - ['hotfix/2023-04-17.1'], - - ['feature/description'], - ['feature/Description'], - ['feature/Description-With-Hyphens'], - ['feature/Description-With_Underscores'], - ['feature/123-description'], - ['feature/123-Description'], - ['feature/UNDERSCORES_UNDERSCORES'], - ['feature/123-Description-With_UNDERSCORES'], - ['feature/1.x'], - ['feature/0.x'], - ['feature/0.1.x'], - ['feature/0.1.2.x'], - ['feature/1.x-description'], - ['feature/0.x-description'], - ['feature/0.1.x-description'], - ['feature/0.1.2.x-description'], - - ['bugfix/description'], - ['bugfix/Description'], - ['bugfix/Description-With-Hyphens'], - ['bugfix/Description-With_Underscores'], - ['bugfix/123-description'], - ['bugfix/123-Description'], - ['bugfix/UNDERSCORES_UNDERSCORES'], - ['bugfix/123-Description-With_UNDERSCORES'], - ['bugfix/1.x'], - ['bugfix/0.x'], - ['bugfix/0.1.x'], - ['bugfix/0.1.2.x'], - ['bugfix/1.x-description'], - ['bugfix/0.x-description'], - ['bugfix/0.1.x-description'], - ['bugfix/0.1.2.x-description'], - - ['project/description'], - ['project/Description'], - ['project/Description-With-Hyphens'], - ['project/123-description'], - ['project/123-Description'], - ['project/1.x'], - ['project/0.x'], - ['project/0.1.x'], - ['project/0.1.2.x'], - ['project/1.x-description'], - ['project/0.x-description'], - ['project/0.1.x-description'], - ['project/0.1.2.x-description'], - - // Negative branches. - ['something', FALSE], - ['premain', FALSE], - ['premaster', FALSE], - ['predevelop', FALSE], - ['mainpost', FALSE], - ['masterpost', FALSE], - ['developpost', FALSE], - ['premainpost', FALSE], - ['premasterpost', FALSE], - ['predeveloppost', FALSE], - - ['preci', FALSE], - ['precipost', FALSE], - - ['deps', FALSE], - ['predeps', FALSE], - ['depspost', FALSE], - ['predepspost', FALSE], - - ['feature', FALSE], - ['release', FALSE], - ['hotfix', FALSE], - ['prefeature', FALSE], - ['prerelease', FALSE], - ['prehotfix', FALSE], - ['featurepost', FALSE], - ['releasepost', FALSE], - ['hotfixpost', FALSE], - ['prefeaturepost', FALSE], - ['prereleasepost', FALSE], - ['prehotfixpost', FALSE], - - ['release/123', FALSE], - ['release/123.456', FALSE], - ['hotfix/123', FALSE], - ['hotfix/123.456', FALSE], - - ['release/202-04-17', FALSE], - ['release/2023-4-17', FALSE], - ['release/2023-04-1', FALSE], - ['release/pre2023-04-17', FALSE], - ['release/2023-04-17post', FALSE], - ['release/pre2023-04-17post', FALSE], - - ['hotfix/202-04-17', FALSE], - ['hotfix/2023-4-17', FALSE], - ['hotfix/2023-04-1', FALSE], - ['hotfix/pre2023-04-17', FALSE], - ['hotfix/2023-04-17post', FALSE], - ['hotfix/pre2023-04-17post', FALSE], - - ['release/123.456.789-something', FALSE], - ['release/123.456.789-rc', FALSE], - ['release/123.456.789-rc123', FALSE], - ['release/123.456.789-rc-123', FALSE], - ['release/123.456.789-prerc123', FALSE], - ['release/123.456.789-rcpost123', FALSE], - ['release/123.456.789-prercpost123', FALSE], - ['release/123.456.789-rc123something', FALSE], - ['release/123.456.789-rc.123something', FALSE], - ['release/123.456.789-rc.123-something', FALSE], - - ['hotfix/123.456.789-something', FALSE], - ['hotfix/123.456.789-rc', FALSE], - ['hotfix/123.456.789-rc123', FALSE], - ['hotfix/123.456.789-rc-123', FALSE], - ['hotfix/123.456.789-prerc123', FALSE], - ['hotfix/123.456.789-rcpost123', FALSE], - ['hotfix/123.456.789-prercpost123', FALSE], - ['hotfix/123.456.789-rc123something', FALSE], - ['hotfix/123.456.789-rc.123something', FALSE], - ['hotfix/123.456.789-rc.123-something', FALSE], - - ['prefeature/something', FALSE], - ['prefbugfix/something', FALSE], - ['prerelease/something', FALSE], - ['prehotfix/something', FALSE], - ['featurepost/something', FALSE], - ['bugfixpost/something', FALSE], - ['releasepost/something', FALSE], - ['hotfixpost/something', FALSE], - ['prefeaturepost/something', FALSE], - ['prebugfixpost/something', FALSE], - ['prereleasepost/something', FALSE], - ['prehotfixpost/something', FALSE], - ['preproject/something', FALSE], - ['projectpost/something', FALSE], - ]; - } - - /** - * Tests for deploy tag regex. - * - * @see https://semver.org/ - * - * @dataProvider dataProviderDeployTagRegex - */ - public function testDeployTagRegex(string $branch, bool $expected = TRUE): void { - $this->assertEquals($expected, preg_match($this->config['workflows']['commit']['jobs'][3]['deploy-tags']['filters']['tags']['only'], $branch)); - } - - /** - * Data provider for testDeployTagRegex(). - */ - public static function dataProviderDeployTagRegex(): array { - return [ - // Positive tags. - ['1.2.3'], - ['1.2.3-rc.123'], - ['2023-04-17'], - ['2023-04-17.123'], - - // Negative tags. - ['123', FALSE], - ['123.456', FALSE], - ['1.2.3-rc123', FALSE], - ['1.2.3-rc.123post', FALSE], - ['1.2.3-prerc.123', FALSE], - ['1.2.3-rcpost.123', FALSE], - ['1.2.3-prercpost.123', FALSE], - - ['202-04-17', FALSE], - ['2023-0-17', FALSE], - ['2023-04-1', FALSE], - ['pre2023-04-17', FALSE], - ['2023-04-17post', FALSE], - ['pre2023-04-17post', FALSE], - ['2023-04-17.123.', FALSE], - ['2023-04-17.pre123', FALSE], - ['2023-04-17.pre123post', FALSE], - ['2023-04-17.123post', FALSE], - ]; - } - -}