From 906a8f3fe822a39fb2aac5e79b401efd400994f8 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Tue, 30 Jun 2026 09:30:41 -0500 Subject: [PATCH 01/34] Update README installation instructions --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 109b02c..55348dc 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,12 @@ build tooling the actions depend on. ## Installation ```bash -composer require ten7/code-testing +composer require "ten7/github-code-testing" ``` +⚠️If you have lullabot/drainpipe and/or lullabot/drainpipe-dev you will need +to uninstall them before installing github-code-testing. + ## Configuration Add a `code_testing` key to the `extra` section of your project's From a42ba35568844041676154dd604d514b4c1dd226 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Wed, 1 Jul 2026 12:16:24 -0500 Subject: [PATCH 02/34] Improving the readme and fixing vars in drainpipe runners. --- README.md | 41 ++++++++++++------- .../workflows/drainpipePantheonBuildEdge.yml | 2 +- .../workflows/drainpipePantheonBuildMain.yml | 2 +- .../workflows/drainpipePantheonReviewApps.yml | 2 +- 4 files changed, 30 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ecc52ed..9d44957 100644 --- a/README.md +++ b/README.md @@ -25,34 +25,45 @@ context key and a list of workflow names. ##### Secrets -* SSH_PRIVATE_KEY is needed for all actions. -* SSH_KNOWN_HOSTS is also needed for all actions. -* TERMINUS_MACHINE_TOKEN is required for all actions -* PANTHEON_REVIEW_RUN_INSTALLER is required for drainpipe actions -* BROWSERSTACK_USERNAME is the short key indicating the username (should be +* `SSH_PRIVATE_KEY` is needed for all actions. +* `SSH_KNOWN_HOSTS` is also needed for all actions. +* `TERMINUS_MACHINE_TOKEN` is required for all actions +* `PANTHEON_REVIEW_RUN_INSTALLER` is required for drainpipe actions +* `PANTHEON_SITE_NAME` is the required by drainpipe actions. It is the UUID + for the site. It's annoying to have this in both variables and secrets. It + really should just be a variable unless at some point Pantheon allows + renaming a site and the UUID serves it's real purpose of being the + constant identifier. +* `BROWSERSTACK_USERNAME` is the short key indicating the username (should be the company-wide/repo-holder's username at browserstack.com) -* BROWSERSTACK_ACCESS_KEY is the hash at the same account at browserstack.com +* `BROWSERSTACK_ACCESS_KEY` is the hash at the same account at browserstack.com ##### Variables -* BROWSERSTACK_PRIMARY_BRANCH is the branch (edge or main) that browserstack +* `BROWSERSTACK_PRIMARY_BRANCH` is the branch (edge, main, master) that + browserstack * tests should be run on. -* BROWSERSTACK_TESTS_ENABLED is a boolean that indicates if browserstack +* `BROWSERSTACK_TESTS_ENABLED` is a boolean that indicates if browserstack tests should be run at all. -* TESTING_NEEDS_SEARCH_INDEXING is a boolean that determines if tests run on +* `TESTING_NEEDS_SEARCH_INDEXING` is a boolean that determines if tests run on the site require a build to run the search_api index. -* PANTHEON_SITE_NAME is the human-friendly site name that is used in +* `PANTHEON_SITE_NAME` is the human-friendly site name that is used in multi-dev URLs: https:/dev-[site-name].pantheonsite.io ##### PR Labels On PRs some labels can be used for triggering actions these include -* skip-wipe which prevents a build from wiping the files and db and starting +* `skip-wipe` which prevents a build from wiping the files and db and starting from scratch on every push -* build multidev which is required to actually run drainpipePantheonReviewApps -* test renovate is useful if you want to reduce testRenovate's time to run +* `build multidev` which is required to actually run drainpipePantheonReviewApps +* `test renovate` is useful if you want to reduce testRenovate's time to run even more. See below. +* `browserstack` By default browserstack tests are never run on PRs even if + `BROWSERSTACK_TESTS_ENABLED`=true. Add this label if a PR should also run + browserstack tests. This is useful if a PR includes significant + theme changes. Less "expensive" standard CodeTests or Playwright tests. So + use this with care. ### Drainpipe Example @@ -113,11 +124,13 @@ the options are simpler. } ``` +### Workflow file patterns + Each entry maps to a workflow file using the pattern `{context}{Name}.yml`. The example above would scaffold: - `drainpipePlaywrightTests.yml` -- `deploymmentBrowserStackTests.yml` +- `deploymentBrowserStackTests.yml` - `deploymentCodeTests.yml` - `testRenovate.yml` diff --git a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml index 0155130..8b2ae31 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml @@ -75,7 +75,7 @@ jobs: multidev-name: edge - name: Run indexing if it is needed. - if: ${{ env.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} + if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} uses: ./.github/actions/code-testing/drupal/index-search with: machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} diff --git a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml index aa7a65c..0437b2c 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml @@ -70,7 +70,7 @@ jobs: multidev-name: dev - name: Run indexing if it is needed. - if: ${{ env.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} + if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} uses: ./.github/actions/code-testing/drupal/index-search with: machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} diff --git a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml index b1e20b9..5dfa031 100644 --- a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml +++ b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml @@ -84,7 +84,7 @@ jobs: site-name: ${{ secrets.PANTHEON_SITE_NAME }} - name: Run indexing if it is needed. - if: ${{ env.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} + if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} uses: ./.github/actions/code-testing/drupal/index-search with: machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} From ac79cb4ceff4a014097eb27c8f49dab124118ae1 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Wed, 1 Jul 2026 12:24:27 -0500 Subject: [PATCH 03/34] Update Browserstack rules for workflow triggers in README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 9d44957..32b846f 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,11 @@ for the specific tasks. There is no need to call drainpipe separately unless you have specific additional requirements for those. Just be sure not to overlap functionality. +⚠️Note that the PlaywrightTests and BrowserstackTests must be merged to the +root branch of the repo before they can be run on any PR. This is a +fundamental requirement of Github. This is generally acceptable especially +for Browserstack since it should be used sparingly. + ```json { "code_testing": { From 8a199d2e94aa37aac26a621a448d5fe76d0efa3b Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Wed, 1 Jul 2026 12:32:11 -0500 Subject: [PATCH 04/34] Critical fix to drainpipeCodeTests.yml: use test:ci-ddev --- scaffold/.github/workflows/drainpipeCodeTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/.github/workflows/drainpipeCodeTests.yml b/scaffold/.github/workflows/drainpipeCodeTests.yml index dc41974..02774a8 100644 --- a/scaffold/.github/workflows/drainpipeCodeTests.yml +++ b/scaffold/.github/workflows/drainpipeCodeTests.yml @@ -173,4 +173,4 @@ jobs: environment-password: '' environment-username: '' target-url: ${{ steps.ddev-url.outputs.url }} - test-script: 'ci-ddev' + test-script: 'test:ci-ddev' From 33d92b42a0a5ba89e2588f4b6fcff9d5e9018ca1 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 6 Jul 2026 14:33:01 -0500 Subject: [PATCH 05/34] Updates to deploy files --- .gitignore | 2 +- .../code-testing/browserstack/test/action.yml | 4 +- .../github/decide-test-run/action.yml | 75 ++++++ .../code-testing/playwright/test/action.yml | 7 +- .../.github/actions/drainpipe/ddev/action.yml | 82 +++++++ .../drainpipe/deployment-create/action.yml | 31 +++ .../drainpipe/deployment-status/action.yml | 42 ++++ .../drainpipe/lockfile-diff/action.yml | 126 ++++++++++ .../actions/drainpipe/lockfile-diff/diff.mjs | 226 ++++++++++++++++++ .../drainpipe/pantheon/clone-env/action.yml | 47 ++++ .../drainpipe/pantheon/push/action.yml | 41 ++++ .../drainpipe/pantheon/review/action.yml | 209 ++++++++++++++++ .../pantheon/setup-terminus/action.yml | 24 ++ .../drainpipe/pantheon/update/action.yml | 33 +++ .../actions/drainpipe/set-env/action.yml | 62 +++++ .../actions/drainpipe/set-env/bash_aliases | 7 + .../actions/drainpipe/setup-git/action.yml | 19 ++ .../actions/drainpipe/setup-ssh/action.yml | 29 +++ .../validate-terminus-timeout/action.yml | 20 ++ 19 files changed, 1081 insertions(+), 5 deletions(-) create mode 100644 scaffold/.github/actions/code-testing/github/decide-test-run/action.yml create mode 100644 scaffold/.github/actions/drainpipe/ddev/action.yml create mode 100644 scaffold/.github/actions/drainpipe/deployment-create/action.yml create mode 100644 scaffold/.github/actions/drainpipe/deployment-status/action.yml create mode 100644 scaffold/.github/actions/drainpipe/lockfile-diff/action.yml create mode 100644 scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs create mode 100644 scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml create mode 100644 scaffold/.github/actions/drainpipe/pantheon/push/action.yml create mode 100644 scaffold/.github/actions/drainpipe/pantheon/review/action.yml create mode 100644 scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml create mode 100644 scaffold/.github/actions/drainpipe/pantheon/update/action.yml create mode 100644 scaffold/.github/actions/drainpipe/set-env/action.yml create mode 100644 scaffold/.github/actions/drainpipe/set-env/bash_aliases create mode 100644 scaffold/.github/actions/drainpipe/setup-git/action.yml create mode 100644 scaffold/.github/actions/drainpipe/setup-ssh/action.yml create mode 100644 scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml diff --git a/.gitignore b/.gitignore index 2c8d939..b16e597 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ vendor/ -.github +/.github diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index 8f3925d..b2b1eaa 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -35,7 +35,7 @@ runs: fi echo "Using PANTHEON_SITE_NAME=$PANTHEON_SITE_NAME" - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v6 with: node-version-file: '.nvmrc' cache: 'npm' @@ -53,7 +53,7 @@ runs: run: | cd test/playwright mkdir -p test-results - npm run test:browserstack -- --ignore-snapshots + npm run test:browserstack env: NODE_OPTIONS: --disable-warning=DEP0205 BASE_URL: ${{ inputs.target-url }} diff --git a/scaffold/.github/actions/code-testing/github/decide-test-run/action.yml b/scaffold/.github/actions/code-testing/github/decide-test-run/action.yml new file mode 100644 index 0000000..62fe803 --- /dev/null +++ b/scaffold/.github/actions/code-testing/github/decide-test-run/action.yml @@ -0,0 +1,75 @@ +name: 'Decide if Tests Should Run' +description: 'Decides whether a workflow_run-triggered test job should proceed: gated on the configured primary branch for push builds, or on a PR label for review app builds' + +inputs: + github-token: + description: 'GitHub token used to look up PR labels' + required: true + primary-branch: + description: 'The branch whose build workflow should trigger tests (e.g. main or edge)' + required: false + default: 'main' + build-workflow-prefix: + description: 'Prefix of the push-triggered build workflow name, matched against ""' + required: false + default: 'Pantheon Build ' + review-apps-workflow-name: + description: 'Name of the PR-triggered review app workflow' + required: false + default: 'Pantheon Review Apps' + pr-label: + description: 'Label required on a PR before tests run against its review app' + required: false + default: 'browserstack' + +outputs: + should-run: + description: 'Whether the calling job should proceed with testing' + value: ${{ steps.decide.outputs.should-run }} + multidev-name: + description: 'Pantheon multidev name to test against' + value: ${{ steps.decide.outputs.multidev-name }} + +runs: + using: composite + steps: + - name: Decide whether to run tests + id: decide + shell: bash + env: + GH_TOKEN: ${{ inputs.github-token }} + GH_REPO: ${{ github.repository }} + WORKFLOW_NAME: ${{ github.event.workflow_run.name }} + PRIMARY_BRANCH: ${{ inputs.primary-branch }} + BUILD_WORKFLOW_PREFIX: ${{ inputs.build-workflow-prefix }} + REVIEW_APPS_WORKFLOW_NAME: ${{ inputs.review-apps-workflow-name }} + PR_LABEL: ${{ inputs.pr-label }} + PULL_REQUESTS_JSON: ${{ toJSON(github.event.workflow_run.pull_requests) }} + run: | + if [[ "$WORKFLOW_NAME" == "$REVIEW_APPS_WORKFLOW_NAME" ]]; then + PR_NUMBER=$(echo "$PULL_REQUESTS_JSON" | jq -r '.[0].number // empty') + if [[ -z "$PR_NUMBER" ]]; then + echo "::notice::No pull request associated with this run, skipping." + echo "should-run=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name') + if echo "$LABELS" | grep -qx "$PR_LABEL"; then + echo "should-run=true" >> "$GITHUB_OUTPUT" + echo "multidev-name=pr-${PR_NUMBER}" >> "$GITHUB_OUTPUT" + else + echo "::notice::PR #$PR_NUMBER is missing the '$PR_LABEL' label, skipping." + echo "should-run=false" >> "$GITHUB_OUTPUT" + fi + elif [[ "$WORKFLOW_NAME" == "${BUILD_WORKFLOW_PREFIX}${PRIMARY_BRANCH}" ]]; then + echo "should-run=true" >> "$GITHUB_OUTPUT" + if [[ "$PRIMARY_BRANCH" == "main" ]]; then + echo "multidev-name=dev" >> "$GITHUB_OUTPUT" + else + echo "multidev-name=$PRIMARY_BRANCH" >> "$GITHUB_OUTPUT" + fi + else + echo "::notice::$WORKFLOW_NAME is not the configured primary branch ($PRIMARY_BRANCH), skipping." + echo "should-run=false" >> "$GITHUB_OUTPUT" + fi diff --git a/scaffold/.github/actions/code-testing/playwright/test/action.yml b/scaffold/.github/actions/code-testing/playwright/test/action.yml index 8faa746..620c09c 100644 --- a/scaffold/.github/actions/code-testing/playwright/test/action.yml +++ b/scaffold/.github/actions/code-testing/playwright/test/action.yml @@ -38,11 +38,14 @@ runs: shell: bash env: NODE_OPTIONS: --disable-warning=DEP0205 - run: cd test/playwright && mkdir -p test-results && npm run ${{ inputs.test-script }} -- ${{ inputs.test-args }} + run: | + cd test/playwright + mkdir -p test-results + npm run ${{ inputs.test-script }} -- ${{ inputs.test-args }} - name: Upload test results if: ${{ !cancelled() }} uses: actions/upload-artifact@v4 with: name: playwright-report path: test/playwright/playwright-report/ - retention-days: 10 + retention-days: 5 diff --git a/scaffold/.github/actions/drainpipe/ddev/action.yml b/scaffold/.github/actions/drainpipe/ddev/action.yml new file mode 100644 index 0000000..c6e5a36 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/ddev/action.yml @@ -0,0 +1,82 @@ +name: 'Install and Start DDEV' +description: 'Installs the latest or specified version of DDEV and starts the project' +inputs: + ssh-private-key: + description: "SSH Private Key" + required: false + ssh-known-hosts: + description: "SSH Known Hosts" + required: false + git-email: + description: "Git e-mail address" + required: false + git-name: + description: "Git name" + required: false + composer-cache-dir: + description: "Composer cache directory, relative to the project workspace. Set to false to disable." + required: false + version: + description: "Override the DDEV version e.g. '1.19.0'" + required: false +runs: + using: "composite" + steps: + - name: Configure SSH keys + shell: bash + env: + INPUT_SSH_PRIVATE_KEY: ${{ inputs.ssh-private-key }} + INPUT_SSH_KNOWN_HOSTS: ${{ inputs.ssh-known-hosts }} + run: | + mkdir -p .ddev/homeadditions/.ssh + touch .ddev/homeadditions/.ssh/config + if [ "$INPUT_SSH_PRIVATE_KEY" != "" ]; then + echo "$INPUT_SSH_PRIVATE_KEY" > .ddev/homeadditions/.ssh/id_drainpipe + chmod 600 .ddev/homeadditions/.ssh/id_drainpipe + echo "IdentityFile ~/.ssh/id_drainpipe" >> .ddev/homeadditions/.ssh/config + fi + if [ "$INPUT_SSH_KNOWN_HOSTS" != "" ]; then + echo "$INPUT_SSH_KNOWN_HOSTS" > .ddev/homeadditions/.ssh/known_hosts + chmod 644 .ddev/homeadditions/.ssh/known_hosts + fi + if [ -f "pantheon.yml" ]; then + echo -e "Host *.drush.in\\n\\tStrictHostKeyChecking no\\n\tLogLevel ERROR\\n" >> .ddev/homeadditions/.ssh/config + fi + chmod 600 .ddev/homeadditions/.ssh/config + chmod 700 .ddev/homeadditions/.ssh + + - name: Install DDEV + uses: ddev/github-action-setup-ddev@fdf2f5c97943bae638f31df6df86f1defa6210c0 # v1 + with: + version: ${{ inputs.version || 'latest' }} + autostart: 'false' + + - name: Configure Composer cache and start DDEV + shell: bash + env: + INPUT_COMPOSER_CACHE_DIR: ${{ inputs.composer-cache-dir }} + run: | + if [ "$INPUT_COMPOSER_CACHE_DIR" != "false" ]; then + CACHE_DIR=".ddev/.drainpipe-composer-cache" + if [ "$INPUT_COMPOSER_CACHE_DIR" != "" ]; then + CACHE_DIR="$INPUT_COMPOSER_CACHE_DIR" + fi + # Workaround for https://github.com/ddev/ddev/issues/6044 + if yq -re .type .ddev/config.yaml; then + ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR" --project-type="$(yq -re .type .ddev/config.yaml)" + else + ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR" + fi + fi + ddev start + ddev describe + + - name: Configure git credentials + shell: bash + env: + INPUT_GIT_NAME: ${{ inputs.git-name }} + INPUT_GIT_EMAIL: ${{ inputs.git-email }} + run: | + ddev exec "git config --global user.name \"$INPUT_GIT_NAME\"" + ddev exec "git config --global user.email \"$INPUT_GIT_EMAIL\"" + echo "DRAINPIPE_DDEV=true" >> $GITHUB_ENV diff --git a/scaffold/.github/actions/drainpipe/deployment-create/action.yml b/scaffold/.github/actions/drainpipe/deployment-create/action.yml new file mode 100644 index 0000000..4277cc3 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/deployment-create/action.yml @@ -0,0 +1,31 @@ +name: "Create a GitHub deployment" +description: "Creates a GitHub deployment and echos the ID to the $GITHUB_ENV file" +inputs: + github-token: + description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" + required: true + environment: + description: "The environment name" + required: true +runs: + using: "composite" + steps: + - uses: ./.github/actions/drainpipe/set-env + + - name: Create GitHub Deployment + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + INPUT_ENVIRONMENT: ${{ inputs.environment }} + run: | # zizmor: ignore[github-env] + export GITHUB_DEPLOYMENT=$(curl -f -X POST \ + https://api.github.com/repos/$GITHUB_REPOSITORY/deployments \ + -H 'Accept: application/vnd.github.v3+json' \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d "{\"ref\": \"$DRAINPIPE_SHA\", \"auto_merge\": false, \"environment\": \"$INPUT_ENVIRONMENT\", \"transient_environment\": false, \"required_contexts\": [], \"description\": \"Acquia Cloud environment\"}" \ + ) + export GITHUB_DEPLOYMENT_ID=$(echo $GITHUB_DEPLOYMENT | jq '.id') + echo "Created GitHub Deployment ID $GITHUB_DEPLOYMENT_ID" + if [ -z "$GITHUB_DEPLOYMENT_ID" ] || [ "$GITHUB_DEPLOYMENT_ID" = "null" ]; then echo $GITHUB_DEPLOYMENT && exit 1; fi + echo "GITHUB_DEPLOYMENT_ID=$GITHUB_DEPLOYMENT_ID" >> $GITHUB_ENV + curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d '{"state":"in_progress"}' + shell: bash diff --git a/scaffold/.github/actions/drainpipe/deployment-status/action.yml b/scaffold/.github/actions/drainpipe/deployment-status/action.yml new file mode 100644 index 0000000..024bf06 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/deployment-status/action.yml @@ -0,0 +1,42 @@ +name: 'Sets the GitHub Deployment status' +description: 'Sets a GitHub deployment to success or failure' +inputs: + github-token: + description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" + required: true + environment-url: + description: "The environment URL" + required: true +runs: + using: "composite" + steps: + - uses: ./.github/actions/drainpipe/set-env + + - name: Set deployment to success + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + run: | + + if [ -z "$GITHUB_DEPLOYMENT_ID" ] || [ "$GITHUB_DEPLOYMENT_ID" = "null" ]; then echo $GITHUB_DEPLOYMENT && exit 1; fi + + curl -f -X POST \ + -H "Authorization: token $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses \ + -d '{"state":"success"}' + + shell: bash + + - name: Set Deployment Failure Status + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + run: | + curl -f -X POST \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses \ + -d "{\"state\":\"failure\"}" + + if: ${{ failure() }} + shell: bash diff --git a/scaffold/.github/actions/drainpipe/lockfile-diff/action.yml b/scaffold/.github/actions/drainpipe/lockfile-diff/action.yml new file mode 100644 index 0000000..e94e542 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/lockfile-diff/action.yml @@ -0,0 +1,126 @@ +name: Lockfile Diff Comment +description: > + Computes a human-readable diff between the base branch and HEAD versions of a + lockfile (yarn.lock or package-lock.json) and posts/updates a sticky PR comment + via marocchino/sticky-pull-request-comment. + +inputs: + token: + description: GitHub token with pull-requests:write and contents:read permissions. + required: true + lockfile: + description: Path to the lockfile relative to the repository root. + required: true + lockfile-type: + description: Lockfile format. Must be "yarn" or "npm". + required: false + default: '' + fail-on-downgrade: + description: Fail the action when a dependency downgrade is detected. The comment is still posted. + required: false + default: 'false' + collapse-threshold: + description: > + Total number of changed packages above which the comment body is wrapped in a +
block to keep the PR page readable. + required: false + default: '25' + +runs: + using: composite + steps: + - name: Install lockfile parsing dependencies + id: install-deps + shell: bash + run: | + DEPS_DIR="${RUNNER_TEMP}/lockfile-diff-deps" + mkdir -p "$DEPS_DIR" + npm install --prefix "$DEPS_DIR" \ + @yarnpkg/lockfile@^1.1.0 \ + @yarnpkg/parsers \ + --no-save --no-package-lock --loglevel error + echo "deps_dir=$DEPS_DIR" >> "$GITHUB_OUTPUT" + + - name: Extract base lockfile + id: extract-base + shell: bash + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + LOCKFILE_PATH: ${{ inputs.lockfile }} + run: | + if [[ "$LOCKFILE_PATH" == *".."* || "$LOCKFILE_PATH" == /* ]]; then + echo "::error::Invalid lockfile path" + exit 1 + fi + + BASE_FILE="${RUNNER_TEMP}/base.lock" + + if git show "${BASE_SHA}:${LOCKFILE_PATH}" > "$BASE_FILE" 2>/dev/null; then + echo "Base lockfile found at ${BASE_SHA}:${LOCKFILE_PATH}" + else + # Lockfile is new in this PR — treat base as empty. + echo "" > "$BASE_FILE" + echo "No base lockfile found; treating as newly added." + fi + + echo "base_lock_file=$BASE_FILE" >> "$GITHUB_OUTPUT" + echo "head_lock_file=${GITHUB_WORKSPACE}/${LOCKFILE_PATH}" >> "$GITHUB_OUTPUT" + + - name: Compute diff + id: diff + shell: bash + env: + LOCKFILE_TYPE: ${{ inputs.lockfile-type }} + LOCKFILE_PATH: ${{ inputs.lockfile }} + COLLAPSE_THRESHOLD: ${{ inputs.collapse-threshold }} + ACTION_PATH: ${{ github.action_path }} + BASE_LOCK_FILE: ${{ steps.extract-base.outputs.base_lock_file }} + HEAD_LOCK_FILE: ${{ steps.extract-base.outputs.head_lock_file }} + LOCKFILE_DIFF_DEPS: ${{ steps.install-deps.outputs.deps_dir }} + run: | + # Infer type from filename when not explicitly provided. + TYPE="$LOCKFILE_TYPE" + if [[ -z "$TYPE" ]]; then + if [[ "$(basename "$LOCKFILE_PATH")" == "yarn.lock" ]]; then + TYPE="yarn" + else + TYPE="npm" + fi + fi + + OUTPUT=$(node \ + "$ACTION_PATH/diff.mjs" \ + --type "$TYPE" \ + --base "$BASE_LOCK_FILE" \ + --head "$HEAD_LOCK_FILE" \ + --collapse-threshold "$COLLAPSE_THRESHOLD" \ + --deps-dir "$LOCKFILE_DIFF_DEPS") + + # Safely write multi-line output using a randomised delimiter. + EOF_DELIM=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null | base64) + { + echo "body<<${EOF_DELIM}" + echo "$OUTPUT" + echo "${EOF_DELIM}" + } >> "$GITHUB_OUTPUT" + + # Read downgrade flag written to disk by the script. + DOWNGRADE_FILE="${RUNNER_TEMP}/lockfile-diff-downgrade" + HAS_DOWNGRADE="false" + [[ -f "$DOWNGRADE_FILE" ]] && HAS_DOWNGRADE=$(cat "$DOWNGRADE_FILE") + + echo "has_downgrade=$HAS_DOWNGRADE" >> "$GITHUB_OUTPUT" + + - name: Post sticky PR comment + uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4 + with: + header: lockfile-diff + GITHUB_TOKEN: ${{ inputs.token }} + message: ${{ steps.diff.outputs.body }} + + - name: Fail on downgrade + if: ${{ inputs.fail-on-downgrade == 'true' && steps.diff.outputs.has_downgrade == 'true' }} + shell: bash + run: | + echo "::error::Dependency downgrade(s) detected. See the PR comment for details." + exit 1 diff --git a/scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs b/scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs new file mode 100644 index 0000000..8d986bc --- /dev/null +++ b/scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs @@ -0,0 +1,226 @@ +#!/usr/bin/env node +/** + * lockfile-diff/diff.mjs + * + * Parses two lockfiles (base vs head), computes added/removed/updated packages, + * and prints a Markdown summary to stdout. + * + * Supported formats: + * - yarn.lock v1 (classic) via @yarnpkg/lockfile + * - yarn.lock v2+ (Berry) via @yarnpkg/parsers + * - package-lock.json v1/v2/v3 (npm 5+) via JSON.parse + * + * CLI args: + * --type yarn | npm + * --base path to base lockfile + * --head path to head lockfile + * --collapse-threshold number (default: 25) + * --deps-dir path where @yarnpkg/lockfile was npm-installed + */ + +import { readFileSync, writeFileSync, existsSync } from 'fs'; +import { resolve } from 'path'; +import { createRequire } from 'module'; +import { env } from 'process'; +import { parseArgs } from 'util'; + +// Argument parsing +const { values: args } = parseArgs({ + options: { + type: { type: 'string' }, + base: { type: 'string' }, + head: { type: 'string' }, + 'collapse-threshold': { type: 'string' }, + 'deps-dir': { type: 'string' }, + }, +}); + +const TYPE = args['type'] ?? 'yarn'; +const BASE_PATH = args['base']; +const HEAD_PATH = args['head']; +const COLLAPSE_THRESHOLD = parseInt(args['collapse-threshold'] ?? '25', 10); +const DEPS_DIR = args['deps-dir']; + +if (!BASE_PATH || !HEAD_PATH) { + console.error('Usage: diff.mjs --type yarn|npm --base --head [--collapse-threshold N] [--deps-dir ]'); + process.exit(1); +} + +// Parsers — each returns Map + +/** + * Yarn lockfile parser — supports both Classic v1 and Berry (v2+). + * + * Berry lockfiles contain a "__metadata:" block; Classic ones do not. + * Classic is parsed with @yarnpkg/lockfile; Berry with @yarnpkg/parsers. + * + * Key format examples (both formats): + * react@^18.0.0: + * "react@^18.0.0, react@^18.2.0": + * "@babel/core@npm:^7.0.0": + */ +function parseYarn(content) { + if (!DEPS_DIR) throw new Error('--deps-dir is required for yarn lockfile parsing'); + + const depsRequire = createRequire(new URL(`file://${resolve(DEPS_DIR)}/sentinel.js`)); + + // Berry (v2+) lockfiles begin with an __metadata block; Classic ones do not. + const isBerry = /^__metadata:/m.test(content); + + let entries; + if (isBerry) { + const { parseSyml } = depsRequire('@yarnpkg/parsers'); + const parsed = parseSyml(content); + entries = Object.entries(parsed).filter(([key]) => key !== '__metadata'); + } else { + const classicParser = depsRequire('@yarnpkg/lockfile'); + const result = classicParser.parse(content); + if (result.type !== 'success') throw new Error('Failed to parse yarn.lock'); + entries = Object.entries(result.object); + } + + const map = new Map(); + for (const [key, entry] of entries) { + const firstName = key.split(',')[0].trim(); + const nameMatch = firstName.match(/^(@[^/]+\/[^@]+|[^@]+)/); + const name = nameMatch ? nameMatch[0] : firstName; + // Keep the highest version if the same package appears under multiple specifier groups. + if (!map.has(name) || compareVersions(entry.version, map.get(name)) > 0) { + map.set(name, entry.version); + } + } + return map; +} + +/** + * package-lock.json (npm 5+). + * v2/v3 uses `packages` (keys prefixed "node_modules/…"). + * v1 uses `dependencies`. v2 includes both; we prefer `packages`. + */ +function parseNpm(content) { + const lock = JSON.parse(content); + const map = new Map(); + + if (lock.packages) { + for (const [key, entry] of Object.entries(lock.packages)) { + if (!key) continue; // root entry has an empty string key in v2/v3 + const name = key.replace(/^node_modules\//, ''); + if (entry.version) map.set(name, entry.version); + } + } else if (lock.dependencies) { + for (const [name, entry] of Object.entries(lock.dependencies)) { + if (entry.version) map.set(name, entry.version); + } + } + + return map; +} + +// Semver comparison (major.minor.patch — sufficient for diff purposes) +function compareVersions(a, b) { + const nums = (v) => String(v).split('-')[0].replace(/^[^0-9]*/, '').split('.').map(Number); + const [aMaj = 0, aMin = 0, aPat = 0] = nums(a); + const [bMaj = 0, bMin = 0, bPat = 0] = nums(b); + return aMaj !== bMaj ? aMaj - bMaj + : aMin !== bMin ? aMin - bMin + : aPat - bPat; +} + +// File loading — gracefully handles missing or empty files +function parseFile(filePath) { + if (!existsSync(filePath)) return new Map(); + const content = readFileSync(filePath, 'utf8').trim(); + if (!content) return new Map(); + return TYPE === 'npm' ? parseNpm(content) : parseYarn(content); +} + +// Diff computation +const baseMap = parseFile(BASE_PATH); +const headMap = parseFile(HEAD_PATH); + +const added = []; +const removed = []; +const updated = []; + +for (const name of [...new Set([...baseMap.keys(), ...headMap.keys()])].sort()) { + const baseVer = baseMap.get(name); + const headVer = headMap.get(name); + + if (!baseVer && headVer) added.push({ name, version: headVer }); + else if (baseVer && !headVer) removed.push({ name, version: baseVer }); + else if (baseVer && headVer && baseVer !== headVer) updated.push({ + name, from: baseVer, to: headVer, + downgrade: compareVersions(baseVer, headVer) > 0, + }); +} + +const hasDowngrade = updated.some((p) => p.downgrade); +const totalChanges = added.length + removed.length + updated.length; +const lockfileLabel = TYPE === 'yarn' ? 'yarn.lock' : 'package-lock.json'; +const shortSha = (env.GITHUB_SHA ?? '').slice(0, 7) || 'unknown'; +const timestamp = new Date().toISOString(); + +const escape = (s) => String(s).replace(/`/g, "'").replace(/[|\\$]/g, '\\$&').replace(/[\r\n]/g, ' '); + +// Markdown output +function buildTables() { + let out = ''; + + if (added.length) { + out += `### ➕ Added (${added.length})\n\n`; + out += `| Package | Version |\n|---|---|\n`; + for (const { name, version } of added) out += `| \`${escape(name)}\` | \`${escape(version)}\` |\n`; + out += '\n'; + } + + if (removed.length) { + out += `### ➖ Removed (${removed.length})\n\n`; + out += `| Package | Version |\n|---|---|\n`; + for (const { name, version } of removed) out += `| \`${escape(name)}\` | \`${escape(version)}\` |\n`; + out += '\n'; + } + + if (updated.length) { + out += `### 🔄 Updated (${updated.length})\n\n`; + out += `| Package | From | To | Note |\n|---|---|---|---|\n`; + for (const { name, from, to, downgrade } of updated) { + out += `| \`${escape(name)}\` | \`${escape(from)}\` | \`${escape(to)}\` | ${downgrade ? '⚠️ downgrade' : ''} |\n`; + } + out += '\n'; + } + + return out; +} + +let body = `## 🔒 Lockfile Changes — \`${lockfileLabel}\`\n\n`; + +if (totalChanges === 0) { + body += `_No dependency changes detected._\n`; +} else { + const summary = [ + added.length && `**${added.length}** added`, + removed.length && `**${removed.length}** removed`, + updated.length && `**${updated.length}** updated`, + hasDowngrade && `⚠️ **includes downgrade(s)**`, + ].filter(Boolean).join(' · '); + + body += `${summary}\n\n`; + + const tables = buildTables(); + if (totalChanges >= COLLAPSE_THRESHOLD) { + body += `
\nShow all ${totalChanges} changes\n\n${tables}\n
\n`; + } else { + body += tables; + } +} + +body += `\nUpdated at ${timestamp} · commit \`${shortSha}\`\n`; + +process.stdout.write(body); + +// Signal downgrade status to the shell via a temp file. +writeFileSync( + `${env.RUNNER_TEMP ?? '/tmp'}/lockfile-diff-downgrade`, + hasDowngrade ? 'true' : 'false', + 'utf8' +); diff --git a/scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml b/scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml new file mode 100644 index 0000000..8debceb --- /dev/null +++ b/scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml @@ -0,0 +1,47 @@ +name: "Clone Environment" +description: "Clones a Pantheon Environment to another site" +inputs: + source-site-name: + description: "Source site name" + required: true + source-environment: + description: "Source environment i.e. dev, test, or live" + required: true + target-site-name: + description: "Target site name" + required: true + target-environment: + description: "Target environment i.e. dev, test, or live" + required: true + terminus-token: + description: "Pantheon Terminus Token" + required: true +runs: + using: "composite" + steps: + - name: Clone Environment + env: + INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} + INPUT_SOURCE_SITE: ${{ inputs.source-site-name }} + INPUT_SOURCE_ENV: ${{ inputs.source-environment }} + INPUT_TARGET_SITE: ${{ inputs.target-site-name }} + INPUT_TARGET_ENV: ${{ inputs.target-environment }} + run: | + source .github/actions/drainpipe/set-env/bash_aliases + drainpipe_exec "terminus auth:login --machine-token=\"$INPUT_TERMINUS_TOKEN\"" + if [ "$INPUT_SOURCE_SITE" == "$INPUT_TARGET_SITE" ]; then + drainpipe_exec "terminus -y env:clone-content $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV $INPUT_TARGET_ENV" + else + drainpipe_exec "terminus backup:create $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=database" + drainpipe_exec "terminus backup:create $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=files" + TARGET_SITE_ID=$(drainpipe_exec "terminus site:lookup $INPUT_TARGET_SITE") + DATABASE_URL=$(drainpipe_exec "terminus backup:get $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=database") + # Cannot pass the URL on the command line directly because it has weird characters. + echo $DATABASE_URL > db.env + drainpipe_exec "terminus -y import:database $INPUT_TARGET_SITE.$INPUT_TARGET_ENV \"\$(cat db.env)\"" + rm db.env + curl -o files.tar.gz $(drainpipe_exec "terminus backup:get $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=files") + tar -xf files.tar.gz + drainpipe_exec "rsync -rLvz --delete --size-only --checksum --ipv4 --progress -e 'ssh -p 2222' ./files_$INPUT_SOURCE_ENV/. --temp-dir=~/tmp/ $INPUT_TARGET_ENV.$TARGET_SITE_ID@appserver.$INPUT_TARGET_ENV.$TARGET_SITE_ID.drush.in:files" + fi + shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/push/action.yml b/scaffold/.github/actions/drainpipe/pantheon/push/action.yml new file mode 100644 index 0000000..112fb7c --- /dev/null +++ b/scaffold/.github/actions/drainpipe/pantheon/push/action.yml @@ -0,0 +1,41 @@ +name: 'Push code to Pantheon' +description: 'Pushes code to a Pantheon site' +inputs: + terminus-token: + description: "Pantheon Terminus Token" + required: true + site-name: + description: "Pantheon site machine name" + required: true + branch: + description: "Which branch to push to" + required: true + commit-message: + description: "The commit message to use when pushing to Pantheon" + required: true +runs: + using: "composite" + steps: + - name: Trust all drush.in hosts + run: | + source .github/actions/drainpipe/set-env/bash_aliases + drainpipe_exec "echo -e \"Host *.drush.in\n StrictHostKeyChecking no\n HostkeyAlgorithms +ssh-rsa\n PubkeyAcceptedKeyTypes +ssh-rsa\" >> ~/.ssh/config" + shell: bash + + - name: Push to Pantheon + env: + INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} + INPUT_SITE_NAME: ${{ inputs.site-name }} + INPUT_BRANCH: ${{ inputs.branch }} + INPUT_COMMIT_MESSAGE: ${{ inputs.commit-message }} + run: | + source .github/actions/drainpipe/set-env/bash_aliases + drainpipe_exec terminus auth:login --machine-token="$INPUT_TERMINUS_TOKEN" + SITE_ID=$(drainpipe_exec "terminus site:lookup $INPUT_SITE_NAME") + if [ "$INPUT_BRANCH" == "master" ]; then + drainpipe_exec "terminus connection:set $INPUT_SITE_NAME.dev git --yes" + else + drainpipe_exec "terminus connection:set $INPUT_SITE_NAME.$INPUT_BRANCH git --yes" + fi + drainpipe_exec "./vendor/bin/task deploy:git directory=/tmp/release branch=$INPUT_BRANCH remote=ssh://codeserver.dev.$SITE_ID@codeserver.dev.$SITE_ID.drush.in:2222/~/repository.git message=\"$INPUT_COMMIT_MESSAGE\"" + shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/review/action.yml b/scaffold/.github/actions/drainpipe/pantheon/review/action.yml new file mode 100644 index 0000000..884ab94 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/pantheon/review/action.yml @@ -0,0 +1,209 @@ +name: 'Deploy Review app to Pantheon' +description: 'Deploys a review app to Pantheon Multidev' +inputs: + github-token: + description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" + required: true + terminus-token: + description: "Pantheon Terminus Token" + required: true + site-name: + description: "Pantheon site machine name" + required: true + run-installer: + description: "Whether or not to run the Drupal site installer. Defaults to false." + required: false + commit-message: + description: "The commit message to use when pushing to Pantheon" + required: true + lock-username: + description: "The username if locking this environment with Basic Auth" + required: false + lock-password: + description: "The password if locking this environment with Basic Auth" + required: false + clone-from: + description: "The environment to clone from. Defaults to live." + required: false + default: "live" + terminus-timeout-limit: + description: "The number of seconds that terminus will wait until timeout. Defaults to 600." + required: false + default: "600" + skip-wipe-multidev: + description: "Whether or not to skip wiping the multidev on each push. Defaults to false." + required: false + default: "false" +runs: + using: "composite" + steps: + - uses: ./.github/actions/drainpipe/set-env + + - name: Validate site-name parameter + env: + INPUT_SITE_NAME: ${{ inputs.site-name }} + run: | + SITE_NAME="$INPUT_SITE_NAME" + if ! [[ "$SITE_NAME" =~ ^[a-zA-Z0-9_-]+$ ]]; then + echo "::error::site-name parameter must contain only alphanumeric characters, underscores, and hyphens." + exit 1 + fi + echo "Site name validated: $SITE_NAME" + shell: bash + + - name: Validate clone-from parameter + env: + INPUT_CLONE_FROM: ${{ inputs.clone-from }} + run: | + CLONE_FROM="$INPUT_CLONE_FROM" + if ! [[ "$CLONE_FROM" =~ ^[a-zA-Z0-9._-]+$ ]]; then + echo "::error::clone-from parameter must contain only alphanumeric characters, periods, underscores, and hyphens." + exit 1 + fi + echo "Clone-from environment validated: $CLONE_FROM" + shell: bash + + - name: Trust all drush.in hosts + run: | + source .github/actions/drainpipe/set-env/bash_aliases + drainpipe_exec "echo -e \"Host *.drush.in\n StrictHostKeyChecking no\n HostkeyAlgorithms +ssh-rsa\n PubkeyAcceptedKeyTypes +ssh-rsa\" >> ~/.ssh/config" + drainpipe_exec "cat ~/.ssh/config" + shell: bash + + - name: Create GitHub Deployment + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + run: | # zizmor: ignore[github-env] + export GITHUB_DEPLOYMENT=$(curl -f -X POST \ + https://api.github.com/repos/$GITHUB_REPOSITORY/deployments \ + -H 'Accept: application/vnd.github.v3+json' \ + -H "Authorization: token $GITHUB_TOKEN" \ + -d "{\"ref\": \"$DRAINPIPE_SHA\", \"auto_merge\": false, \"environment\": \"pantheon-pr-$DRAINPIPE_PR_NUMBER\", \"transient_environment\": true, \"required_contexts\": [], \"description\": \"Pantheon Multidev for Pull Request #$DRAINPIPE_PR_NUMBER\"}" \ + ) + export GITHUB_DEPLOYMENT_ID=$(echo $GITHUB_DEPLOYMENT | jq '.id') + echo "Created GitHub Deployment ID $GITHUB_DEPLOYMENT_ID" + if [ -z "$GITHUB_DEPLOYMENT_ID" ] || [ "$GITHUB_DEPLOYMENT_ID" = "null" ]; then echo $GITHUB_DEPLOYMENT && exit 1; fi + echo "GITHUB_DEPLOYMENT_ID=$GITHUB_DEPLOYMENT_ID" >> $GITHUB_ENV + curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d '{"state":"in_progress"}' + shell: bash + + - name: Clean Stale Environments + env: + INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} + GITHUB_TOKEN: ${{ inputs.github-token }} + INPUT_SITE_NAME: ${{ inputs.site-name }} + run: | + source .github/actions/drainpipe/set-env/bash_aliases + echo "Cleaning stale Multidev environments" + drainpipe_exec "terminus auth:login --machine-token=\"$INPUT_TERMINUS_TOKEN\"" + PULLS=$(curl -f \ + https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open \ + -H 'Accept: application/vnd.github.v3+json' \ + -H "Authorization: token $GITHUB_TOKEN" \ + ) + # Truncate PR names to 11 chars to match Pantheon's multidev name limit. + PULL_NUMBERS=$(echo $PULLS | jq -r '.[] | "pr-" + (.number|tostring)' | cut -c1-11) + MULTIDEVS=$(drainpipe_exec "terminus multidev:list --format json $INPUT_SITE_NAME | jq --raw-output 'keys | .[]'") + for MULTIDEV in $MULTIDEVS; do + if echo "$PULL_NUMBERS" | grep -Fxq "$MULTIDEV"; then + echo "Found open PR for $MULTIDEV" + # if $MULTIDEV starts with "pr-" + elif [[ $MULTIDEV == pr-* ]]; then + echo "No PR for $MULTIDEV, shutting down..." + DEPLOYMENTS=$(curl -s -f -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments?environment=pantheon-$MULTIDEV | jq '.[] | .id') + for DEPLOYMENT_ID in $DEPLOYMENTS; do + echo "Marking GitHub Deployment $DEPLOYMENT_ID as inactive" + curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$DEPLOYMENT_ID/statuses -d "{\"state\":\"inactive\"}" + curl -H "Authorization: token $GITHUB_TOKEN" -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/environments/pantheon-$MULTIDEV + done + drainpipe_exec "terminus multidev:delete $INPUT_SITE_NAME.$MULTIDEV --delete-branch --yes" + else + echo "Dangling Multidev environment $MULTIDEV found, no action taken." + fi + done + shell: bash + + - name: Create or Update Multidev + env: + INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} + INPUT_SITE_NAME: ${{ inputs.site-name }} + INPUT_CLONE_FROM: ${{ inputs.clone-from }} + INPUT_RUN_INSTALLER: ${{ inputs.run-installer }} + INPUT_SKIP_WIPE_MULTIDEV: ${{ inputs.skip-wipe-multidev }} + run: | # zizmor: ignore[github-env] + source .github/actions/drainpipe/set-env/bash_aliases + drainpipe_exec "terminus auth:login --machine-token=\"$INPUT_TERMINUS_TOKEN\"" + REQUESTED_NAME="pr-$DRAINPIPE_PR_NUMBER" + JQ_COMMAND="'.[] | select(.id == \"$REQUESTED_NAME\") | .id'" + ENVIRONMENT_EXISTS=$(drainpipe_exec "terminus multidev:list --format json $INPUT_SITE_NAME | jq --raw-output $JQ_COMMAND") + if [ "$ENVIRONMENT_EXISTS" == "$REQUESTED_NAME" ]; then + if [ "$INPUT_SKIP_WIPE_MULTIDEV" != "true" ]; then + drainpipe_exec "terminus env:wipe $INPUT_SITE_NAME.$REQUESTED_NAME --yes" + fi + MULTIDEV_NAME="$REQUESTED_NAME" + else + if [ "$INPUT_SKIP_WIPE_MULTIDEV" != "true" ]; then + drainpipe_exec "terminus multidev:create $INPUT_SITE_NAME.$INPUT_CLONE_FROM $REQUESTED_NAME --no-db --no-files --yes" + else + drainpipe_exec "terminus multidev:create $INPUT_SITE_NAME.$INPUT_CLONE_FROM $REQUESTED_NAME --yes" + fi + # Query Pantheon for the actual environment name, which may have been + # truncated to 11 characters by the platform. + MULTIDEV_NAME=$(drainpipe_exec "terminus multidev:list --format json $INPUT_SITE_NAME | jq --raw-output 'keys | .[] | select(startswith(\"${REQUESTED_NAME:0:11}\"))'") + echo "::notice::Requested multidev name: $REQUESTED_NAME — Pantheon created: $MULTIDEV_NAME" + fi + echo "MULTIDEV_NAME=$MULTIDEV_NAME" >> $GITHUB_ENV + if [ "$INPUT_RUN_INSTALLER" != "true" ] && [ "$INPUT_SKIP_WIPE_MULTIDEV" != "true" ]; then + drainpipe_exec "terminus env:clone-content $INPUT_SITE_NAME.$INPUT_CLONE_FROM $MULTIDEV_NAME --yes" + fi + shell: bash + + - name: Push to Pantheon + env: + INPUT_SITE_NAME: ${{ inputs.site-name }} + INPUT_COMMIT_MESSAGE: ${{ inputs.commit-message }} + run: | + source .github/actions/drainpipe/set-env/bash_aliases + SITE_ID=$(drainpipe_exec "terminus site:lookup $INPUT_SITE_NAME") + drainpipe_exec "terminus connection:set $INPUT_SITE_NAME.$MULTIDEV_NAME git --yes" + drainpipe_exec "./vendor/bin/task deploy:git directory=/tmp/release branch=$MULTIDEV_NAME remote=ssh://codeserver.dev.$SITE_ID@codeserver.dev.$SITE_ID.drush.in:2222/~/repository.git message=\"$INPUT_COMMIT_MESSAGE\" site=$INPUT_SITE_NAME.$MULTIDEV_NAME" + shell: bash + + - name: Deploy to Pantheon + env: + INPUT_TERMINUS_TIMEOUT: ${{ inputs.terminus-timeout-limit }} + INPUT_SITE_NAME: ${{ inputs.site-name }} + INPUT_RUN_INSTALLER: ${{ inputs.run-installer }} + INPUT_LOCK_USERNAME: ${{ inputs.lock-username }} + INPUT_LOCK_PASSWORD: ${{ inputs.lock-password }} + GITHUB_TOKEN: ${{ inputs.github-token }} + run: | + source .github/actions/drainpipe/set-env/bash_aliases + + echo "::notice::Waiting $INPUT_TERMINUS_TIMEOUT seconds for Pantheon to sync..." + drainpipe_exec "terminus workflow:wait -vv --max $INPUT_TERMINUS_TIMEOUT -- $INPUT_SITE_NAME.$MULTIDEV_NAME" + + drainpipe_exec "terminus aliases --only $INPUT_SITE_NAME --yes" + if [ "$INPUT_RUN_INSTALLER" == "true" ]; then + drainpipe_exec "./vendor/bin/drush @$INPUT_SITE_NAME.$MULTIDEV_NAME --yes site:install --existing-config" + elif drainpipe_exec "./vendor/bin/task -l | grep '* update: '"; then + drainpipe_exec "./vendor/bin/task update site=@$INPUT_SITE_NAME.$MULTIDEV_NAME" + else + drainpipe_exec "./vendor/bin/task drupal:update site=@$INPUT_SITE_NAME.$MULTIDEV_NAME" + fi + ENVIRONMENT_URL="https://$MULTIDEV_NAME-$INPUT_SITE_NAME.pantheonsite.io" + # Lock Environment. + if [ "$INPUT_LOCK_USERNAME" != "" ] && [ "$INPUT_LOCK_PASSWORD" != "" ]; then + drainpipe_exec "terminus lock:enable $INPUT_SITE_NAME.$MULTIDEV_NAME $INPUT_LOCK_USERNAME $INPUT_LOCK_PASSWORD" + ENVIRONMENT_URL="https://$INPUT_LOCK_USERNAME:$INPUT_LOCK_PASSWORD@$MULTIDEV_NAME-$INPUT_SITE_NAME.pantheonsite.io" + fi + curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d "{\"state\":\"success\", \"environment_url\": \"$ENVIRONMENT_URL\"}" + shell: bash + + - name: Set Deployment Failure Status + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + run: | + curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d "{\"state\":\"failure\"}" + if: ${{ failure() }} + shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml b/scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml new file mode 100644 index 0000000..15dfa8c --- /dev/null +++ b/scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml @@ -0,0 +1,24 @@ +name: 'Prepare Pantheon Environment' +description: 'Sets up Terminus and authorises with Pantheon' +inputs: + terminus-token: + description: "Pantheon Terminus Token" + required: true + terminus-plugins: + description: "Terminus plugins" + required: false +runs: + using: "composite" + steps: + - env: + INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} + INPUT_TERMINUS_PLUGINS: ${{ inputs.terminus-plugins }} + run: | + echo -e "Host *.drush.in\n StrictHostKeyChecking no\n HostkeyAlgorithms +ssh-rsa\n PubkeyAcceptedAlgorithms +ssh-rsa" >> ~/.ssh/config + mkdir ~/terminus + curl -L https://github.com/pantheon-systems/terminus/releases/download/4.1.1/terminus.phar --output ~/terminus/terminus + chmod +x ~/terminus/terminus + ln -s ~/terminus/terminus /usr/local/bin/terminus + echo "$INPUT_TERMINUS_PLUGINS" | while read -d, plugin || [[ -n $plugin ]]; do terminus self:plugin:install $plugin; done + terminus auth:login --machine-token="$INPUT_TERMINUS_TOKEN" + shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/update/action.yml b/scaffold/.github/actions/drainpipe/pantheon/update/action.yml new file mode 100644 index 0000000..2b294a7 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/pantheon/update/action.yml @@ -0,0 +1,33 @@ +name: "Update or Install Pantheon Site" +description: "Runs the Drupal updater or the site installer in a Pantheon environment" +inputs: + site-name: + description: "Pantheon site machine name" + required: true + run-installer: + description: "Whether or not to run the Drupal site installer. Defaults to false." + required: false + environment: + description: "The environment to run the updates or install in e.g. 'test'" + required: true +runs: + using: "composite" + steps: + - name: Update site on Pantheon + env: + INPUT_SITE_NAME: ${{ inputs.site-name }} + INPUT_ENVIRONMENT: ${{ inputs.environment }} + INPUT_RUN_INSTALLER: ${{ inputs.run-installer }} + run: | + # Wait for Pantheon to sync. + source .github/actions/drainpipe/set-env/bash_aliases + drainpipe_exec "terminus workflow:wait $INPUT_SITE_NAME.$INPUT_ENVIRONMENT" + drainpipe_exec "terminus aliases --only $INPUT_SITE_NAME --yes" + if [ "$INPUT_RUN_INSTALLER" == "true" ]; then + drainpipe_exec "./vendor/bin/drush @$INPUT_SITE_NAME.$INPUT_ENVIRONMENT --yes site:install --existing-config" + elif drainpipe_exec "./vendor/bin/task -l | grep '* update: '"; then + drainpipe_exec "./vendor/bin/task update site=@$INPUT_SITE_NAME.$INPUT_ENVIRONMENT" + else + drainpipe_exec "./vendor/bin/task drupal:update site=@$INPUT_SITE_NAME.$INPUT_ENVIRONMENT" + fi + shell: bash diff --git a/scaffold/.github/actions/drainpipe/set-env/action.yml b/scaffold/.github/actions/drainpipe/set-env/action.yml new file mode 100644 index 0000000..05249cb --- /dev/null +++ b/scaffold/.github/actions/drainpipe/set-env/action.yml @@ -0,0 +1,62 @@ +name: 'Set Env' +description: 'Creates some useful environment variables' +runs: + using: "composite" + steps: + - run: | # zizmor: ignore[github-env] + echo "Setting Drainpipe environment variables:" + echo "GITHUB_EVENT_NAME: $GITHUB_EVENT_NAME" + echo "GITHUB_REF: $GITHUB_REF" + echo "GITHUB_REF_NAME: $GITHUB_REF_NAME" + + if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && "$GITHUB_REF" == refs/heads/* ]]; then + # Get PR number for the current branch using gh + DRAINPIPE_PR_NUMBER=$(gh pr list --state open --head "$GITHUB_REF_NAME" --json number --jq '.[0].number') + if [ -n "$DRAINPIPE_PR_NUMBER" ]; then + DRAINPIPE_SHA=$(gh pr view "$DRAINPIPE_PR_NUMBER" --json headRefOid --jq '.headRefOid') + else + # Fallback to else logic if no PR found + DRAINPIPE_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + DRAINPIPE_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha) + fi + else + # Extract PR number from GITHUB_REF (for PR events) + DRAINPIPE_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') + DRAINPIPE_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha) + fi + + # Sanitize: PR number must be numeric, SHA must be hex characters + DRAINPIPE_PR_NUMBER=$(echo "$DRAINPIPE_PR_NUMBER" | tr -cd '0-9') + DRAINPIPE_SHA=$(echo "$DRAINPIPE_SHA" | tr -cd '0-9a-f') + + echo "DRAINPIPE_PR_NUMBER=$DRAINPIPE_PR_NUMBER" >> $GITHUB_ENV + + if [ -z "$DRAINPIPE_SHA" ] || [ "$DRAINPIPE_SHA" = "null" ]; then + DRAINPIPE_SHA=$DRAINPIPE_PR_NUMBER + fi + echo "DRAINPIPE_SHA=$DRAINPIPE_SHA" >> $GITHUB_ENV + + echo "The variables have been set:" + echo "DRAINPIPE_PR_NUMBER: $DRAINPIPE_PR_NUMBER" + echo "DRAINPIPE_SHA: $DRAINPIPE_SHA" + + shell: bash + env: + GH_TOKEN: ${{ github.token }} + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + path: drainpipe + persist-credentials: false + + - run: | # zizmor: ignore[github-env] + if [[ -f .nvmrc ]]; then + NODE_FILE=.nvmrc + else + NODE_FILE=drainpipe/.nvmrc + fi + # Sanitize: strip whitespace then keep only numeric characters + NODE_MAJOR=$(tr -d '[:space:]' < "$NODE_FILE" | tr -cd '0-9') + echo "NODE_MAJOR=${NODE_MAJOR}" >> "$GITHUB_ENV" + + shell: bash diff --git a/scaffold/.github/actions/drainpipe/set-env/bash_aliases b/scaffold/.github/actions/drainpipe/set-env/bash_aliases new file mode 100644 index 0000000..58fca27 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/set-env/bash_aliases @@ -0,0 +1,7 @@ +drainpipe_exec() { + if [ "$DRAINPIPE_DDEV" == "true" ]; then + ddev exec "$@" + else + eval "$@" + fi +} diff --git a/scaffold/.github/actions/drainpipe/setup-git/action.yml b/scaffold/.github/actions/drainpipe/setup-git/action.yml new file mode 100644 index 0000000..c8c6922 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/setup-git/action.yml @@ -0,0 +1,19 @@ +name: 'Configure git' +description: 'Configures git username and e-mail address' +inputs: + git-email: + description: "Git e-mail address" + required: true + git-name: + description: "Git name" + required: true +runs: + using: "composite" + steps: + - run: | + git config --global user.email "$INPUT_GIT_EMAIL" + git config --global user.name "$INPUT_GIT_NAME" + shell: bash + env: + INPUT_GIT_EMAIL: ${{ inputs.git-email }} + INPUT_GIT_NAME: ${{ inputs.git-name }} diff --git a/scaffold/.github/actions/drainpipe/setup-ssh/action.yml b/scaffold/.github/actions/drainpipe/setup-ssh/action.yml new file mode 100644 index 0000000..c112937 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/setup-ssh/action.yml @@ -0,0 +1,29 @@ +name: 'Configure ssh' +description: 'Configures SSH' +inputs: + ssh-private-key: + description: "SSH Private Key" + required: true + ssh-known-hosts: + description: "SSH Known Hosts" + required: false +runs: + using: "composite" + steps: + - run: | + sudo apt-get update + sudo apt-get install -y openssh-client + eval $(ssh-agent -s) + echo "$INPUT_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + mkdir -p ~/.ssh + chmod 700 ~/.ssh + touch ~/.ssh/config + chmod 600 ~/.ssh/config + if [ "$INPUT_SSH_KNOWN_HOSTS" != "" ]; then + echo "$INPUT_SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts + chmod 644 ~/.ssh/known_hosts + fi + shell: bash + env: + INPUT_SSH_PRIVATE_KEY: ${{ inputs.ssh-private-key }} + INPUT_SSH_KNOWN_HOSTS: ${{ inputs.ssh-known-hosts }} diff --git a/scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml b/scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml new file mode 100644 index 0000000..ffaf7d0 --- /dev/null +++ b/scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml @@ -0,0 +1,20 @@ +name: 'Validate TERMINUS_TIMEOUT_LIMIT' +description: 'Validates and sets the TERMINUS_TIMEOUT_LIMIT environment variable' +inputs: + terminus_timeout_limit: + description: 'Timeout in seconds for Terminus' + required: false +runs: + using: "composite" + steps: + - name: Validate TERMINUS_TIMEOUT_LIMIT + shell: bash + env: + INPUT_TIMEOUT_LIMIT: ${{ inputs.terminus_timeout_limit || '600' }} + run: | # zizmor: ignore[github-env] + TIMEOUT_LIMIT="$INPUT_TIMEOUT_LIMIT" + if ! [[ "$TIMEOUT_LIMIT" =~ ^[0-9]+$ ]]; then + echo "::error::TERMINUS_TIMEOUT_LIMIT must be a number. It represents the number of seconds that terminus will wait until timeout. Current value: $TIMEOUT_LIMIT" + exit 1 + fi + echo "TERMINUS_TIMEOUT_LIMIT=$TIMEOUT_LIMIT" >> "$GITHUB_ENV" From fac79852de74a0a78040f5d948abfe41dbd7eb2d Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 6 Jul 2026 14:40:13 -0500 Subject: [PATCH 06/34] Clean up playwright tests including drainpipePlaywrightTests.yml --- .../actions/code-testing/playwright/test/action.yml | 13 ++++++------- .../.github/workflows/drainpipePlaywrightTests.yml | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/scaffold/.github/actions/code-testing/playwright/test/action.yml b/scaffold/.github/actions/code-testing/playwright/test/action.yml index 620c09c..86de5c2 100644 --- a/scaffold/.github/actions/code-testing/playwright/test/action.yml +++ b/scaffold/.github/actions/code-testing/playwright/test/action.yml @@ -13,10 +13,6 @@ inputs: description: "The npm script to run (defined in test/playwright/package.json). Defaults to 'test'." required: false default: "test" - test-args: - description: "Additional arguments to pass to the Playwright test. For instance --ignore-snapshots --project=func-chromium. Prefer test-script for CI contexts." - required: false - default: "" runs: using: composite @@ -38,13 +34,16 @@ runs: shell: bash env: NODE_OPTIONS: --disable-warning=DEP0205 + BASE_URL: ${{ inputs.target-url }} + BASIC_AUTH_USER: ${{ inputs.pantheon-review-username }} + BASIC_AUTH_PASS: ${{ inputs.patheon-review-password }} run: | cd test/playwright mkdir -p test-results - npm run ${{ inputs.test-script }} -- ${{ inputs.test-args }} + npm run ${{ inputs.test-script }} - name: Upload test results - if: ${{ !cancelled() }} - uses: actions/upload-artifact@v4 + if: ${{ always() }} + uses: actions/upload-artifact@v6 with: name: playwright-report path: test/playwright/playwright-report/ diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 8106c35..9006867 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -170,7 +170,7 @@ jobs: - name: Run Playwright tests in DDEV uses: ./.github/actions/code-testing/playwright/test with: - environment-password: '' - environment-username: '' + environment-password: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + environment-username: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} target-url: ${{ steps.ddev-url.outputs.url }} test-script: 'test:ci-pantheon' \ No newline at end of file From 9c9293885e70d8d1878103668d4b129cd7937cdb Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 6 Jul 2026 14:58:44 -0500 Subject: [PATCH 07/34] Use php version checkout --- .../workflows/deploymentBrowserStackTests.yml | 19 +++++++++++++++---- .../workflows/deploymentPlaywrightTests.yml | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/scaffold/.github/workflows/deploymentBrowserStackTests.yml b/scaffold/.github/workflows/deploymentBrowserStackTests.yml index 0cf2a87..5359497 100644 --- a/scaffold/.github/workflows/deploymentBrowserStackTests.yml +++ b/scaffold/.github/workflows/deploymentBrowserStackTests.yml @@ -4,9 +4,21 @@ on: deployment_status: { } jobs: + detect-php-version: + name: Detect PHP Version + runs-on: ubuntu-latest + if: github.event.deployment_status.state == 'success' + outputs: + php-version: ${{ steps.php-version.outputs.php-version }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Read php_version from Pantheon config + id: php-version + uses: ./.github/actions/code-testing/detect-php-version Decide-If-Tests-Should-Run: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} + if: ${{ github.event.deployment_status.state == 'success' }} outputs: should-run: ${{ steps.decide.outputs.should-run }} multidev-name: ${{ steps.decide.outputs.multidev-name }} @@ -29,7 +41,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.4" + php-version: ${{ needs.detect-php-version.outputs.php-version }} - name: Install Terminus uses: pantheon-systems/terminus-github-actions@v1 @@ -75,5 +87,4 @@ jobs: browserstack-username: ${{ secrets.BROWSERSTACK_USERNAME }} pantheon-review-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} pantheon-review-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} - pantheon-site-name: ${{ vars.PANTHEON_SITE_NAME }} - target-url: '' \ No newline at end of file + target-url: ${{ steps.set-url.outputs.target_url }} \ No newline at end of file diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml index 2d20a37..23a0bd3 100644 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ b/scaffold/.github/workflows/deploymentPlaywrightTests.yml @@ -4,6 +4,18 @@ on: deployment_status: {} jobs: + detect-php-version: + name: Detect PHP Version + runs-on: ubuntu-latest + if: github.event.deployment_status.state == 'success' + outputs: + php-version: ${{ steps.php-version.outputs.php-version }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Read php_version from Pantheon config + id: php-version + uses: ./.github/actions/code-testing/detect-php-version Playwright-Tests: runs-on: ubuntu-latest if: github.event.deployment_status.state == 'success' @@ -13,7 +25,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.4" + php-version: ${{ needs.detect-php-version.outputs.php-version }} - name: Install Terminus uses: pantheon-systems/terminus-github-actions@v1 @@ -32,7 +44,7 @@ jobs: # Playwright steps go here - name: Checkout actions - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Run Playwright tests uses: ./.github/actions/code-testing/playwright/test @@ -40,4 +52,4 @@ jobs: target-url: ${{ github.event.deployment_status.environment_url }} environment-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} environment-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} - test-script: 'ci-pantheon' \ No newline at end of file + test-script: 'test:ci-pantheon' \ No newline at end of file From 0ec547b078a812a953b828f42e0a66847b63e644 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 6 Jul 2026 15:00:27 -0500 Subject: [PATCH 08/34] Use php version checkout in drainpipeBrowserStackTests.yml --- .../workflows/drainpipeBrowserStackTests.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml index f37ce46..6c45186 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml @@ -14,6 +14,18 @@ permissions: pull-requests: read jobs: + detect-php-version: + name: Detect PHP Version + runs-on: ubuntu-latest + if: github.event.deployment_status.state == 'success' + outputs: + php-version: ${{ steps.php-version.outputs.php-version }} + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Read php_version from Pantheon config + id: php-version + uses: ./.github/actions/code-testing/detect-php-version Decide-If-Tests-Should-Run: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} @@ -40,7 +52,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: "8.4" + php-version: ${{ needs.detect-php-version.outputs.php-version }} - name: Install Terminus uses: pantheon-systems/terminus-github-actions@v1 From 9efacbbc5b042358a6f80fcd50a88383e7e4ac3c Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 6 Jul 2026 15:37:06 -0500 Subject: [PATCH 09/34] Ignore drainpipe scaffolding --- .gitignore | 1 + .../code-testing/playwright/test/action.yml | 2 +- .../.github/actions/drainpipe/ddev/action.yml | 82 ------- .../drainpipe/deployment-create/action.yml | 31 --- .../drainpipe/deployment-status/action.yml | 42 ---- .../drainpipe/lockfile-diff/action.yml | 126 ---------- .../actions/drainpipe/lockfile-diff/diff.mjs | 226 ------------------ .../drainpipe/pantheon/clone-env/action.yml | 47 ---- .../drainpipe/pantheon/push/action.yml | 41 ---- .../drainpipe/pantheon/review/action.yml | 209 ---------------- .../pantheon/setup-terminus/action.yml | 24 -- .../drainpipe/pantheon/update/action.yml | 33 --- .../actions/drainpipe/set-env/action.yml | 62 ----- .../actions/drainpipe/set-env/bash_aliases | 7 - .../actions/drainpipe/setup-git/action.yml | 19 -- .../actions/drainpipe/setup-ssh/action.yml | 29 --- .../validate-terminus-timeout/action.yml | 20 -- .../workflows/deploymentBrowserStackTests.yml | 55 ++++- .../workflows/deploymentPlaywrightTests.yml | 16 +- 19 files changed, 47 insertions(+), 1025 deletions(-) delete mode 100644 scaffold/.github/actions/drainpipe/ddev/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/deployment-create/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/deployment-status/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/lockfile-diff/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs delete mode 100644 scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/pantheon/push/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/pantheon/review/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/pantheon/update/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/set-env/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/set-env/bash_aliases delete mode 100644 scaffold/.github/actions/drainpipe/setup-git/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/setup-ssh/action.yml delete mode 100644 scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml diff --git a/.gitignore b/.gitignore index b16e597..d898263 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ vendor/ /.github +/scaffold/.github/actions/drainpipe \ No newline at end of file diff --git a/scaffold/.github/actions/code-testing/playwright/test/action.yml b/scaffold/.github/actions/code-testing/playwright/test/action.yml index 86de5c2..26fe83c 100644 --- a/scaffold/.github/actions/code-testing/playwright/test/action.yml +++ b/scaffold/.github/actions/code-testing/playwright/test/action.yml @@ -28,7 +28,7 @@ runs: run: | cd test/playwright npm ci - npx playwright install --with-deps chromium chromium-headless-shell + npx playwright install - name: Run Playwright tests shell: bash diff --git a/scaffold/.github/actions/drainpipe/ddev/action.yml b/scaffold/.github/actions/drainpipe/ddev/action.yml deleted file mode 100644 index c6e5a36..0000000 --- a/scaffold/.github/actions/drainpipe/ddev/action.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: 'Install and Start DDEV' -description: 'Installs the latest or specified version of DDEV and starts the project' -inputs: - ssh-private-key: - description: "SSH Private Key" - required: false - ssh-known-hosts: - description: "SSH Known Hosts" - required: false - git-email: - description: "Git e-mail address" - required: false - git-name: - description: "Git name" - required: false - composer-cache-dir: - description: "Composer cache directory, relative to the project workspace. Set to false to disable." - required: false - version: - description: "Override the DDEV version e.g. '1.19.0'" - required: false -runs: - using: "composite" - steps: - - name: Configure SSH keys - shell: bash - env: - INPUT_SSH_PRIVATE_KEY: ${{ inputs.ssh-private-key }} - INPUT_SSH_KNOWN_HOSTS: ${{ inputs.ssh-known-hosts }} - run: | - mkdir -p .ddev/homeadditions/.ssh - touch .ddev/homeadditions/.ssh/config - if [ "$INPUT_SSH_PRIVATE_KEY" != "" ]; then - echo "$INPUT_SSH_PRIVATE_KEY" > .ddev/homeadditions/.ssh/id_drainpipe - chmod 600 .ddev/homeadditions/.ssh/id_drainpipe - echo "IdentityFile ~/.ssh/id_drainpipe" >> .ddev/homeadditions/.ssh/config - fi - if [ "$INPUT_SSH_KNOWN_HOSTS" != "" ]; then - echo "$INPUT_SSH_KNOWN_HOSTS" > .ddev/homeadditions/.ssh/known_hosts - chmod 644 .ddev/homeadditions/.ssh/known_hosts - fi - if [ -f "pantheon.yml" ]; then - echo -e "Host *.drush.in\\n\\tStrictHostKeyChecking no\\n\tLogLevel ERROR\\n" >> .ddev/homeadditions/.ssh/config - fi - chmod 600 .ddev/homeadditions/.ssh/config - chmod 700 .ddev/homeadditions/.ssh - - - name: Install DDEV - uses: ddev/github-action-setup-ddev@fdf2f5c97943bae638f31df6df86f1defa6210c0 # v1 - with: - version: ${{ inputs.version || 'latest' }} - autostart: 'false' - - - name: Configure Composer cache and start DDEV - shell: bash - env: - INPUT_COMPOSER_CACHE_DIR: ${{ inputs.composer-cache-dir }} - run: | - if [ "$INPUT_COMPOSER_CACHE_DIR" != "false" ]; then - CACHE_DIR=".ddev/.drainpipe-composer-cache" - if [ "$INPUT_COMPOSER_CACHE_DIR" != "" ]; then - CACHE_DIR="$INPUT_COMPOSER_CACHE_DIR" - fi - # Workaround for https://github.com/ddev/ddev/issues/6044 - if yq -re .type .ddev/config.yaml; then - ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR" --project-type="$(yq -re .type .ddev/config.yaml)" - else - ddev config --web-environment-add="COMPOSER_CACHE_DIR=/var/www/html/$CACHE_DIR" - fi - fi - ddev start - ddev describe - - - name: Configure git credentials - shell: bash - env: - INPUT_GIT_NAME: ${{ inputs.git-name }} - INPUT_GIT_EMAIL: ${{ inputs.git-email }} - run: | - ddev exec "git config --global user.name \"$INPUT_GIT_NAME\"" - ddev exec "git config --global user.email \"$INPUT_GIT_EMAIL\"" - echo "DRAINPIPE_DDEV=true" >> $GITHUB_ENV diff --git a/scaffold/.github/actions/drainpipe/deployment-create/action.yml b/scaffold/.github/actions/drainpipe/deployment-create/action.yml deleted file mode 100644 index 4277cc3..0000000 --- a/scaffold/.github/actions/drainpipe/deployment-create/action.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "Create a GitHub deployment" -description: "Creates a GitHub deployment and echos the ID to the $GITHUB_ENV file" -inputs: - github-token: - description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" - required: true - environment: - description: "The environment name" - required: true -runs: - using: "composite" - steps: - - uses: ./.github/actions/drainpipe/set-env - - - name: Create GitHub Deployment - env: - GITHUB_TOKEN: ${{ inputs.github-token }} - INPUT_ENVIRONMENT: ${{ inputs.environment }} - run: | # zizmor: ignore[github-env] - export GITHUB_DEPLOYMENT=$(curl -f -X POST \ - https://api.github.com/repos/$GITHUB_REPOSITORY/deployments \ - -H 'Accept: application/vnd.github.v3+json' \ - -H "Authorization: token $GITHUB_TOKEN" \ - -d "{\"ref\": \"$DRAINPIPE_SHA\", \"auto_merge\": false, \"environment\": \"$INPUT_ENVIRONMENT\", \"transient_environment\": false, \"required_contexts\": [], \"description\": \"Acquia Cloud environment\"}" \ - ) - export GITHUB_DEPLOYMENT_ID=$(echo $GITHUB_DEPLOYMENT | jq '.id') - echo "Created GitHub Deployment ID $GITHUB_DEPLOYMENT_ID" - if [ -z "$GITHUB_DEPLOYMENT_ID" ] || [ "$GITHUB_DEPLOYMENT_ID" = "null" ]; then echo $GITHUB_DEPLOYMENT && exit 1; fi - echo "GITHUB_DEPLOYMENT_ID=$GITHUB_DEPLOYMENT_ID" >> $GITHUB_ENV - curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d '{"state":"in_progress"}' - shell: bash diff --git a/scaffold/.github/actions/drainpipe/deployment-status/action.yml b/scaffold/.github/actions/drainpipe/deployment-status/action.yml deleted file mode 100644 index 024bf06..0000000 --- a/scaffold/.github/actions/drainpipe/deployment-status/action.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: 'Sets the GitHub Deployment status' -description: 'Sets a GitHub deployment to success or failure' -inputs: - github-token: - description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" - required: true - environment-url: - description: "The environment URL" - required: true -runs: - using: "composite" - steps: - - uses: ./.github/actions/drainpipe/set-env - - - name: Set deployment to success - env: - GITHUB_TOKEN: ${{ inputs.github-token }} - run: | - - if [ -z "$GITHUB_DEPLOYMENT_ID" ] || [ "$GITHUB_DEPLOYMENT_ID" = "null" ]; then echo $GITHUB_DEPLOYMENT && exit 1; fi - - curl -f -X POST \ - -H "Authorization: token $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses \ - -d '{"state":"success"}' - - shell: bash - - - name: Set Deployment Failure Status - env: - GITHUB_TOKEN: ${{ inputs.github-token }} - run: | - curl -f -X POST \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses \ - -d "{\"state\":\"failure\"}" - - if: ${{ failure() }} - shell: bash diff --git a/scaffold/.github/actions/drainpipe/lockfile-diff/action.yml b/scaffold/.github/actions/drainpipe/lockfile-diff/action.yml deleted file mode 100644 index e94e542..0000000 --- a/scaffold/.github/actions/drainpipe/lockfile-diff/action.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: Lockfile Diff Comment -description: > - Computes a human-readable diff between the base branch and HEAD versions of a - lockfile (yarn.lock or package-lock.json) and posts/updates a sticky PR comment - via marocchino/sticky-pull-request-comment. - -inputs: - token: - description: GitHub token with pull-requests:write and contents:read permissions. - required: true - lockfile: - description: Path to the lockfile relative to the repository root. - required: true - lockfile-type: - description: Lockfile format. Must be "yarn" or "npm". - required: false - default: '' - fail-on-downgrade: - description: Fail the action when a dependency downgrade is detected. The comment is still posted. - required: false - default: 'false' - collapse-threshold: - description: > - Total number of changed packages above which the comment body is wrapped in a -
block to keep the PR page readable. - required: false - default: '25' - -runs: - using: composite - steps: - - name: Install lockfile parsing dependencies - id: install-deps - shell: bash - run: | - DEPS_DIR="${RUNNER_TEMP}/lockfile-diff-deps" - mkdir -p "$DEPS_DIR" - npm install --prefix "$DEPS_DIR" \ - @yarnpkg/lockfile@^1.1.0 \ - @yarnpkg/parsers \ - --no-save --no-package-lock --loglevel error - echo "deps_dir=$DEPS_DIR" >> "$GITHUB_OUTPUT" - - - name: Extract base lockfile - id: extract-base - shell: bash - env: - BASE_SHA: ${{ github.event.pull_request.base.sha }} - LOCKFILE_PATH: ${{ inputs.lockfile }} - run: | - if [[ "$LOCKFILE_PATH" == *".."* || "$LOCKFILE_PATH" == /* ]]; then - echo "::error::Invalid lockfile path" - exit 1 - fi - - BASE_FILE="${RUNNER_TEMP}/base.lock" - - if git show "${BASE_SHA}:${LOCKFILE_PATH}" > "$BASE_FILE" 2>/dev/null; then - echo "Base lockfile found at ${BASE_SHA}:${LOCKFILE_PATH}" - else - # Lockfile is new in this PR — treat base as empty. - echo "" > "$BASE_FILE" - echo "No base lockfile found; treating as newly added." - fi - - echo "base_lock_file=$BASE_FILE" >> "$GITHUB_OUTPUT" - echo "head_lock_file=${GITHUB_WORKSPACE}/${LOCKFILE_PATH}" >> "$GITHUB_OUTPUT" - - - name: Compute diff - id: diff - shell: bash - env: - LOCKFILE_TYPE: ${{ inputs.lockfile-type }} - LOCKFILE_PATH: ${{ inputs.lockfile }} - COLLAPSE_THRESHOLD: ${{ inputs.collapse-threshold }} - ACTION_PATH: ${{ github.action_path }} - BASE_LOCK_FILE: ${{ steps.extract-base.outputs.base_lock_file }} - HEAD_LOCK_FILE: ${{ steps.extract-base.outputs.head_lock_file }} - LOCKFILE_DIFF_DEPS: ${{ steps.install-deps.outputs.deps_dir }} - run: | - # Infer type from filename when not explicitly provided. - TYPE="$LOCKFILE_TYPE" - if [[ -z "$TYPE" ]]; then - if [[ "$(basename "$LOCKFILE_PATH")" == "yarn.lock" ]]; then - TYPE="yarn" - else - TYPE="npm" - fi - fi - - OUTPUT=$(node \ - "$ACTION_PATH/diff.mjs" \ - --type "$TYPE" \ - --base "$BASE_LOCK_FILE" \ - --head "$HEAD_LOCK_FILE" \ - --collapse-threshold "$COLLAPSE_THRESHOLD" \ - --deps-dir "$LOCKFILE_DIFF_DEPS") - - # Safely write multi-line output using a randomised delimiter. - EOF_DELIM=$(dd if=/dev/urandom bs=15 count=1 2>/dev/null | base64) - { - echo "body<<${EOF_DELIM}" - echo "$OUTPUT" - echo "${EOF_DELIM}" - } >> "$GITHUB_OUTPUT" - - # Read downgrade flag written to disk by the script. - DOWNGRADE_FILE="${RUNNER_TEMP}/lockfile-diff-downgrade" - HAS_DOWNGRADE="false" - [[ -f "$DOWNGRADE_FILE" ]] && HAS_DOWNGRADE=$(cat "$DOWNGRADE_FILE") - - echo "has_downgrade=$HAS_DOWNGRADE" >> "$GITHUB_OUTPUT" - - - name: Post sticky PR comment - uses: marocchino/sticky-pull-request-comment@0ea0beb66eb9baf113663a64ec522f60e49231c0 # v3.0.4 - with: - header: lockfile-diff - GITHUB_TOKEN: ${{ inputs.token }} - message: ${{ steps.diff.outputs.body }} - - - name: Fail on downgrade - if: ${{ inputs.fail-on-downgrade == 'true' && steps.diff.outputs.has_downgrade == 'true' }} - shell: bash - run: | - echo "::error::Dependency downgrade(s) detected. See the PR comment for details." - exit 1 diff --git a/scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs b/scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs deleted file mode 100644 index 8d986bc..0000000 --- a/scaffold/.github/actions/drainpipe/lockfile-diff/diff.mjs +++ /dev/null @@ -1,226 +0,0 @@ -#!/usr/bin/env node -/** - * lockfile-diff/diff.mjs - * - * Parses two lockfiles (base vs head), computes added/removed/updated packages, - * and prints a Markdown summary to stdout. - * - * Supported formats: - * - yarn.lock v1 (classic) via @yarnpkg/lockfile - * - yarn.lock v2+ (Berry) via @yarnpkg/parsers - * - package-lock.json v1/v2/v3 (npm 5+) via JSON.parse - * - * CLI args: - * --type yarn | npm - * --base path to base lockfile - * --head path to head lockfile - * --collapse-threshold number (default: 25) - * --deps-dir path where @yarnpkg/lockfile was npm-installed - */ - -import { readFileSync, writeFileSync, existsSync } from 'fs'; -import { resolve } from 'path'; -import { createRequire } from 'module'; -import { env } from 'process'; -import { parseArgs } from 'util'; - -// Argument parsing -const { values: args } = parseArgs({ - options: { - type: { type: 'string' }, - base: { type: 'string' }, - head: { type: 'string' }, - 'collapse-threshold': { type: 'string' }, - 'deps-dir': { type: 'string' }, - }, -}); - -const TYPE = args['type'] ?? 'yarn'; -const BASE_PATH = args['base']; -const HEAD_PATH = args['head']; -const COLLAPSE_THRESHOLD = parseInt(args['collapse-threshold'] ?? '25', 10); -const DEPS_DIR = args['deps-dir']; - -if (!BASE_PATH || !HEAD_PATH) { - console.error('Usage: diff.mjs --type yarn|npm --base --head [--collapse-threshold N] [--deps-dir ]'); - process.exit(1); -} - -// Parsers — each returns Map - -/** - * Yarn lockfile parser — supports both Classic v1 and Berry (v2+). - * - * Berry lockfiles contain a "__metadata:" block; Classic ones do not. - * Classic is parsed with @yarnpkg/lockfile; Berry with @yarnpkg/parsers. - * - * Key format examples (both formats): - * react@^18.0.0: - * "react@^18.0.0, react@^18.2.0": - * "@babel/core@npm:^7.0.0": - */ -function parseYarn(content) { - if (!DEPS_DIR) throw new Error('--deps-dir is required for yarn lockfile parsing'); - - const depsRequire = createRequire(new URL(`file://${resolve(DEPS_DIR)}/sentinel.js`)); - - // Berry (v2+) lockfiles begin with an __metadata block; Classic ones do not. - const isBerry = /^__metadata:/m.test(content); - - let entries; - if (isBerry) { - const { parseSyml } = depsRequire('@yarnpkg/parsers'); - const parsed = parseSyml(content); - entries = Object.entries(parsed).filter(([key]) => key !== '__metadata'); - } else { - const classicParser = depsRequire('@yarnpkg/lockfile'); - const result = classicParser.parse(content); - if (result.type !== 'success') throw new Error('Failed to parse yarn.lock'); - entries = Object.entries(result.object); - } - - const map = new Map(); - for (const [key, entry] of entries) { - const firstName = key.split(',')[0].trim(); - const nameMatch = firstName.match(/^(@[^/]+\/[^@]+|[^@]+)/); - const name = nameMatch ? nameMatch[0] : firstName; - // Keep the highest version if the same package appears under multiple specifier groups. - if (!map.has(name) || compareVersions(entry.version, map.get(name)) > 0) { - map.set(name, entry.version); - } - } - return map; -} - -/** - * package-lock.json (npm 5+). - * v2/v3 uses `packages` (keys prefixed "node_modules/…"). - * v1 uses `dependencies`. v2 includes both; we prefer `packages`. - */ -function parseNpm(content) { - const lock = JSON.parse(content); - const map = new Map(); - - if (lock.packages) { - for (const [key, entry] of Object.entries(lock.packages)) { - if (!key) continue; // root entry has an empty string key in v2/v3 - const name = key.replace(/^node_modules\//, ''); - if (entry.version) map.set(name, entry.version); - } - } else if (lock.dependencies) { - for (const [name, entry] of Object.entries(lock.dependencies)) { - if (entry.version) map.set(name, entry.version); - } - } - - return map; -} - -// Semver comparison (major.minor.patch — sufficient for diff purposes) -function compareVersions(a, b) { - const nums = (v) => String(v).split('-')[0].replace(/^[^0-9]*/, '').split('.').map(Number); - const [aMaj = 0, aMin = 0, aPat = 0] = nums(a); - const [bMaj = 0, bMin = 0, bPat = 0] = nums(b); - return aMaj !== bMaj ? aMaj - bMaj - : aMin !== bMin ? aMin - bMin - : aPat - bPat; -} - -// File loading — gracefully handles missing or empty files -function parseFile(filePath) { - if (!existsSync(filePath)) return new Map(); - const content = readFileSync(filePath, 'utf8').trim(); - if (!content) return new Map(); - return TYPE === 'npm' ? parseNpm(content) : parseYarn(content); -} - -// Diff computation -const baseMap = parseFile(BASE_PATH); -const headMap = parseFile(HEAD_PATH); - -const added = []; -const removed = []; -const updated = []; - -for (const name of [...new Set([...baseMap.keys(), ...headMap.keys()])].sort()) { - const baseVer = baseMap.get(name); - const headVer = headMap.get(name); - - if (!baseVer && headVer) added.push({ name, version: headVer }); - else if (baseVer && !headVer) removed.push({ name, version: baseVer }); - else if (baseVer && headVer && baseVer !== headVer) updated.push({ - name, from: baseVer, to: headVer, - downgrade: compareVersions(baseVer, headVer) > 0, - }); -} - -const hasDowngrade = updated.some((p) => p.downgrade); -const totalChanges = added.length + removed.length + updated.length; -const lockfileLabel = TYPE === 'yarn' ? 'yarn.lock' : 'package-lock.json'; -const shortSha = (env.GITHUB_SHA ?? '').slice(0, 7) || 'unknown'; -const timestamp = new Date().toISOString(); - -const escape = (s) => String(s).replace(/`/g, "'").replace(/[|\\$]/g, '\\$&').replace(/[\r\n]/g, ' '); - -// Markdown output -function buildTables() { - let out = ''; - - if (added.length) { - out += `### ➕ Added (${added.length})\n\n`; - out += `| Package | Version |\n|---|---|\n`; - for (const { name, version } of added) out += `| \`${escape(name)}\` | \`${escape(version)}\` |\n`; - out += '\n'; - } - - if (removed.length) { - out += `### ➖ Removed (${removed.length})\n\n`; - out += `| Package | Version |\n|---|---|\n`; - for (const { name, version } of removed) out += `| \`${escape(name)}\` | \`${escape(version)}\` |\n`; - out += '\n'; - } - - if (updated.length) { - out += `### 🔄 Updated (${updated.length})\n\n`; - out += `| Package | From | To | Note |\n|---|---|---|---|\n`; - for (const { name, from, to, downgrade } of updated) { - out += `| \`${escape(name)}\` | \`${escape(from)}\` | \`${escape(to)}\` | ${downgrade ? '⚠️ downgrade' : ''} |\n`; - } - out += '\n'; - } - - return out; -} - -let body = `## 🔒 Lockfile Changes — \`${lockfileLabel}\`\n\n`; - -if (totalChanges === 0) { - body += `_No dependency changes detected._\n`; -} else { - const summary = [ - added.length && `**${added.length}** added`, - removed.length && `**${removed.length}** removed`, - updated.length && `**${updated.length}** updated`, - hasDowngrade && `⚠️ **includes downgrade(s)**`, - ].filter(Boolean).join(' · '); - - body += `${summary}\n\n`; - - const tables = buildTables(); - if (totalChanges >= COLLAPSE_THRESHOLD) { - body += `
\nShow all ${totalChanges} changes\n\n${tables}\n
\n`; - } else { - body += tables; - } -} - -body += `\nUpdated at ${timestamp} · commit \`${shortSha}\`\n`; - -process.stdout.write(body); - -// Signal downgrade status to the shell via a temp file. -writeFileSync( - `${env.RUNNER_TEMP ?? '/tmp'}/lockfile-diff-downgrade`, - hasDowngrade ? 'true' : 'false', - 'utf8' -); diff --git a/scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml b/scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml deleted file mode 100644 index 8debceb..0000000 --- a/scaffold/.github/actions/drainpipe/pantheon/clone-env/action.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: "Clone Environment" -description: "Clones a Pantheon Environment to another site" -inputs: - source-site-name: - description: "Source site name" - required: true - source-environment: - description: "Source environment i.e. dev, test, or live" - required: true - target-site-name: - description: "Target site name" - required: true - target-environment: - description: "Target environment i.e. dev, test, or live" - required: true - terminus-token: - description: "Pantheon Terminus Token" - required: true -runs: - using: "composite" - steps: - - name: Clone Environment - env: - INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} - INPUT_SOURCE_SITE: ${{ inputs.source-site-name }} - INPUT_SOURCE_ENV: ${{ inputs.source-environment }} - INPUT_TARGET_SITE: ${{ inputs.target-site-name }} - INPUT_TARGET_ENV: ${{ inputs.target-environment }} - run: | - source .github/actions/drainpipe/set-env/bash_aliases - drainpipe_exec "terminus auth:login --machine-token=\"$INPUT_TERMINUS_TOKEN\"" - if [ "$INPUT_SOURCE_SITE" == "$INPUT_TARGET_SITE" ]; then - drainpipe_exec "terminus -y env:clone-content $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV $INPUT_TARGET_ENV" - else - drainpipe_exec "terminus backup:create $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=database" - drainpipe_exec "terminus backup:create $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=files" - TARGET_SITE_ID=$(drainpipe_exec "terminus site:lookup $INPUT_TARGET_SITE") - DATABASE_URL=$(drainpipe_exec "terminus backup:get $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=database") - # Cannot pass the URL on the command line directly because it has weird characters. - echo $DATABASE_URL > db.env - drainpipe_exec "terminus -y import:database $INPUT_TARGET_SITE.$INPUT_TARGET_ENV \"\$(cat db.env)\"" - rm db.env - curl -o files.tar.gz $(drainpipe_exec "terminus backup:get $INPUT_SOURCE_SITE.$INPUT_SOURCE_ENV --element=files") - tar -xf files.tar.gz - drainpipe_exec "rsync -rLvz --delete --size-only --checksum --ipv4 --progress -e 'ssh -p 2222' ./files_$INPUT_SOURCE_ENV/. --temp-dir=~/tmp/ $INPUT_TARGET_ENV.$TARGET_SITE_ID@appserver.$INPUT_TARGET_ENV.$TARGET_SITE_ID.drush.in:files" - fi - shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/push/action.yml b/scaffold/.github/actions/drainpipe/pantheon/push/action.yml deleted file mode 100644 index 112fb7c..0000000 --- a/scaffold/.github/actions/drainpipe/pantheon/push/action.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: 'Push code to Pantheon' -description: 'Pushes code to a Pantheon site' -inputs: - terminus-token: - description: "Pantheon Terminus Token" - required: true - site-name: - description: "Pantheon site machine name" - required: true - branch: - description: "Which branch to push to" - required: true - commit-message: - description: "The commit message to use when pushing to Pantheon" - required: true -runs: - using: "composite" - steps: - - name: Trust all drush.in hosts - run: | - source .github/actions/drainpipe/set-env/bash_aliases - drainpipe_exec "echo -e \"Host *.drush.in\n StrictHostKeyChecking no\n HostkeyAlgorithms +ssh-rsa\n PubkeyAcceptedKeyTypes +ssh-rsa\" >> ~/.ssh/config" - shell: bash - - - name: Push to Pantheon - env: - INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} - INPUT_SITE_NAME: ${{ inputs.site-name }} - INPUT_BRANCH: ${{ inputs.branch }} - INPUT_COMMIT_MESSAGE: ${{ inputs.commit-message }} - run: | - source .github/actions/drainpipe/set-env/bash_aliases - drainpipe_exec terminus auth:login --machine-token="$INPUT_TERMINUS_TOKEN" - SITE_ID=$(drainpipe_exec "terminus site:lookup $INPUT_SITE_NAME") - if [ "$INPUT_BRANCH" == "master" ]; then - drainpipe_exec "terminus connection:set $INPUT_SITE_NAME.dev git --yes" - else - drainpipe_exec "terminus connection:set $INPUT_SITE_NAME.$INPUT_BRANCH git --yes" - fi - drainpipe_exec "./vendor/bin/task deploy:git directory=/tmp/release branch=$INPUT_BRANCH remote=ssh://codeserver.dev.$SITE_ID@codeserver.dev.$SITE_ID.drush.in:2222/~/repository.git message=\"$INPUT_COMMIT_MESSAGE\"" - shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/review/action.yml b/scaffold/.github/actions/drainpipe/pantheon/review/action.yml deleted file mode 100644 index 884ab94..0000000 --- a/scaffold/.github/actions/drainpipe/pantheon/review/action.yml +++ /dev/null @@ -1,209 +0,0 @@ -name: 'Deploy Review app to Pantheon' -description: 'Deploys a review app to Pantheon Multidev' -inputs: - github-token: - description: "GitHub token as generated automatically in secrets.GITHUB_TOKEN" - required: true - terminus-token: - description: "Pantheon Terminus Token" - required: true - site-name: - description: "Pantheon site machine name" - required: true - run-installer: - description: "Whether or not to run the Drupal site installer. Defaults to false." - required: false - commit-message: - description: "The commit message to use when pushing to Pantheon" - required: true - lock-username: - description: "The username if locking this environment with Basic Auth" - required: false - lock-password: - description: "The password if locking this environment with Basic Auth" - required: false - clone-from: - description: "The environment to clone from. Defaults to live." - required: false - default: "live" - terminus-timeout-limit: - description: "The number of seconds that terminus will wait until timeout. Defaults to 600." - required: false - default: "600" - skip-wipe-multidev: - description: "Whether or not to skip wiping the multidev on each push. Defaults to false." - required: false - default: "false" -runs: - using: "composite" - steps: - - uses: ./.github/actions/drainpipe/set-env - - - name: Validate site-name parameter - env: - INPUT_SITE_NAME: ${{ inputs.site-name }} - run: | - SITE_NAME="$INPUT_SITE_NAME" - if ! [[ "$SITE_NAME" =~ ^[a-zA-Z0-9_-]+$ ]]; then - echo "::error::site-name parameter must contain only alphanumeric characters, underscores, and hyphens." - exit 1 - fi - echo "Site name validated: $SITE_NAME" - shell: bash - - - name: Validate clone-from parameter - env: - INPUT_CLONE_FROM: ${{ inputs.clone-from }} - run: | - CLONE_FROM="$INPUT_CLONE_FROM" - if ! [[ "$CLONE_FROM" =~ ^[a-zA-Z0-9._-]+$ ]]; then - echo "::error::clone-from parameter must contain only alphanumeric characters, periods, underscores, and hyphens." - exit 1 - fi - echo "Clone-from environment validated: $CLONE_FROM" - shell: bash - - - name: Trust all drush.in hosts - run: | - source .github/actions/drainpipe/set-env/bash_aliases - drainpipe_exec "echo -e \"Host *.drush.in\n StrictHostKeyChecking no\n HostkeyAlgorithms +ssh-rsa\n PubkeyAcceptedKeyTypes +ssh-rsa\" >> ~/.ssh/config" - drainpipe_exec "cat ~/.ssh/config" - shell: bash - - - name: Create GitHub Deployment - env: - GITHUB_TOKEN: ${{ inputs.github-token }} - run: | # zizmor: ignore[github-env] - export GITHUB_DEPLOYMENT=$(curl -f -X POST \ - https://api.github.com/repos/$GITHUB_REPOSITORY/deployments \ - -H 'Accept: application/vnd.github.v3+json' \ - -H "Authorization: token $GITHUB_TOKEN" \ - -d "{\"ref\": \"$DRAINPIPE_SHA\", \"auto_merge\": false, \"environment\": \"pantheon-pr-$DRAINPIPE_PR_NUMBER\", \"transient_environment\": true, \"required_contexts\": [], \"description\": \"Pantheon Multidev for Pull Request #$DRAINPIPE_PR_NUMBER\"}" \ - ) - export GITHUB_DEPLOYMENT_ID=$(echo $GITHUB_DEPLOYMENT | jq '.id') - echo "Created GitHub Deployment ID $GITHUB_DEPLOYMENT_ID" - if [ -z "$GITHUB_DEPLOYMENT_ID" ] || [ "$GITHUB_DEPLOYMENT_ID" = "null" ]; then echo $GITHUB_DEPLOYMENT && exit 1; fi - echo "GITHUB_DEPLOYMENT_ID=$GITHUB_DEPLOYMENT_ID" >> $GITHUB_ENV - curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d '{"state":"in_progress"}' - shell: bash - - - name: Clean Stale Environments - env: - INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} - GITHUB_TOKEN: ${{ inputs.github-token }} - INPUT_SITE_NAME: ${{ inputs.site-name }} - run: | - source .github/actions/drainpipe/set-env/bash_aliases - echo "Cleaning stale Multidev environments" - drainpipe_exec "terminus auth:login --machine-token=\"$INPUT_TERMINUS_TOKEN\"" - PULLS=$(curl -f \ - https://api.github.com/repos/$GITHUB_REPOSITORY/pulls?state=open \ - -H 'Accept: application/vnd.github.v3+json' \ - -H "Authorization: token $GITHUB_TOKEN" \ - ) - # Truncate PR names to 11 chars to match Pantheon's multidev name limit. - PULL_NUMBERS=$(echo $PULLS | jq -r '.[] | "pr-" + (.number|tostring)' | cut -c1-11) - MULTIDEVS=$(drainpipe_exec "terminus multidev:list --format json $INPUT_SITE_NAME | jq --raw-output 'keys | .[]'") - for MULTIDEV in $MULTIDEVS; do - if echo "$PULL_NUMBERS" | grep -Fxq "$MULTIDEV"; then - echo "Found open PR for $MULTIDEV" - # if $MULTIDEV starts with "pr-" - elif [[ $MULTIDEV == pr-* ]]; then - echo "No PR for $MULTIDEV, shutting down..." - DEPLOYMENTS=$(curl -s -f -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments?environment=pantheon-$MULTIDEV | jq '.[] | .id') - for DEPLOYMENT_ID in $DEPLOYMENTS; do - echo "Marking GitHub Deployment $DEPLOYMENT_ID as inactive" - curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$DEPLOYMENT_ID/statuses -d "{\"state\":\"inactive\"}" - curl -H "Authorization: token $GITHUB_TOKEN" -X DELETE -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/environments/pantheon-$MULTIDEV - done - drainpipe_exec "terminus multidev:delete $INPUT_SITE_NAME.$MULTIDEV --delete-branch --yes" - else - echo "Dangling Multidev environment $MULTIDEV found, no action taken." - fi - done - shell: bash - - - name: Create or Update Multidev - env: - INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} - INPUT_SITE_NAME: ${{ inputs.site-name }} - INPUT_CLONE_FROM: ${{ inputs.clone-from }} - INPUT_RUN_INSTALLER: ${{ inputs.run-installer }} - INPUT_SKIP_WIPE_MULTIDEV: ${{ inputs.skip-wipe-multidev }} - run: | # zizmor: ignore[github-env] - source .github/actions/drainpipe/set-env/bash_aliases - drainpipe_exec "terminus auth:login --machine-token=\"$INPUT_TERMINUS_TOKEN\"" - REQUESTED_NAME="pr-$DRAINPIPE_PR_NUMBER" - JQ_COMMAND="'.[] | select(.id == \"$REQUESTED_NAME\") | .id'" - ENVIRONMENT_EXISTS=$(drainpipe_exec "terminus multidev:list --format json $INPUT_SITE_NAME | jq --raw-output $JQ_COMMAND") - if [ "$ENVIRONMENT_EXISTS" == "$REQUESTED_NAME" ]; then - if [ "$INPUT_SKIP_WIPE_MULTIDEV" != "true" ]; then - drainpipe_exec "terminus env:wipe $INPUT_SITE_NAME.$REQUESTED_NAME --yes" - fi - MULTIDEV_NAME="$REQUESTED_NAME" - else - if [ "$INPUT_SKIP_WIPE_MULTIDEV" != "true" ]; then - drainpipe_exec "terminus multidev:create $INPUT_SITE_NAME.$INPUT_CLONE_FROM $REQUESTED_NAME --no-db --no-files --yes" - else - drainpipe_exec "terminus multidev:create $INPUT_SITE_NAME.$INPUT_CLONE_FROM $REQUESTED_NAME --yes" - fi - # Query Pantheon for the actual environment name, which may have been - # truncated to 11 characters by the platform. - MULTIDEV_NAME=$(drainpipe_exec "terminus multidev:list --format json $INPUT_SITE_NAME | jq --raw-output 'keys | .[] | select(startswith(\"${REQUESTED_NAME:0:11}\"))'") - echo "::notice::Requested multidev name: $REQUESTED_NAME — Pantheon created: $MULTIDEV_NAME" - fi - echo "MULTIDEV_NAME=$MULTIDEV_NAME" >> $GITHUB_ENV - if [ "$INPUT_RUN_INSTALLER" != "true" ] && [ "$INPUT_SKIP_WIPE_MULTIDEV" != "true" ]; then - drainpipe_exec "terminus env:clone-content $INPUT_SITE_NAME.$INPUT_CLONE_FROM $MULTIDEV_NAME --yes" - fi - shell: bash - - - name: Push to Pantheon - env: - INPUT_SITE_NAME: ${{ inputs.site-name }} - INPUT_COMMIT_MESSAGE: ${{ inputs.commit-message }} - run: | - source .github/actions/drainpipe/set-env/bash_aliases - SITE_ID=$(drainpipe_exec "terminus site:lookup $INPUT_SITE_NAME") - drainpipe_exec "terminus connection:set $INPUT_SITE_NAME.$MULTIDEV_NAME git --yes" - drainpipe_exec "./vendor/bin/task deploy:git directory=/tmp/release branch=$MULTIDEV_NAME remote=ssh://codeserver.dev.$SITE_ID@codeserver.dev.$SITE_ID.drush.in:2222/~/repository.git message=\"$INPUT_COMMIT_MESSAGE\" site=$INPUT_SITE_NAME.$MULTIDEV_NAME" - shell: bash - - - name: Deploy to Pantheon - env: - INPUT_TERMINUS_TIMEOUT: ${{ inputs.terminus-timeout-limit }} - INPUT_SITE_NAME: ${{ inputs.site-name }} - INPUT_RUN_INSTALLER: ${{ inputs.run-installer }} - INPUT_LOCK_USERNAME: ${{ inputs.lock-username }} - INPUT_LOCK_PASSWORD: ${{ inputs.lock-password }} - GITHUB_TOKEN: ${{ inputs.github-token }} - run: | - source .github/actions/drainpipe/set-env/bash_aliases - - echo "::notice::Waiting $INPUT_TERMINUS_TIMEOUT seconds for Pantheon to sync..." - drainpipe_exec "terminus workflow:wait -vv --max $INPUT_TERMINUS_TIMEOUT -- $INPUT_SITE_NAME.$MULTIDEV_NAME" - - drainpipe_exec "terminus aliases --only $INPUT_SITE_NAME --yes" - if [ "$INPUT_RUN_INSTALLER" == "true" ]; then - drainpipe_exec "./vendor/bin/drush @$INPUT_SITE_NAME.$MULTIDEV_NAME --yes site:install --existing-config" - elif drainpipe_exec "./vendor/bin/task -l | grep '* update: '"; then - drainpipe_exec "./vendor/bin/task update site=@$INPUT_SITE_NAME.$MULTIDEV_NAME" - else - drainpipe_exec "./vendor/bin/task drupal:update site=@$INPUT_SITE_NAME.$MULTIDEV_NAME" - fi - ENVIRONMENT_URL="https://$MULTIDEV_NAME-$INPUT_SITE_NAME.pantheonsite.io" - # Lock Environment. - if [ "$INPUT_LOCK_USERNAME" != "" ] && [ "$INPUT_LOCK_PASSWORD" != "" ]; then - drainpipe_exec "terminus lock:enable $INPUT_SITE_NAME.$MULTIDEV_NAME $INPUT_LOCK_USERNAME $INPUT_LOCK_PASSWORD" - ENVIRONMENT_URL="https://$INPUT_LOCK_USERNAME:$INPUT_LOCK_PASSWORD@$MULTIDEV_NAME-$INPUT_SITE_NAME.pantheonsite.io" - fi - curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d "{\"state\":\"success\", \"environment_url\": \"$ENVIRONMENT_URL\"}" - shell: bash - - - name: Set Deployment Failure Status - env: - GITHUB_TOKEN: ${{ inputs.github-token }} - run: | - curl -f -H "Authorization: token $GITHUB_TOKEN" -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/deployments/$GITHUB_DEPLOYMENT_ID/statuses -d "{\"state\":\"failure\"}" - if: ${{ failure() }} - shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml b/scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml deleted file mode 100644 index 15dfa8c..0000000 --- a/scaffold/.github/actions/drainpipe/pantheon/setup-terminus/action.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: 'Prepare Pantheon Environment' -description: 'Sets up Terminus and authorises with Pantheon' -inputs: - terminus-token: - description: "Pantheon Terminus Token" - required: true - terminus-plugins: - description: "Terminus plugins" - required: false -runs: - using: "composite" - steps: - - env: - INPUT_TERMINUS_TOKEN: ${{ inputs.terminus-token }} - INPUT_TERMINUS_PLUGINS: ${{ inputs.terminus-plugins }} - run: | - echo -e "Host *.drush.in\n StrictHostKeyChecking no\n HostkeyAlgorithms +ssh-rsa\n PubkeyAcceptedAlgorithms +ssh-rsa" >> ~/.ssh/config - mkdir ~/terminus - curl -L https://github.com/pantheon-systems/terminus/releases/download/4.1.1/terminus.phar --output ~/terminus/terminus - chmod +x ~/terminus/terminus - ln -s ~/terminus/terminus /usr/local/bin/terminus - echo "$INPUT_TERMINUS_PLUGINS" | while read -d, plugin || [[ -n $plugin ]]; do terminus self:plugin:install $plugin; done - terminus auth:login --machine-token="$INPUT_TERMINUS_TOKEN" - shell: bash diff --git a/scaffold/.github/actions/drainpipe/pantheon/update/action.yml b/scaffold/.github/actions/drainpipe/pantheon/update/action.yml deleted file mode 100644 index 2b294a7..0000000 --- a/scaffold/.github/actions/drainpipe/pantheon/update/action.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: "Update or Install Pantheon Site" -description: "Runs the Drupal updater or the site installer in a Pantheon environment" -inputs: - site-name: - description: "Pantheon site machine name" - required: true - run-installer: - description: "Whether or not to run the Drupal site installer. Defaults to false." - required: false - environment: - description: "The environment to run the updates or install in e.g. 'test'" - required: true -runs: - using: "composite" - steps: - - name: Update site on Pantheon - env: - INPUT_SITE_NAME: ${{ inputs.site-name }} - INPUT_ENVIRONMENT: ${{ inputs.environment }} - INPUT_RUN_INSTALLER: ${{ inputs.run-installer }} - run: | - # Wait for Pantheon to sync. - source .github/actions/drainpipe/set-env/bash_aliases - drainpipe_exec "terminus workflow:wait $INPUT_SITE_NAME.$INPUT_ENVIRONMENT" - drainpipe_exec "terminus aliases --only $INPUT_SITE_NAME --yes" - if [ "$INPUT_RUN_INSTALLER" == "true" ]; then - drainpipe_exec "./vendor/bin/drush @$INPUT_SITE_NAME.$INPUT_ENVIRONMENT --yes site:install --existing-config" - elif drainpipe_exec "./vendor/bin/task -l | grep '* update: '"; then - drainpipe_exec "./vendor/bin/task update site=@$INPUT_SITE_NAME.$INPUT_ENVIRONMENT" - else - drainpipe_exec "./vendor/bin/task drupal:update site=@$INPUT_SITE_NAME.$INPUT_ENVIRONMENT" - fi - shell: bash diff --git a/scaffold/.github/actions/drainpipe/set-env/action.yml b/scaffold/.github/actions/drainpipe/set-env/action.yml deleted file mode 100644 index 05249cb..0000000 --- a/scaffold/.github/actions/drainpipe/set-env/action.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: 'Set Env' -description: 'Creates some useful environment variables' -runs: - using: "composite" - steps: - - run: | # zizmor: ignore[github-env] - echo "Setting Drainpipe environment variables:" - echo "GITHUB_EVENT_NAME: $GITHUB_EVENT_NAME" - echo "GITHUB_REF: $GITHUB_REF" - echo "GITHUB_REF_NAME: $GITHUB_REF_NAME" - - if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && "$GITHUB_REF" == refs/heads/* ]]; then - # Get PR number for the current branch using gh - DRAINPIPE_PR_NUMBER=$(gh pr list --state open --head "$GITHUB_REF_NAME" --json number --jq '.[0].number') - if [ -n "$DRAINPIPE_PR_NUMBER" ]; then - DRAINPIPE_SHA=$(gh pr view "$DRAINPIPE_PR_NUMBER" --json headRefOid --jq '.headRefOid') - else - # Fallback to else logic if no PR found - DRAINPIPE_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') - DRAINPIPE_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha) - fi - else - # Extract PR number from GITHUB_REF (for PR events) - DRAINPIPE_PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }') - DRAINPIPE_SHA=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.head.sha) - fi - - # Sanitize: PR number must be numeric, SHA must be hex characters - DRAINPIPE_PR_NUMBER=$(echo "$DRAINPIPE_PR_NUMBER" | tr -cd '0-9') - DRAINPIPE_SHA=$(echo "$DRAINPIPE_SHA" | tr -cd '0-9a-f') - - echo "DRAINPIPE_PR_NUMBER=$DRAINPIPE_PR_NUMBER" >> $GITHUB_ENV - - if [ -z "$DRAINPIPE_SHA" ] || [ "$DRAINPIPE_SHA" = "null" ]; then - DRAINPIPE_SHA=$DRAINPIPE_PR_NUMBER - fi - echo "DRAINPIPE_SHA=$DRAINPIPE_SHA" >> $GITHUB_ENV - - echo "The variables have been set:" - echo "DRAINPIPE_PR_NUMBER: $DRAINPIPE_PR_NUMBER" - echo "DRAINPIPE_SHA: $DRAINPIPE_SHA" - - shell: bash - env: - GH_TOKEN: ${{ github.token }} - - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - path: drainpipe - persist-credentials: false - - - run: | # zizmor: ignore[github-env] - if [[ -f .nvmrc ]]; then - NODE_FILE=.nvmrc - else - NODE_FILE=drainpipe/.nvmrc - fi - # Sanitize: strip whitespace then keep only numeric characters - NODE_MAJOR=$(tr -d '[:space:]' < "$NODE_FILE" | tr -cd '0-9') - echo "NODE_MAJOR=${NODE_MAJOR}" >> "$GITHUB_ENV" - - shell: bash diff --git a/scaffold/.github/actions/drainpipe/set-env/bash_aliases b/scaffold/.github/actions/drainpipe/set-env/bash_aliases deleted file mode 100644 index 58fca27..0000000 --- a/scaffold/.github/actions/drainpipe/set-env/bash_aliases +++ /dev/null @@ -1,7 +0,0 @@ -drainpipe_exec() { - if [ "$DRAINPIPE_DDEV" == "true" ]; then - ddev exec "$@" - else - eval "$@" - fi -} diff --git a/scaffold/.github/actions/drainpipe/setup-git/action.yml b/scaffold/.github/actions/drainpipe/setup-git/action.yml deleted file mode 100644 index c8c6922..0000000 --- a/scaffold/.github/actions/drainpipe/setup-git/action.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: 'Configure git' -description: 'Configures git username and e-mail address' -inputs: - git-email: - description: "Git e-mail address" - required: true - git-name: - description: "Git name" - required: true -runs: - using: "composite" - steps: - - run: | - git config --global user.email "$INPUT_GIT_EMAIL" - git config --global user.name "$INPUT_GIT_NAME" - shell: bash - env: - INPUT_GIT_EMAIL: ${{ inputs.git-email }} - INPUT_GIT_NAME: ${{ inputs.git-name }} diff --git a/scaffold/.github/actions/drainpipe/setup-ssh/action.yml b/scaffold/.github/actions/drainpipe/setup-ssh/action.yml deleted file mode 100644 index c112937..0000000 --- a/scaffold/.github/actions/drainpipe/setup-ssh/action.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: 'Configure ssh' -description: 'Configures SSH' -inputs: - ssh-private-key: - description: "SSH Private Key" - required: true - ssh-known-hosts: - description: "SSH Known Hosts" - required: false -runs: - using: "composite" - steps: - - run: | - sudo apt-get update - sudo apt-get install -y openssh-client - eval $(ssh-agent -s) - echo "$INPUT_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - - mkdir -p ~/.ssh - chmod 700 ~/.ssh - touch ~/.ssh/config - chmod 600 ~/.ssh/config - if [ "$INPUT_SSH_KNOWN_HOSTS" != "" ]; then - echo "$INPUT_SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts - chmod 644 ~/.ssh/known_hosts - fi - shell: bash - env: - INPUT_SSH_PRIVATE_KEY: ${{ inputs.ssh-private-key }} - INPUT_SSH_KNOWN_HOSTS: ${{ inputs.ssh-known-hosts }} diff --git a/scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml b/scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml deleted file mode 100644 index ffaf7d0..0000000 --- a/scaffold/.github/actions/drainpipe/validate-terminus-timeout/action.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: 'Validate TERMINUS_TIMEOUT_LIMIT' -description: 'Validates and sets the TERMINUS_TIMEOUT_LIMIT environment variable' -inputs: - terminus_timeout_limit: - description: 'Timeout in seconds for Terminus' - required: false -runs: - using: "composite" - steps: - - name: Validate TERMINUS_TIMEOUT_LIMIT - shell: bash - env: - INPUT_TIMEOUT_LIMIT: ${{ inputs.terminus_timeout_limit || '600' }} - run: | # zizmor: ignore[github-env] - TIMEOUT_LIMIT="$INPUT_TIMEOUT_LIMIT" - if ! [[ "$TIMEOUT_LIMIT" =~ ^[0-9]+$ ]]; then - echo "::error::TERMINUS_TIMEOUT_LIMIT must be a number. It represents the number of seconds that terminus will wait until timeout. Current value: $TIMEOUT_LIMIT" - exit 1 - fi - echo "TERMINUS_TIMEOUT_LIMIT=$TIMEOUT_LIMIT" >> "$GITHUB_ENV" diff --git a/scaffold/.github/workflows/deploymentBrowserStackTests.yml b/scaffold/.github/workflows/deploymentBrowserStackTests.yml index 5359497..2826aa1 100644 --- a/scaffold/.github/workflows/deploymentBrowserStackTests.yml +++ b/scaffold/.github/workflows/deploymentBrowserStackTests.yml @@ -18,22 +18,56 @@ jobs: uses: ./.github/actions/code-testing/detect-php-version Decide-If-Tests-Should-Run: runs-on: ubuntu-latest - if: ${{ github.event.deployment_status.state == 'success' }} + if: github.event.deployment_status.state == 'success' outputs: should-run: ${{ steps.decide.outputs.should-run }} - multidev-name: ${{ steps.decide.outputs.multidev-name }} + multidev-name: ${{ steps.multidev.outputs.name }} steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Set multidev name + id: multidev + run: echo "name=${{ github.event.deployment_status.environment }}" | sed 's/pantheon-//' >> $GITHUB_OUTPUT - name: Decide whether to run BrowserStack tests id: decide - uses: ./.github/actions/code-testing/github/decide-test-run - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - primary-branch: ${{ vars.BROWSERSTACK_PRIMARY_BRANCH || 'main' }} + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + MULTIDEV_NAME: ${{ steps.multidev.outputs.name }} + BROWSERSTACK_TESTS_ENABLED: ${{ vars.BROWSERSTACK_TESTS_ENABLED }} + BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }} + BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} + PR_LABEL: browserstack + run: | + if [[ "$BROWSERSTACK_TESTS_ENABLED" != "true" ]]; then + echo "::notice::BrowserStack tests are disabled (BROWSERSTACK_TESTS_ENABLED is not 'true')." + echo "should-run=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + if [[ -z "$BROWSERSTACK_USERNAME" || -z "$BROWSERSTACK_ACCESS_KEY" ]]; then + echo "::warning::BrowserStack credentials are not set." + echo "should-run=false" >> "$GITHUB_OUTPUT" + exit 0 + fi + + if [[ "$MULTIDEV_NAME" =~ ^pr-([0-9]+)$ ]]; then + PR_NUMBER="${BASH_REMATCH[1]}" + LABELS=$(gh pr view "$PR_NUMBER" --json labels --jq '.labels[].name') + if echo "$LABELS" | grep -qx "$PR_LABEL"; then + echo "::notice::PR #$PR_NUMBER has the '$PR_LABEL' label, running BrowserStack tests." + echo "should-run=true" >> "$GITHUB_OUTPUT" + else + echo "::notice::PR #$PR_NUMBER is missing the '$PR_LABEL' label, skipping BrowserStack tests." + echo "should-run=false" >> "$GITHUB_OUTPUT" + fi + else + echo "::notice::$MULTIDEV_NAME is not a PR multidev, running BrowserStack tests." + echo "should-run=true" >> "$GITHUB_OUTPUT" + fi Set-Up-Tests: runs-on: ubuntu-latest - needs: Decide-If-Tests-Should-Run + needs: [detect-php-version, Decide-If-Tests-Should-Run] if: ${{ needs.Decide-If-Tests-Should-Run.outputs.should-run == 'true' }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -48,15 +82,12 @@ jobs: with: pantheon-machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} terminus-version: 4.3.1 - - name: Set multidev name - id: multidev - run: echo "name=${{ github.event.deployment_status.environment }}" | sed 's/pantheon-//' >> $GITHUB_OUTPUT - name: Wait for review app to respond uses: ./.github/actions/code-testing/terminus/wait-for-build with: site-name: ${{ vars.PANTHEON_SITE_NAME }} - multidev-name: ${{ steps.multidev.outputs.name }} + multidev-name: ${{ needs.Decide-If-Tests-Should-Run.outputs.multidev-name }} # Browserstack test steps go here - name: Checkout actions diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml index 23a0bd3..7251351 100644 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ b/scaffold/.github/workflows/deploymentPlaywrightTests.yml @@ -4,18 +4,6 @@ on: deployment_status: {} jobs: - detect-php-version: - name: Detect PHP Version - runs-on: ubuntu-latest - if: github.event.deployment_status.state == 'success' - outputs: - php-version: ${{ steps.php-version.outputs.php-version }} - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Read php_version from Pantheon config - id: php-version - uses: ./.github/actions/code-testing/detect-php-version Playwright-Tests: runs-on: ubuntu-latest if: github.event.deployment_status.state == 'success' @@ -25,7 +13,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ needs.detect-php-version.outputs.php-version }} + php-version: "8.4" - name: Install Terminus uses: pantheon-systems/terminus-github-actions@v1 @@ -44,7 +32,7 @@ jobs: # Playwright steps go here - name: Checkout actions - uses: actions/checkout@v6 + uses: actions/checkout@v4 - name: Run Playwright tests uses: ./.github/actions/code-testing/playwright/test From 63a1ab857b899ff43e3319d76ae1b179006dea60 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 6 Jul 2026 16:52:50 -0500 Subject: [PATCH 10/34] Fixes for drainpipe and deployment tests --- .../workflows/deploymentBrowserStackTests.yml | 5 +- .../workflows/deploymentPlaywrightTests.yml | 2 +- .../workflows/drainpipeBrowserStackTests.yml | 2 +- .../workflows/drainpipePlaywrightTests.yml | 187 +++--------------- 4 files changed, 37 insertions(+), 159 deletions(-) diff --git a/scaffold/.github/workflows/deploymentBrowserStackTests.yml b/scaffold/.github/workflows/deploymentBrowserStackTests.yml index 2826aa1..dc9ba36 100644 --- a/scaffold/.github/workflows/deploymentBrowserStackTests.yml +++ b/scaffold/.github/workflows/deploymentBrowserStackTests.yml @@ -1,4 +1,4 @@ -name: "Run Browserstack tests on Pantheon" +name: "Run BrowserStack tests on Pantheon" on: deployment_status: { } @@ -65,7 +65,7 @@ jobs: echo "::notice::$MULTIDEV_NAME is not a PR multidev, running BrowserStack tests." echo "should-run=true" >> "$GITHUB_OUTPUT" fi - Set-Up-Tests: + Set-Up-and-Run-Tests: runs-on: ubuntu-latest needs: [detect-php-version, Decide-If-Tests-Should-Run] if: ${{ needs.Decide-If-Tests-Should-Run.outputs.should-run == 'true' }} @@ -94,6 +94,7 @@ jobs: uses: actions/checkout@v6 - name: Validate browserstack connection + id: validate-browserstack uses: ./.github/actions/code-testing/browserstack/validate with: enabled: ${{ vars.BROWSERSTACK_TESTS_ENABLED }} diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml index 7251351..6d3a450 100644 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ b/scaffold/.github/workflows/deploymentPlaywrightTests.yml @@ -1,4 +1,4 @@ -name: "Run playwright tests on Pantheon" +name: "Run Playwright tests on Pantheon" on: deployment_status: {} diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml index 6c45186..a00bf30 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml @@ -1,4 +1,4 @@ -name: "Run Browserstack tests on Pantheon" +name: "Run BrowserStack tests on Pantheon" on: workflow_run: diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 9006867..84cad61 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -1,176 +1,53 @@ -name: "Run Unit, Code Quality and Existing-Site Tests" +name: "Playwright Tests" on: - pull_request: - types: [opened, synchronize, reopened] - push: - branches: - - edge - - main + workflow_run: + workflows: + - "Pantheon Build edge" + - "Pantheon Build main" + - "Pantheon Review Apps" + types: + - completed concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +permissions: + contents: read + pull-requests: read + jobs: - detect-php-version: - name: Detect PHP Version + get-multidev-name: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} outputs: - php-version: ${{ steps.php-version.outputs.php-version }} - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Read php_version from Pantheon config - id: php-version - uses: ./.github/actions/code-testing/detect-php-version - - # These jobs run in parallel - they don't need the deployment. Just composer. - unit-tests: - name: Unit Tests - runs-on: ubuntu-latest - needs: detect-php-version - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ needs.detect-php-version.outputs.php-version }} - extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, json, mbstring, pdo - coverage: none - - # Install composer dependencies to ensure autoloader - # is up to date and vendor/bin/phpunit is available - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Run Unit Tests - run: | - mkdir -p test-results - ./vendor/bin/phpunit -c phpunit.xml --testsuite=unit --log-junit test-results/phpunit-unit.xml - - - name: Upload Test Results - uses: actions/upload-artifact@v6 - if: always() - with: - name: unit-test-results - path: test-results/unit/ - - code-quality: - name: Code Quality - runs-on: ubuntu-latest - needs: detect-php-version + multidev-name: ${{ steps.name.outputs.multidev-name }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Setup PHP - uses: shivammathur/setup-php@v2 + - name: Get multidev name + id: name + uses: ./.github/actions/code-testing/github/decide-test-run with: - php-version: ${{ needs.detect-php-version.outputs.php-version }} - extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, json, mbstring, pdo - coverage: none - - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Run PHPCS - run: ./vendor/bin/phpcs --report=checkstyle --report-file=phpcs-report.xml || true - - - name: Upload PHPCS Report - uses: actions/upload-artifact@v6 - if: always() - with: - name: phpcs-report - path: phpcs-report.xml - - # ExistingSite tests require a full Drupal environment with database - # This runs in parallel with deployment - uses synced DB, not multidev. - existing-site-tests: - name: ExistingSite Tests + github-token: ${{ secrets.GITHUB_TOKEN }} + primary-branch: ${{ vars.BROWSERSTACK_PRIMARY_BRANCH || 'main' }} + run-playwright-tests: runs-on: ubuntu-latest + needs: get-multidev-name steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 - with: - path: ${{ github.workspace }}/.ddev/.drainpipe-composer-cache - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install and Start DDEV - uses: ./.github/actions/drainpipe/ddev - with: - git-name: Drainpipe Bot - git-email: no-reply@example.com - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - ssh-known-hosts: ${{ secrets.SSH_KNOWN_HOSTS }} - - - name: Install Dependencies - run: ddev composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Configure Pantheon Credentials - run: | - # Add Pantheon credentials to DDEV web environment - ddev config --web-environment-add="PANTHEON_TOKEN=${{ secrets.TERMINUS_MACHINE_TOKEN }}" - ddev config --web-environment-add="PANTHEON_SITE_ID=${{ secrets.PANTHEON_SITE_NAME }}" - ddev config --web-environment-add="TERMINUS_MACHINE_TOKEN=${{ secrets.TERMINUS_MACHINE_TOKEN }}" - ddev restart - - - name: Sync Database from Pantheon - run: ddev task sync - - - name: Run Drupal Updates - run: ddev drush deploy - - - name: Enable Stage File Proxy - run: | - # Enable stage_file_proxy so tests can access images from remote site - ddev drush pm:enable stage_file_proxy -y - # Verify it's enabled - ddev drush pm:list --filter=stage_file_proxy --status=enabled - - - name: Reindex Solr - if: ${{ vars.TESTING_NEEDS_SEARCH_INDEXING == 'true' }} - run: | - # Reindex Solr so search tests have fresh data - ddev drush search-api:reset-tracker - ddev drush search-api:index - - - name: Install theme dependencies - run: ddev task assets:prod - - - name: Run ExistingSite Tests - run: ddev task test:existing-site - - - name: Upload ExistingSite Test Results - uses: actions/upload-artifact@v6 - if: always() - with: - name: existing-site-test-results - path: test-results/phpunit/ - - - name: Upload Browser Output on Failure - uses: actions/upload-artifact@v6 - if: failure() - with: - name: existing-site-browser-output - path: | - test-results/phpunit/ - web/sites/simpletest/browser_output/ - - # --- Playwright E2E Tests against DDEV environment --- - - name: Get DDEV URL - id: ddev-url + - name: Set target URL + shell: bash + id: set-url + env: + PANTHEON_SITE_NAME: ${{ vars.PANTHEON_SITE_NAME }} + MULTIDEV_NAME: ${{ needs.get-multidev-name.outputs.multidev-name }} run: | - DDEV_URL=$(ddev describe -j | jq -r '.raw.primary_url') - echo "url=${DDEV_URL}" >> $GITHUB_OUTPUT - echo "DDEV URL: ${DDEV_URL}" + echo "target_url=https://${MULTIDEV_NAME}-${PANTHEON_SITE_NAME}.pantheonsite.io" >> "$GITHUB_OUTPUT" - - name: Run Playwright tests in DDEV + - name: Run Playwright tests in Pantheon environment. uses: ./.github/actions/code-testing/playwright/test with: - environment-password: ${{ secrets.PANTHEON_REVIEW_USERNAME }} - environment-username: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + environment-password: '' + environment-username: '' target-url: ${{ steps.ddev-url.outputs.url }} test-script: 'test:ci-pantheon' \ No newline at end of file From 9000a9419a462b1ecd774e672c5b1b052d35f766 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Tue, 7 Jul 2026 12:58:37 -0500 Subject: [PATCH 11/34] T7RD-491 unify test naming and run-names --- .../code-testing/browserstack/test/action.yml | 13 +++---------- .../workflows/deploymentBrowserStackTests.yml | 2 +- scaffold/.github/workflows/deploymentCodeTests.yml | 2 ++ scaffold/.github/workflows/deploymentLockDiff.yml | 1 + .../.github/workflows/deploymentPlaywrightTests.yml | 1 + .../workflows/drainpipeBrowserStackTests.yml | 7 ++++--- scaffold/.github/workflows/drainpipeCodeTests.yml | 1 + scaffold/.github/workflows/drainpipeLockDiff.yml | 1 + .../workflows/drainpipePantheonBuildEdge.yml | 3 ++- .../workflows/drainpipePantheonBuildMain.yml | 3 ++- .../workflows/drainpipePantheonReviewApps.yml | 1 + .../.github/workflows/drainpipePlaywrightTests.yml | 13 +++++++------ scaffold/.github/workflows/testRenovate.yml | 9 +++++---- 13 files changed, 31 insertions(+), 26 deletions(-) diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index b2b1eaa..97f8445 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -26,14 +26,6 @@ runs: - name: Checkout actions uses: actions/checkout@v6 - - name: Verify site name is set - shell: bash - run: | - if [ -z "$PANTHEON_SITE_NAME" ]; then - echo "::error::PANTHEON_SITE_NAME is empty. Set it under Settings → Secrets and variables → Actions (either tab)." - exit 1 - fi - echo "Using PANTHEON_SITE_NAME=$PANTHEON_SITE_NAME" - name: Setup Node.js uses: actions/setup-node@v6 with: @@ -51,6 +43,7 @@ runs: - name: Run BrowserStack tests shell: bash run: | + echo "running tests on ${BASE_URL}" cd test/playwright mkdir -p test-results npm run test:browserstack @@ -58,6 +51,6 @@ runs: NODE_OPTIONS: --disable-warning=DEP0205 BASE_URL: ${{ inputs.target-url }} BASIC_AUTH_USER: ${{ inputs.pantheon-review-username }} - BASIC_AUTH_PASS: ${{ inputs.patheon-review-password }} - BROWSERSTACK_USERNAME: ${{ inputs.browserstack-user-name}} + BASIC_AUTH_PASS: ${{ inputs.pantheon-review-password }} + BROWSERSTACK_USERNAME: ${{ inputs.browserstack-username }} BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack-access-key }} diff --git a/scaffold/.github/workflows/deploymentBrowserStackTests.yml b/scaffold/.github/workflows/deploymentBrowserStackTests.yml index dc9ba36..30f589c 100644 --- a/scaffold/.github/workflows/deploymentBrowserStackTests.yml +++ b/scaffold/.github/workflows/deploymentBrowserStackTests.yml @@ -1,5 +1,5 @@ name: "Run BrowserStack tests on Pantheon" - +run-name: "${{ github.event.deployment_status.environment }} by @${{ github.actor }}" on: deployment_status: { } diff --git a/scaffold/.github/workflows/deploymentCodeTests.yml b/scaffold/.github/workflows/deploymentCodeTests.yml index f3acd2d..a0f99f0 100644 --- a/scaffold/.github/workflows/deploymentCodeTests.yml +++ b/scaffold/.github/workflows/deploymentCodeTests.yml @@ -1,4 +1,6 @@ name: "Run Unit, Code Quality and Existing-Site Tests" +run-name: "${{ github.event.deployment_status.environment }} by @${{ github.actor }}" + on: deployment_status: {} diff --git a/scaffold/.github/workflows/deploymentLockDiff.yml b/scaffold/.github/workflows/deploymentLockDiff.yml index 646c1e7..e6057c0 100644 --- a/scaffold/.github/workflows/deploymentLockDiff.yml +++ b/scaffold/.github/workflows/deploymentLockDiff.yml @@ -1,4 +1,5 @@ name: "Composer Lock Diff" +run-name: "${{ github.event.deployment_status.environment }} by @${{ github.actor }}" on: deployment_status: {} diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml index 6d3a450..427896f 100644 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ b/scaffold/.github/workflows/deploymentPlaywrightTests.yml @@ -1,4 +1,5 @@ name: "Run Playwright tests on Pantheon" +run-name: "${{ github.event.deployment_status.environment }} by @${{ github.actor }}" on: deployment_status: {} diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml index a00bf30..65e5618 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml @@ -1,10 +1,11 @@ name: "Run BrowserStack tests on Pantheon" +run-name: "${{ github.event.workflow_run.head_branch }} by @${{ github.event.workflow_run.actor.login }}" on: workflow_run: workflows: - - "Pantheon Build edge" - - "Pantheon Build main" + - "Pantheon Build Edge" + - "Pantheon Build Main" - "Pantheon Review Apps" types: - completed @@ -17,7 +18,7 @@ jobs: detect-php-version: name: Detect PHP Version runs-on: ubuntu-latest - if: github.event.deployment_status.state == 'success' + if: ${{ github.event.workflow_run.conclusion == 'success' }} outputs: php-version: ${{ steps.php-version.outputs.php-version }} steps: diff --git a/scaffold/.github/workflows/drainpipeCodeTests.yml b/scaffold/.github/workflows/drainpipeCodeTests.yml index 02774a8..0deef47 100644 --- a/scaffold/.github/workflows/drainpipeCodeTests.yml +++ b/scaffold/.github/workflows/drainpipeCodeTests.yml @@ -1,4 +1,5 @@ name: "Run Unit, Code Quality and Existing-Site Tests" +run-name: "${{ github.event_name == 'pull_request' && format('PR #{0} ({1})', github.event.pull_request.number, github.head_ref) || github.ref_name }} by @${{ github.actor }}" on: pull_request: diff --git a/scaffold/.github/workflows/drainpipeLockDiff.yml b/scaffold/.github/workflows/drainpipeLockDiff.yml index cdf118a..2099ea7 100644 --- a/scaffold/.github/workflows/drainpipeLockDiff.yml +++ b/scaffold/.github/workflows/drainpipeLockDiff.yml @@ -1,4 +1,5 @@ name: "Composer Lock Diff" +run-name: "PR #${{ github.event.pull_request.number }} (${{ github.head_ref }}) by @${{ github.actor }}" on: pull_request: diff --git a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml index 8b2ae31..fe6abb6 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml @@ -1,4 +1,5 @@ -name: "Pantheon Build edge" +name: "Pantheon Build Edge" +run-name: "${{ github.ref_name }} by @${{ github.actor }}" on: push: diff --git a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml index 0437b2c..ed37c88 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml @@ -1,4 +1,5 @@ -name: "Pantheon Build main" +name: "Pantheon Build Main" +run-name: "${{ github.ref_name }} by @${{ github.actor }}" on: push: diff --git a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml index 5dfa031..6ad9c39 100644 --- a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml +++ b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml @@ -1,4 +1,5 @@ name: "Pantheon Review Apps" +run-name: "PR #${{ github.event.pull_request.number }} (${{ github.head_ref }}) by @${{ github.actor }}" on: pull_request: diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 84cad61..4a26f43 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -1,10 +1,11 @@ -name: "Playwright Tests" +name: "Run Playwright tests on Pantheon" +run-name: "${{ github.event.workflow_run.head_branch }} by @${{ github.event.workflow_run.actor.login }}" on: workflow_run: workflows: - - "Pantheon Build edge" - - "Pantheon Build main" + - "Pantheon Build Edge" + - "Pantheon Build Main" - "Pantheon Review Apps" types: - completed @@ -47,7 +48,7 @@ jobs: - name: Run Playwright tests in Pantheon environment. uses: ./.github/actions/code-testing/playwright/test with: - environment-password: '' - environment-username: '' - target-url: ${{ steps.ddev-url.outputs.url }} + environment-password: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + environment-username: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + target-url: ${{ steps.set-url.outputs.target_url }} test-script: 'test:ci-pantheon' \ No newline at end of file diff --git a/scaffold/.github/workflows/testRenovate.yml b/scaffold/.github/workflows/testRenovate.yml index c9b519a..3e12086 100644 --- a/scaffold/.github/workflows/testRenovate.yml +++ b/scaffold/.github/workflows/testRenovate.yml @@ -1,8 +1,9 @@ -name: Test Renovate settings +name: "Test Renovate Settings" +run-name: "${{ github.ref_name }} by @${{ github.actor }}" + on: - push: - branches: - - main + pull_request: + types: [opened, synchronize, reopened, labeled] concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} From b35409c44107cbdd8f094b8246aeed6742f8e0eb Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Tue, 7 Jul 2026 13:23:28 -0500 Subject: [PATCH 12/34] T7RD-491 fix some bugs with browserstack action --- .../actions/code-testing/browserstack/test/action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index 97f8445..78e78ec 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -20,6 +20,10 @@ inputs: pantheon-review-password: description: "Password for basic auth to access Pantheon review apps. Should be set as a secret named PANTHEON_REVIEW_PASSWORD." required: true + browserstack-local: + description: "Whether BrowserStack should tunnel through BrowserStack Local. Pantheon review apps are publicly reachable, so this should stay 'false' in CI." + required: false + default: "false" runs: using: composite steps: @@ -54,3 +58,5 @@ runs: BASIC_AUTH_PASS: ${{ inputs.pantheon-review-password }} BROWSERSTACK_USERNAME: ${{ inputs.browserstack-username }} BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack-access-key }} + BROWSERSTACK_BUILD_NAME: ${{ inputs.target-url }} + BROWSERSTACK_LOCAL: ${{ inputs.browserstack-local }} From d425a2772ef400aeac110d21e83aea87ed0e5073 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Tue, 7 Jul 2026 13:42:47 -0500 Subject: [PATCH 13/34] T7RD-491 in workflows browserstack.local must be false --- .../actions/code-testing/browserstack/test/action.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index 78e78ec..5203326 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -20,10 +20,6 @@ inputs: pantheon-review-password: description: "Password for basic auth to access Pantheon review apps. Should be set as a secret named PANTHEON_REVIEW_PASSWORD." required: true - browserstack-local: - description: "Whether BrowserStack should tunnel through BrowserStack Local. Pantheon review apps are publicly reachable, so this should stay 'false' in CI." - required: false - default: "false" runs: using: composite steps: @@ -59,4 +55,4 @@ runs: BROWSERSTACK_USERNAME: ${{ inputs.browserstack-username }} BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack-access-key }} BROWSERSTACK_BUILD_NAME: ${{ inputs.target-url }} - BROWSERSTACK_LOCAL: ${{ inputs.browserstack-local }} + BROWSERSTACK_LOCAL: false From d9f226861c7f0d71abc0d22d4561fb9bdb253369 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Tue, 7 Jul 2026 13:48:36 -0500 Subject: [PATCH 14/34] T7RD-491 update drainpipePlaywrightTests.yml to checkout code --- scaffold/.github/workflows/drainpipePlaywrightTests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 4a26f43..f5c4941 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -36,6 +36,8 @@ jobs: runs-on: ubuntu-latest needs: get-multidev-name steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - name: Set target URL shell: bash id: set-url From a63e24a155a977ecc5fa251806d4410a430e7c6d Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Wed, 8 Jul 2026 13:07:55 -0500 Subject: [PATCH 15/34] T7RD-491 update readme and naming simplicity --- README.md | 104 +++++++++++++++--- .../workflows/deploymentPlaywrightTests.yml | 2 +- .../workflows/drainpipeBrowserStackTests.yml | 2 +- .../workflows/drainpipePlaywrightTests.yml | 2 +- 4 files changed, 90 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 32b846f..b8f9d74 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,28 @@ A Composer plugin that scaffolds TEN7's GitHub Actions and workflow files into Drupal projects. -Requires [lullabot/drainpipe](https://github.com/lullabot/drainpipe) as a -dependency — even on projects not using drainpipe workflows, as it provides the -build tooling the actions depend on. +Requires [lullabot/drainpipe](https://github.com/lullabot/drainpipe) as a +dependency, but drainpipe actions are only installed on sites that use +drainpipe. + +# Requirements + +This tool is predicated on the assumption that you want to run code tests +with your GitHub deployments to Pantheon. + +Most important is a [Playwright](https://playwright.dev/docs/intro) test setup +in a directory called `test/playwright`. + +If you have a BrowserStack account, you can install the +[browserstack-node-sdk](https://www.browserstack.com/docs/automate/playwright/getting-started/nodejs/integrate-your-tests?fw-lang=nodejs) +which will install a browserstack.yml file in the `test/playwright` directory. + +For the `CodeTests`, it is also important to have a phpunit configuration on +your site. In most Drupal setups, this will be at least partly set up on +install. If there are no tests, Unit and ExistingSite steps will be skipped. +As is mentioned below, This is not necessary as the tests can be run locally; +however, if your site has php-based tests you want run, these can be a +useful check on every run. ## Installation @@ -56,14 +75,23 @@ On PRs some labels can be used for triggering actions these include * `skip-wipe` which prevents a build from wiping the files and db and starting from scratch on every push -* `build multidev` which is required to actually run drainpipePantheonReviewApps -* `test renovate` is useful if you want to reduce testRenovate's time to run - even more. See below. +* `build multidev` is required to build a Pantheon review app for the PR at + all. It only controls whether the multidev environment gets built - whether + tests actually run against it once built is a separate check (see + `browserstack` below). +* `test renovate` is required for testRenovate to run at all. The workflow's + job is gated on this label, so without it nothing runs - it's not just a + time-saving option. See below. * `browserstack` By default browserstack tests are never run on PRs even if `BROWSERSTACK_TESTS_ENABLED`=true. Add this label if a PR should also run browserstack tests. This is useful if a PR includes significant theme changes. Less "expensive" standard CodeTests or Playwright tests. So use this with care. + ⚠️ This label currently gates Playwright tests on PR review apps too, not + just BrowserStack. Both workflows call the same `decide-test-run` action, + which defaults its PR-label check to `browserstack`. Without the label, + neither suite runs against the review app. This gate does not apply to the + edge/main push path, where both suites always run. ### Drainpipe Example @@ -72,7 +100,7 @@ for the specific tasks. There is no need to call drainpipe separately unless you have specific additional requirements for those. Just be sure not to overlap functionality. -⚠️Note that the PlaywrightTests and BrowserstackTests must be merged to the +⚠️ Note that the PlaywrightTests and BrowserstackTests must be merged to the root branch of the repo before they can be run on any PR. This is a fundamental requirement of Github. This is generally acceptable especially for Browserstack since it should be used sparingly. @@ -95,23 +123,65 @@ for Browserstack since it should be used sparingly. } ``` +#### Anatomy of the Workflows + +##### Playwright and Browserstack Tests + +Playwright and BrowserStack tests depend on at least one of the "Pantheon*" +workflows completing, and run against a Pantheon environment. There are two +independent paths: + +- **Push to edge/main**: the matching `Pantheon Build` workflow deploys, then + tests run automatically against that environment. A push to `main` tests + against the `dev` multidev, not a `main` one - that's Pantheon's own + environment naming, not something this plugin adds. +- **Pull requests**: `Pantheon Review Apps` only builds a multidev if the PR + has the `build multidev` label, and tests then only run against it if the + PR also has the `browserstack` label (see PR Labels above). + +⚠️ The push path matches on the literal workflow `name:` string ("Pantheon +Build " plus the configured primary branch). If you rename +`drainpipePantheonBuildEdge.yml` or `drainpipePantheonBuildMain.yml`, update +`decide-test-run`'s `build-workflow-prefix` input to match, or tests will +silently stop running after every deploy. + +These are set up to use two different scripts in your +tests/playwright/package.json file described below. PlaywrightTests is +expecting a script called `test:ci-playwright` and the BrowserStackTests +expect a script called `test:browserstack` (see below). + +CodeTests and LockDiff can be run independently of a build. + +##### CodeTests + +CodeTests is not necessary as all of what it does can be run locally. Adding +it to your repo, can be a fairly inexpensive way to verify that code is +working at a bare level. It runs the full suite of tests a site may have +from Unit to ExistingSite tests, a code check, and any playwright tests +against a DDEV environment on GitHub. This workflow expects a playwright +test called `test:ci-ddev` (see below). + #### testRenovate -This is required by drainpipe, but may not actually get installed. If you -want to use this and you have instructions in a renovate.json and have it -configured on Github, you need to add the following to `extra.code_testing`. +This is installed by drainpipe, but may not actually get installed. If you +want to use this, and you have instructions in a renovate.json and have it +configured on GitHub, you need to add the following to `extra.code_testing`. + +testRenovate runs on pull requests (opened, synchronized, reopened, or +labeled), and its job only runs if the PR also carries the `test renovate` +label - without it, the job is skipped entirely. ```json { "test": [ - "Renovate", + "Renovate" ] } ``` ### Deployment Example -For sites that use a deployment solution such as pantheon's github builder, +For sites that use a deployment solution such as pantheon's GitHub builder, the options are simpler. ```json @@ -140,11 +210,11 @@ example above would scaffold: - `testRenovate.yml` It's entirely possible to skip the extras:code_testing" section and just copy -the desired files from ./vendor/ten7/scaffold/.github/workflows, but this +the desired files from `./vendor/ten7/scaffold/.github/workflows`, but this should not be necessary. If there need to be new changes, they should be made here with broadly abstracted steps and making use of updates users can make in their repos (secrets/variables/labels) or with specifically required -scripts test/playwright/package.json +scripts `test/playwright/package.json` ## Workflow contexts @@ -156,13 +226,13 @@ scripts test/playwright/package.json ## Available workflows -See the directory scaffold/.github/workflows +See the directory `scaffold/.github/workflows`. ## Actions All actions under `.github/actions/code-testing/` are scaffolded unconditionally. They have no effect unless referenced by a workflow. Each -action has a description defining what it does +action has a description defining what it does. This plugin also installs certain lullabot/drainpipe actions as needed. @@ -194,5 +264,5 @@ These tests should define what should be run by npm. An example might be: ``` -The test:browserstack should be configured differently based on the rules for +The `test:browserstack` should be configured differently based on the rules for developing with BrowserStack that are beyond the scope of this repo. \ No newline at end of file diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml index 427896f..409620c 100644 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ b/scaffold/.github/workflows/deploymentPlaywrightTests.yml @@ -1,4 +1,4 @@ -name: "Run Playwright tests on Pantheon" +name: "Run Playwright Tests on Pantheon" run-name: "${{ github.event.deployment_status.environment }} by @${{ github.actor }}" on: diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml index 65e5618..e78a4c6 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml @@ -1,4 +1,4 @@ -name: "Run BrowserStack tests on Pantheon" +name: "Run BrowserStack Tests on Pantheon" run-name: "${{ github.event.workflow_run.head_branch }} by @${{ github.event.workflow_run.actor.login }}" on: diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index f5c4941..2e7411a 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -1,4 +1,4 @@ -name: "Run Playwright tests on Pantheon" +name: "Run Playwright Tests on Pantheon" run-name: "${{ github.event.workflow_run.head_branch }} by @${{ github.event.workflow_run.actor.login }}" on: From 286585329c6944499ce99bb2355c3f19fe0ebd09 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Wed, 8 Jul 2026 13:20:42 -0500 Subject: [PATCH 16/34] T7RD-491 refine READEME.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index b8f9d74..350df43 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,20 @@ useful check on every run. ## Installation +This repo is not listed at packagist so you need to add the following to +your "repositories[]" in composer.json: + +```json +{ + "type": "vcs", + "url": "https://github.com/ten7/github-code-testing" +} +``` + +Then you can run the following, though nothing will change in your codebase +until you define "github" in "extras" explained below. + + ```bash composer require "ten7/github-code-testing" ``` From a27fde58c45d60d297a07358ff14c19177be5952 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Thu, 9 Jul 2026 11:14:01 -0500 Subject: [PATCH 17/34] T7RD-491 bug fixes for indexing sites. --- .../code-testing/drupal/index-search/action.yml | 12 ++++++------ .../.github/workflows/drainpipePantheonBuildEdge.yml | 2 +- .../.github/workflows/drainpipePantheonBuildMain.yml | 2 +- .../workflows/drainpipePantheonReviewApps.yml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scaffold/.github/actions/code-testing/drupal/index-search/action.yml b/scaffold/.github/actions/code-testing/drupal/index-search/action.yml index ac91526..e289788 100644 --- a/scaffold/.github/actions/code-testing/drupal/index-search/action.yml +++ b/scaffold/.github/actions/code-testing/drupal/index-search/action.yml @@ -4,8 +4,8 @@ inputs: pantheon-site-name: description: 'The site name, such as bps-district' required: true - pr-number: - description: "The Pull Request number" + multidev-name: + description: "The name of the environment: dev, edge, pr-[x]" required: true machine-token: description: "The machine token needed to authorize terminus" @@ -18,10 +18,10 @@ runs: id: search-indexing env: PANTHEON_SITE_NAME: ${{ inputs.pantheon-site-name }} - PR_NUMBER: ${{ inputs.pr-number }} + MULTIDEV_NAME: ${{ inputs.multidev-name }} MACHINE_TOKEN: ${{ inputs.machine-token }} shell: bash run: | - drainpipe_exec "terminus auth:login --machine-token="${{env.MACHINE_TOKEN}}" && \ - terminus remote:drush ${{env.PANTHEON_SITE_NAME}}.pr-${{ env.PR_NUMBER }} -- search-api:reset-tracker && \ - terminus remote:drush ${{env.PANTHEON_SITE_NAME}}.pr-${{ github.event.pull_request.number }} -- search-api:index" + terminus auth:login --machine-token="${{ env.MACHINE_TOKEN }}" + terminus remote:drush ${{ env.PANTHEON_SITE_NAME }}.${{ env.MULTIDEV_NAME }} -- search-api:reset-tracker + terminus remote:drush ${{ env.PANTHEON_SITE_NAME }}.${{ env.MULTIDEV_NAME }} -- search-api:index diff --git a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml index fe6abb6..4e66e8a 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml @@ -81,4 +81,4 @@ jobs: with: machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} pantheon-site-name: ${{ secrets.PANTHEON_SITE_NAME }} - pr-number: edge \ No newline at end of file + multidev-name: edge \ No newline at end of file diff --git a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml index ed37c88..efcd6f0 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml @@ -76,4 +76,4 @@ jobs: with: machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} pantheon-site-name: ${{ secrets.PANTHEON_SITE_NAME }} - pr-number: dev \ No newline at end of file + multidev-name: dev \ No newline at end of file diff --git a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml index 6ad9c39..6c7523f 100644 --- a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml +++ b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml @@ -90,7 +90,7 @@ jobs: with: machine-token: ${{ secrets.TERMINUS_MACHINE_TOKEN }} pantheon-site-name: ${{ secrets.PANTHEON_SITE_NAME }} - pr-number: pr-${{ github.event.pull_request.number }} + multidev-name: pr-${{ github.event.pull_request.number }} - name: Add Multidev URL to PR uses: ./.github/actions/code-testing/github/add-pr-url From 69c5877848be0a9b4189f1373e77eb76c254b4bf Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Thu, 9 Jul 2026 12:31:45 -0500 Subject: [PATCH 18/34] T7RD-491 update index-search/action.yml --- .../actions/code-testing/drupal/index-search/action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scaffold/.github/actions/code-testing/drupal/index-search/action.yml b/scaffold/.github/actions/code-testing/drupal/index-search/action.yml index e289788..6016249 100644 --- a/scaffold/.github/actions/code-testing/drupal/index-search/action.yml +++ b/scaffold/.github/actions/code-testing/drupal/index-search/action.yml @@ -22,6 +22,7 @@ runs: MACHINE_TOKEN: ${{ inputs.machine-token }} shell: bash run: | + source .github/actions/drainpipe/set-env/bash_aliases terminus auth:login --machine-token="${{ env.MACHINE_TOKEN }}" - terminus remote:drush ${{ env.PANTHEON_SITE_NAME }}.${{ env.MULTIDEV_NAME }} -- search-api:reset-tracker - terminus remote:drush ${{ env.PANTHEON_SITE_NAME }}.${{ env.MULTIDEV_NAME }} -- search-api:index + drainpipe_exec "terminus remote:drush ${{ env.PANTHEON_SITE_NAME }}.${{ env.MULTIDEV_NAME }} -- search-api:reset-tracker" + drainpipe_exec "terminus remote:drush ${{ env.PANTHEON_SITE_NAME }}.${{ env.MULTIDEV_NAME }} -- search-api:index" From cdb659d1da09a409a4aef8c8adef749999a29ee7 Mon Sep 17 00:00:00 2001 From: Chris Dart <571478+generalludd@users.noreply.github.com> Date: Fri, 10 Jul 2026 09:25:43 -0500 Subject: [PATCH 19/34] Update README.md Update descripion/purpose for the module. --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 350df43..dd349a5 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,13 @@ -# ten7/github-code-testing +# GitHub Code Testing A Composer plugin that scaffolds TEN7's GitHub Actions and workflow files into Drupal projects. -Requires [lullabot/drainpipe](https://github.com/lullabot/drainpipe) as a + +This is a transitional project, allowing TEN7 to build testing infrastructure for +existing lullabot/drainpipe projects and preparing for the switch to Pantheon-based +deployments on GitHub. + +This will install [lullabot/drainpipe](https://github.com/lullabot/drainpipe) as a dependency, but drainpipe actions are only installed on sites that use drainpipe. @@ -40,9 +45,12 @@ your "repositories[]" in composer.json: Then you can run the following, though nothing will change in your codebase until you define "github" in "extras" explained below. +Note: It is best to use the latest version when requiring this. Check the tags +at https://github.com/ten7/github-code-testing. + ```bash -composer require "ten7/github-code-testing" +composer require "ten7/github-code-testing^1.0.7-beta" ``` ⚠️If you have lullabot/drainpipe and/or lullabot/drainpipe-dev you will need @@ -279,4 +287,4 @@ These tests should define what should be run by npm. An example might be: ``` The `test:browserstack` should be configured differently based on the rules for -developing with BrowserStack that are beyond the scope of this repo. \ No newline at end of file +developing with BrowserStack that are beyond the scope of this repo. From 08717115f1cdc88f866c3a02134f303b5f022b73 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Fri, 10 Jul 2026 11:32:02 -0500 Subject: [PATCH 20/34] T7RD-491 typo fix in deploymentCodeTests.yml --- scaffold/.github/workflows/deploymentCodeTests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scaffold/.github/workflows/deploymentCodeTests.yml b/scaffold/.github/workflows/deploymentCodeTests.yml index a0f99f0..ac1cfdd 100644 --- a/scaffold/.github/workflows/deploymentCodeTests.yml +++ b/scaffold/.github/workflows/deploymentCodeTests.yml @@ -170,4 +170,4 @@ jobs: environment-password: '' environment-username: '' target-url: ${{ steps.ddev-url.outputs.url }} - test-script: 'ci-ddev' + test-script: 'test:ci-ddev' From c2f4c087c84c9aa939695b8ad5a5fc430547dd68 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Fri, 10 Jul 2026 12:28:57 -0500 Subject: [PATCH 21/34] T7RD-491 remove unneeded php-check in drainpipeBrowserStackTests.yml --- .../.github/workflows/drainpipeBrowserStackTests.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml index e78a4c6..4db6fb6 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml @@ -15,18 +15,6 @@ permissions: pull-requests: read jobs: - detect-php-version: - name: Detect PHP Version - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - outputs: - php-version: ${{ steps.php-version.outputs.php-version }} - steps: - - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Read php_version from Pantheon config - id: php-version - uses: ./.github/actions/code-testing/detect-php-version Decide-If-Tests-Should-Run: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} From 8c3ed72102bd249d03613c6589eefd9d2d30b450 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Fri, 10 Jul 2026 15:54:39 -0500 Subject: [PATCH 22/34] T7RD-491 fixes for running tests on workflow_runs --- .../github/decide-test-run/action.yml | 37 ++++++------------- .../workflows/drainpipePantheonReviewApps.yml | 4 +- .../workflows/drainpipePlaywrightTests.yml | 4 ++ 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/scaffold/.github/actions/code-testing/github/decide-test-run/action.yml b/scaffold/.github/actions/code-testing/github/decide-test-run/action.yml index 62fe803..e6d7b27 100644 --- a/scaffold/.github/actions/code-testing/github/decide-test-run/action.yml +++ b/scaffold/.github/actions/code-testing/github/decide-test-run/action.yml @@ -1,22 +1,14 @@ name: 'Decide if Tests Should Run' -description: 'Decides whether a workflow_run-triggered test job should proceed: gated on the configured primary branch for push builds, or on a PR label for review app builds' +description: 'Decides whether a workflow_run-triggered test job should proceed: always for the configured primary branch, or gated on a PR label for any other branch' inputs: github-token: description: 'GitHub token used to look up PR labels' required: true primary-branch: - description: 'The branch whose build workflow should trigger tests (e.g. main or edge)' + description: 'The git branch to always test (e.g. main or edge)' required: false default: 'main' - build-workflow-prefix: - description: 'Prefix of the push-triggered build workflow name, matched against ""' - required: false - default: 'Pantheon Build ' - review-apps-workflow-name: - description: 'Name of the PR-triggered review app workflow' - required: false - default: 'Pantheon Review Apps' pr-label: description: 'Label required on a PR before tests run against its review app' required: false @@ -39,17 +31,22 @@ runs: env: GH_TOKEN: ${{ inputs.github-token }} GH_REPO: ${{ github.repository }} - WORKFLOW_NAME: ${{ github.event.workflow_run.name }} + HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} PRIMARY_BRANCH: ${{ inputs.primary-branch }} - BUILD_WORKFLOW_PREFIX: ${{ inputs.build-workflow-prefix }} - REVIEW_APPS_WORKFLOW_NAME: ${{ inputs.review-apps-workflow-name }} PR_LABEL: ${{ inputs.pr-label }} PULL_REQUESTS_JSON: ${{ toJSON(github.event.workflow_run.pull_requests) }} run: | - if [[ "$WORKFLOW_NAME" == "$REVIEW_APPS_WORKFLOW_NAME" ]]; then + if [[ "$HEAD_BRANCH" == "$PRIMARY_BRANCH" ]]; then + echo "should-run=true" >> "$GITHUB_OUTPUT" + if [[ "$PRIMARY_BRANCH" == "main" ]]; then + echo "multidev-name=dev" >> "$GITHUB_OUTPUT" + else + echo "multidev-name=$PRIMARY_BRANCH" >> "$GITHUB_OUTPUT" + fi + else PR_NUMBER=$(echo "$PULL_REQUESTS_JSON" | jq -r '.[0].number // empty') if [[ -z "$PR_NUMBER" ]]; then - echo "::notice::No pull request associated with this run, skipping." + echo "::notice::No pull request associated with branch $HEAD_BRANCH, skipping." echo "should-run=false" >> "$GITHUB_OUTPUT" exit 0 fi @@ -62,14 +59,4 @@ runs: echo "::notice::PR #$PR_NUMBER is missing the '$PR_LABEL' label, skipping." echo "should-run=false" >> "$GITHUB_OUTPUT" fi - elif [[ "$WORKFLOW_NAME" == "${BUILD_WORKFLOW_PREFIX}${PRIMARY_BRANCH}" ]]; then - echo "should-run=true" >> "$GITHUB_OUTPUT" - if [[ "$PRIMARY_BRANCH" == "main" ]]; then - echo "multidev-name=dev" >> "$GITHUB_OUTPUT" - else - echo "multidev-name=$PRIMARY_BRANCH" >> "$GITHUB_OUTPUT" - fi - else - echo "::notice::$WORKFLOW_NAME is not the configured primary branch ($PRIMARY_BRANCH), skipping." - echo "should-run=false" >> "$GITHUB_OUTPUT" fi diff --git a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml index 6c7523f..5484b96 100644 --- a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml +++ b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml @@ -67,7 +67,7 @@ jobs: - name: Configure review app for testing env: - SITE_NAME: ${{ vars.PANTHEON_SITE_NAME || secrets.PANTHEON_SITE_NAME }} + SITE_NAME: ${{ vars.PANTHEON_SITE_NAME }} PR_NUMBER: ${{ github.event.pull_request.number }} run: | MULTIDEV_ENV="pr-${PR_NUMBER}" @@ -97,6 +97,6 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} pr-number: ${{ github.event.pull_request.number }} - site-name: ${{ vars.PANTHEON_SITE_NAME || secrets.PANTHEON_SITE_NAME }} + site-name: ${{ vars.PANTHEON_SITE_NAME }} lock-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} lock-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 2e7411a..0bf9412 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -22,9 +22,12 @@ jobs: runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion == 'success' }} outputs: + should-run: ${{ steps.name.outputs.should-run }} multidev-name: ${{ steps.name.outputs.multidev-name }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Get multidev name id: name @@ -35,6 +38,7 @@ jobs: run-playwright-tests: runs-on: ubuntu-latest needs: get-multidev-name + if: needs.get-multidev-name.outputs.should-run == 'true' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 From 534a1eaf0ac76db38ef6b590fbc7f034888c46ba Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Fri, 10 Jul 2026 16:11:19 -0500 Subject: [PATCH 23/34] T7RD-491 full playwright install on playwright tests. non npx on browserstack --- .../code-testing/browserstack/test/action.yml | 1 - .../code-testing/playwright/test/action.yml | 34 ++++++++++++------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index 5203326..0de5d91 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -38,7 +38,6 @@ runs: run: | cd test/playwright npm ci - npx playwright install --with-deps chromium chromium-headless-shell - name: Run BrowserStack tests shell: bash diff --git a/scaffold/.github/actions/code-testing/playwright/test/action.yml b/scaffold/.github/actions/code-testing/playwright/test/action.yml index 26fe83c..31f0700 100644 --- a/scaffold/.github/actions/code-testing/playwright/test/action.yml +++ b/scaffold/.github/actions/code-testing/playwright/test/action.yml @@ -9,10 +9,10 @@ inputs: environment-password: description: "Password for basic auth to access any site that is behind a server-level username/password. If it is not needed it will be ignored." required: true - test-script: - description: "The npm script to run (defined in test/playwright/package.json). Defaults to 'test'." + test-args: + description: "Additional arguments to pass to the Playwright test. For instance --ignore-snapshots --project=func-chromium" required: false - default: "test" + default: "--ignore-snapshots --project=func-chromium --project=wcag --project=vrt-chromium" runs: using: composite @@ -28,23 +28,31 @@ runs: run: | cd test/playwright npm ci - npx playwright install + - name: Install Playwright browsers + shell: bash + run: | + cd test/playwright + npx playwright install - name: Run Playwright tests shell: bash env: NODE_OPTIONS: --disable-warning=DEP0205 BASE_URL: ${{ inputs.target-url }} - BASIC_AUTH_USER: ${{ inputs.pantheon-review-username }} - BASIC_AUTH_PASS: ${{ inputs.patheon-review-password }} - run: | - cd test/playwright - mkdir -p test-results - npm run ${{ inputs.test-script }} + BASIC_AUTH_USER: ${{ inputs.environment-username }} + BASIC_AUTH_PASS: ${{ inputs.environment-password }} + run: cd test/playwright && mkdir -p test-results && npm run test -- ${{ inputs.test-args }} - name: Upload test results - if: ${{ always() }} - uses: actions/upload-artifact@v6 + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 with: name: playwright-report path: test/playwright/playwright-report/ - retention-days: 5 + retention-days: 30 + - name: Upload test artifacts + if: failure() + uses: actions/upload-artifact@v4 + with: + name: test-results + path: test/playwright/test-results/ + retention-days: 30 From 8759a45e55bd2a9552352d24e36c45f440cff01c Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Fri, 10 Jul 2026 16:13:09 -0500 Subject: [PATCH 24/34] T7RD-491 full playwright install on playwright --- .../code-testing/playwright/test/action.yml | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/scaffold/.github/actions/code-testing/playwright/test/action.yml b/scaffold/.github/actions/code-testing/playwright/test/action.yml index 31f0700..26fe83c 100644 --- a/scaffold/.github/actions/code-testing/playwright/test/action.yml +++ b/scaffold/.github/actions/code-testing/playwright/test/action.yml @@ -9,10 +9,10 @@ inputs: environment-password: description: "Password for basic auth to access any site that is behind a server-level username/password. If it is not needed it will be ignored." required: true - test-args: - description: "Additional arguments to pass to the Playwright test. For instance --ignore-snapshots --project=func-chromium" + test-script: + description: "The npm script to run (defined in test/playwright/package.json). Defaults to 'test'." required: false - default: "--ignore-snapshots --project=func-chromium --project=wcag --project=vrt-chromium" + default: "test" runs: using: composite @@ -28,31 +28,23 @@ runs: run: | cd test/playwright npm ci - - - name: Install Playwright browsers - shell: bash - run: | - cd test/playwright npx playwright install + - name: Run Playwright tests shell: bash env: NODE_OPTIONS: --disable-warning=DEP0205 BASE_URL: ${{ inputs.target-url }} - BASIC_AUTH_USER: ${{ inputs.environment-username }} - BASIC_AUTH_PASS: ${{ inputs.environment-password }} - run: cd test/playwright && mkdir -p test-results && npm run test -- ${{ inputs.test-args }} + BASIC_AUTH_USER: ${{ inputs.pantheon-review-username }} + BASIC_AUTH_PASS: ${{ inputs.patheon-review-password }} + run: | + cd test/playwright + mkdir -p test-results + npm run ${{ inputs.test-script }} - name: Upload test results - if: ${{ !cancelled() }} - uses: actions/upload-artifact@v4 + if: ${{ always() }} + uses: actions/upload-artifact@v6 with: name: playwright-report path: test/playwright/playwright-report/ - retention-days: 30 - - name: Upload test artifacts - if: failure() - uses: actions/upload-artifact@v4 - with: - name: test-results - path: test/playwright/test-results/ - retention-days: 30 + retention-days: 5 From be3058ceff05f8da120233318c697e3f82fe4142 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Fri, 10 Jul 2026 16:57:10 -0500 Subject: [PATCH 25/34] T7RD-491 always run tests based on the head_sha so tests in the pr are evaluataed --- .../actions/code-testing/browserstack/test/action.yml | 3 --- scaffold/.github/workflows/deploymentBrowserStackTests.yml | 2 ++ scaffold/.github/workflows/deploymentPlaywrightTests.yml | 2 ++ scaffold/.github/workflows/drainpipeBrowserStackTests.yml | 7 +++---- scaffold/.github/workflows/drainpipePlaywrightTests.yml | 2 ++ 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index 0de5d91..fbc3820 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -23,9 +23,6 @@ inputs: runs: using: composite steps: - - name: Checkout actions - uses: actions/checkout@v6 - - name: Setup Node.js uses: actions/setup-node@v6 with: diff --git a/scaffold/.github/workflows/deploymentBrowserStackTests.yml b/scaffold/.github/workflows/deploymentBrowserStackTests.yml index 30f589c..89ab715 100644 --- a/scaffold/.github/workflows/deploymentBrowserStackTests.yml +++ b/scaffold/.github/workflows/deploymentBrowserStackTests.yml @@ -92,6 +92,8 @@ jobs: # Browserstack test steps go here - name: Checkout actions uses: actions/checkout@v6 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Validate browserstack connection id: validate-browserstack diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml index 409620c..e31fc5f 100644 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ b/scaffold/.github/workflows/deploymentPlaywrightTests.yml @@ -10,6 +10,8 @@ jobs: if: github.event.deployment_status.state == 'success' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml index 4db6fb6..522d956 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml @@ -23,6 +23,8 @@ jobs: multidev-name: ${{ steps.decide.outputs.multidev-name }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Decide whether to run BrowserStack tests id: decide @@ -37,11 +39,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 with: - php-version: ${{ needs.detect-php-version.outputs.php-version }} + ref: ${{ github.event.workflow_run.head_sha }} - name: Install Terminus uses: pantheon-systems/terminus-github-actions@v1 diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 0bf9412..801d1b7 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -41,6 +41,8 @@ jobs: if: needs.get-multidev-name.outputs.should-run == 'true' steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + ref: ${{ github.event.workflow_run.head_sha }} - name: Set target URL shell: bash From 3d77e3521fbf58e9c3314e70e0c9aff51f8ef5b0 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Sat, 11 Jul 2026 09:28:55 -0500 Subject: [PATCH 26/34] T7RD-491 Ensure .browserstack dir exists for tests. --- .../.github/actions/code-testing/browserstack/test/action.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index fbc3820..cd65df6 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -36,6 +36,10 @@ runs: cd test/playwright npm ci + - name: Ensure BrowserStack config directory exists + shell: bash + run: mkdir -p "$HOME/.browserstack" + - name: Run BrowserStack tests shell: bash run: | From d152ec7978e4c4b2b42ce0a601a6acc9b8c487f8 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Sun, 12 Jul 2026 19:43:56 -0500 Subject: [PATCH 27/34] T7RD-491 typo in drainpipePlaywrightTests.yml --- scaffold/.github/workflows/drainpipePlaywrightTests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 801d1b7..6a93cf8 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -56,7 +56,7 @@ jobs: - name: Run Playwright tests in Pantheon environment. uses: ./.github/actions/code-testing/playwright/test with: - environment-password: ${{ secrets.PANTHEON_REVIEW_USERNAME }} - environment-username: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + environment-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + environment-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} target-url: ${{ steps.set-url.outputs.target_url }} test-script: 'test:ci-pantheon' \ No newline at end of file From 9f9c0f1d6103bc5e94d0e3493dd82b76320c9c0b Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Sun, 12 Jul 2026 19:53:21 -0500 Subject: [PATCH 28/34] T7RD-491 only run this in PHP 8.3 or higher --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 62dcc94..1962f43 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "composer-plugin", "license": "GPL-2.0-or-later", "require": { - "php": ">=8.1", + "php": ">=8.3", "composer-plugin-api": "^2.0", "lullabot/drainpipe": "^6.0" }, From b5810d0b265437bb87b0686184396d2ef81b9e1d Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 13 Jul 2026 13:28:29 -0500 Subject: [PATCH 29/34] T7RD-491 unify inputs for browserstack and playwright --- .../code-testing/browserstack/test/action.yml | 8 ++-- .../code-testing/playwright/test/action.yml | 41 +++++++++++++++---- .../workflows/deploymentBrowserStackTests.yml | 4 +- .../.github/workflows/deploymentCodeTests.yml | 4 +- .../workflows/deploymentPlaywrightTests.yml | 4 +- .../workflows/drainpipeBrowserStackTests.yml | 4 +- .../.github/workflows/drainpipeCodeTests.yml | 4 +- .../workflows/drainpipePlaywrightTests.yml | 4 +- 8 files changed, 50 insertions(+), 23 deletions(-) diff --git a/scaffold/.github/actions/code-testing/browserstack/test/action.yml b/scaffold/.github/actions/code-testing/browserstack/test/action.yml index cd65df6..39ada18 100644 --- a/scaffold/.github/actions/code-testing/browserstack/test/action.yml +++ b/scaffold/.github/actions/code-testing/browserstack/test/action.yml @@ -14,10 +14,10 @@ inputs: target-url: description: "The name of the Pantheon site to test against." required: true - pantheon-review-username: + basic-auth-user: description: "Username for basic auth to access Pantheon review apps. Should be set as a secret named PANTHEON_REVIEW_USERNAME." required: true - pantheon-review-password: + basic-auth-pass: description: "Password for basic auth to access Pantheon review apps. Should be set as a secret named PANTHEON_REVIEW_PASSWORD." required: true runs: @@ -50,8 +50,8 @@ runs: env: NODE_OPTIONS: --disable-warning=DEP0205 BASE_URL: ${{ inputs.target-url }} - BASIC_AUTH_USER: ${{ inputs.pantheon-review-username }} - BASIC_AUTH_PASS: ${{ inputs.pantheon-review-password }} + BASIC_AUTH_USER: ${{ inputs.basic-auth-user }} + BASIC_AUTH_PASS: ${{ inputs.basic-auth-pass }} BROWSERSTACK_USERNAME: ${{ inputs.browserstack-username }} BROWSERSTACK_ACCESS_KEY: ${{ inputs.browserstack-access-key }} BROWSERSTACK_BUILD_NAME: ${{ inputs.target-url }} diff --git a/scaffold/.github/actions/code-testing/playwright/test/action.yml b/scaffold/.github/actions/code-testing/playwright/test/action.yml index 26fe83c..79ee357 100644 --- a/scaffold/.github/actions/code-testing/playwright/test/action.yml +++ b/scaffold/.github/actions/code-testing/playwright/test/action.yml @@ -3,11 +3,11 @@ description: "Run Playwright tests against a remote environment." inputs: target-url: description: "The url to be used as BASE_URL for the scripts" - environment-username: - description: "Username for basic auth to access any site that is behind a server-level username/password. If it is not needed it will be ignored." + basic-auth-user: + description: "Username for basic auth to access Pantheon review apps. Should be set as a secret named PANTHEON_REVIEW_USERNAME." required: true - environment-password: - description: "Password for basic auth to access any site that is behind a server-level username/password. If it is not needed it will be ignored." + basic-auth-pass: + description: "Password for basic auth to access Pantheon review apps. Should be set as a secret named PANTHEON_REVIEW_PASSWORD." required: true test-script: description: "The npm script to run (defined in test/playwright/package.json). Defaults to 'test'." @@ -28,15 +28,42 @@ runs: run: | cd test/playwright npm ci - npx playwright install + + - name: Get installed Playwright version + id: playwright-version + shell: bash + run: | + cd test/playwright + echo "version=$(node -e "console.log(require('@playwright/test/package.json').version)")" >> $GITHUB_OUTPUT + + - name: Cache Playwright browser binaries + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.version }} + + - name: Install Playwright browsers and OS dependencies + if: steps.playwright-cache.outputs.cache-hit != 'true' + shell: bash + run: | + cd test/playwright + npx playwright install --with-deps + + - name: Install OS dependencies for cached browsers + if: steps.playwright-cache.outputs.cache-hit == 'true' + shell: bash + run: | + cd test/playwright + npx playwright install-deps - name: Run Playwright tests shell: bash env: NODE_OPTIONS: --disable-warning=DEP0205 BASE_URL: ${{ inputs.target-url }} - BASIC_AUTH_USER: ${{ inputs.pantheon-review-username }} - BASIC_AUTH_PASS: ${{ inputs.patheon-review-password }} + BASIC_AUTH_USER: ${{ inputs.basic-auth-user }} + BASIC_AUTH_PASS: ${{ inputs.basic-auth-pass }} run: | cd test/playwright mkdir -p test-results diff --git a/scaffold/.github/workflows/deploymentBrowserStackTests.yml b/scaffold/.github/workflows/deploymentBrowserStackTests.yml index 89ab715..54c3bad 100644 --- a/scaffold/.github/workflows/deploymentBrowserStackTests.yml +++ b/scaffold/.github/workflows/deploymentBrowserStackTests.yml @@ -119,6 +119,6 @@ jobs: with: browserstack-access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} browserstack-username: ${{ secrets.BROWSERSTACK_USERNAME }} - pantheon-review-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} - pantheon-review-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + basic-auth-pass: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + basic-auth-user: ${{ secrets.PANTHEON_REVIEW_USERNAME }} target-url: ${{ steps.set-url.outputs.target_url }} \ No newline at end of file diff --git a/scaffold/.github/workflows/deploymentCodeTests.yml b/scaffold/.github/workflows/deploymentCodeTests.yml index ac1cfdd..2c7f6c9 100644 --- a/scaffold/.github/workflows/deploymentCodeTests.yml +++ b/scaffold/.github/workflows/deploymentCodeTests.yml @@ -167,7 +167,7 @@ jobs: - name: Run Playwright tests in DDEV uses: ./.github/actions/code-testing/playwright/test with: - environment-password: '' - environment-username: '' + basic-auth-pass: '' + basic-auth-user: '' target-url: ${{ steps.ddev-url.outputs.url }} test-script: 'test:ci-ddev' diff --git a/scaffold/.github/workflows/deploymentPlaywrightTests.yml b/scaffold/.github/workflows/deploymentPlaywrightTests.yml index e31fc5f..6e9751f 100644 --- a/scaffold/.github/workflows/deploymentPlaywrightTests.yml +++ b/scaffold/.github/workflows/deploymentPlaywrightTests.yml @@ -41,6 +41,6 @@ jobs: uses: ./.github/actions/code-testing/playwright/test with: target-url: ${{ github.event.deployment_status.environment_url }} - environment-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} - environment-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + basic-auth-user: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + basic-auth-pass: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} test-script: 'test:ci-pantheon' \ No newline at end of file diff --git a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml index 522d956..7b2fd21 100644 --- a/scaffold/.github/workflows/drainpipeBrowserStackTests.yml +++ b/scaffold/.github/workflows/drainpipeBrowserStackTests.yml @@ -78,6 +78,6 @@ jobs: with: browserstack-access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }} browserstack-username: ${{ secrets.BROWSERSTACK_USERNAME }} - pantheon-review-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} - pantheon-review-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + basic-auth-pass: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + basic-auth-user: ${{ secrets.PANTHEON_REVIEW_USERNAME }} target-url: ${{ steps.set-url.outputs.target_url }} \ No newline at end of file diff --git a/scaffold/.github/workflows/drainpipeCodeTests.yml b/scaffold/.github/workflows/drainpipeCodeTests.yml index 0deef47..69bdae5 100644 --- a/scaffold/.github/workflows/drainpipeCodeTests.yml +++ b/scaffold/.github/workflows/drainpipeCodeTests.yml @@ -171,7 +171,7 @@ jobs: - name: Run Playwright tests in DDEV uses: ./.github/actions/code-testing/playwright/test with: - environment-password: '' - environment-username: '' + basic-auth-pass: '' + basic-auth-user: '' target-url: ${{ steps.ddev-url.outputs.url }} test-script: 'test:ci-ddev' diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 6a93cf8..41864cf 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -56,7 +56,7 @@ jobs: - name: Run Playwright tests in Pantheon environment. uses: ./.github/actions/code-testing/playwright/test with: - environment-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} - environment-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + basic-auth-pass: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + basic-auth-user: ${{ secrets.PANTHEON_REVIEW_USERNAME }} target-url: ${{ steps.set-url.outputs.target_url }} test-script: 'test:ci-pantheon' \ No newline at end of file From bf65d5fad699b72cf62cf296ace3603db0d86d63 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Thu, 16 Jul 2026 17:27:49 -0500 Subject: [PATCH 30/34] T7RD-491 allow playwright tests independent of browserstack --- scaffold/.github/workflows/drainpipePlaywrightTests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/scaffold/.github/workflows/drainpipePlaywrightTests.yml b/scaffold/.github/workflows/drainpipePlaywrightTests.yml index 41864cf..71aaf2e 100644 --- a/scaffold/.github/workflows/drainpipePlaywrightTests.yml +++ b/scaffold/.github/workflows/drainpipePlaywrightTests.yml @@ -35,6 +35,7 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} primary-branch: ${{ vars.BROWSERSTACK_PRIMARY_BRANCH || 'main' }} + pr-label: 'build multidev' run-playwright-tests: runs-on: ubuntu-latest needs: get-multidev-name From 8423c237f6c287ab8a273b662152a14759d97475 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Thu, 16 Jul 2026 17:31:24 -0500 Subject: [PATCH 31/34] T7RD-491 disable running playwright in codeTests unless explicitly requested --- .../.github/workflows/deploymentCodeTests.yml | 23 +++++++++++++++++++ .../.github/workflows/drainpipeCodeTests.yml | 8 +++++++ 2 files changed, 31 insertions(+) diff --git a/scaffold/.github/workflows/deploymentCodeTests.yml b/scaffold/.github/workflows/deploymentCodeTests.yml index 2c7f6c9..8aea4b3 100644 --- a/scaffold/.github/workflows/deploymentCodeTests.yml +++ b/scaffold/.github/workflows/deploymentCodeTests.yml @@ -10,6 +10,7 @@ concurrency: jobs: detect-php-version: + if: github.event.deployment_status.state == 'success' name: Detect PHP Version runs-on: ubuntu-latest outputs: @@ -155,16 +156,38 @@ jobs: path: | test-results/phpunit/ web/sites/simpletest/browser_output/ + - name: Check if Playwright should run + id: check-playwright + env: + GH_TOKEN: ${{ github.token }} + run: | + # Run Playwright on the default branch, or when the PR + # associated with this deployment has the playwright-tests label. + if [ "${{ github.event.deployment.ref }}" = "${{ github.event.repository.default_branch }}" ]; then + echo "Deployment is for the default branch." + echo "run=true" >> $GITHUB_OUTPUT + exit 0 + fi + LABELS=$(gh api "repos/${{ github.repository }}/commits/${{ github.event.deployment.sha }}/pulls" \ + --jq '[.[].labels[].name] | join(" ")') + echo "PR labels: ${LABELS}" + if echo "${LABELS}" | grep -qw 'playwright-tests'; then + echo "run=true" >> $GITHUB_OUTPUT + else + echo "run=false" >> $GITHUB_OUTPUT + fi # --- Playwright E2E Tests against DDEV environment --- - name: Get DDEV URL id: ddev-url + if: steps.check-playwright.outputs.run == 'true' run: | DDEV_URL=$(ddev describe -j | jq -r '.raw.primary_url') echo "url=${DDEV_URL}" >> $GITHUB_OUTPUT echo "DDEV URL: ${DDEV_URL}" - name: Run Playwright tests in DDEV + if: steps.check-playwright.outputs.run == 'true' uses: ./.github/actions/code-testing/playwright/test with: basic-auth-pass: '' diff --git a/scaffold/.github/workflows/drainpipeCodeTests.yml b/scaffold/.github/workflows/drainpipeCodeTests.yml index 69bdae5..700bdc2 100644 --- a/scaffold/.github/workflows/drainpipeCodeTests.yml +++ b/scaffold/.github/workflows/drainpipeCodeTests.yml @@ -161,14 +161,22 @@ jobs: web/sites/simpletest/browser_output/ # --- Playwright E2E Tests against DDEV environment --- + # Run Playwright on pushes to the default branch, or when the PR + # has the playwright-tests label. + - name: Check if Playwright should run + id: check-playwright + run: echo "run=${{ (github.event_name == 'push' && github.ref_name == github.event.repository.default_branch) || contains(github.event.pull_request.labels.*.name, 'playwright-tests') }}" >> $GITHUB_OUTPUT + - name: Get DDEV URL id: ddev-url + if: steps.check-playwright.outputs.run == 'true' run: | DDEV_URL=$(ddev describe -j | jq -r '.raw.primary_url') echo "url=${DDEV_URL}" >> $GITHUB_OUTPUT echo "DDEV URL: ${DDEV_URL}" - name: Run Playwright tests in DDEV + if: steps.check-playwright.outputs.run == 'true' uses: ./.github/actions/code-testing/playwright/test with: basic-auth-pass: '' From 2719d7d0c6d5686211d54114621435e3c3b8119b Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 20 Jul 2026 10:12:31 -0500 Subject: [PATCH 32/34] T7RD-491 run config import on edge/main sites --- scaffold/.github/workflows/drainpipePantheonBuildEdge.yml | 6 ++++++ scaffold/.github/workflows/drainpipePantheonBuildMain.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml index 4e66e8a..f86e877 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildEdge.yml @@ -64,6 +64,12 @@ jobs: site-name: ${{ secrets.PANTHEON_SITE_NAME }} branch: edge + - name: Import configuration and run updates + uses: ./.github/actions/drainpipe/pantheon/update + with: + site-name: ${{ secrets.PANTHEON_SITE_NAME }} + environment: edge + - name: Install Terminus uses: pantheon-systems/terminus-github-actions@v1 with: diff --git a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml index efcd6f0..8d9d9fe 100644 --- a/scaffold/.github/workflows/drainpipePantheonBuildMain.yml +++ b/scaffold/.github/workflows/drainpipePantheonBuildMain.yml @@ -59,6 +59,12 @@ jobs: site-name: ${{ secrets.PANTHEON_SITE_NAME }} branch: master + - name: Import configuration and run updates + uses: ./.github/actions/drainpipe/pantheon/update + with: + site-name: ${{ secrets.PANTHEON_SITE_NAME }} + environment: dev + - name: Install Terminus uses: pantheon-systems/terminus-github-actions@v1 with: From 5ed1dcadc42e9a391befa08d680e97c07fbe41f7 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Mon, 20 Jul 2026 12:10:58 -0500 Subject: [PATCH 33/34] T7RD-491 add label to PR sooner in build --- .../workflows/drainpipePantheonReviewApps.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml index 5484b96..b371c90 100644 --- a/scaffold/.github/workflows/drainpipePantheonReviewApps.yml +++ b/scaffold/.github/workflows/drainpipePantheonReviewApps.yml @@ -29,6 +29,15 @@ jobs: ${{ runner.os }}-composer- - uses: ./.github/actions/drainpipe/set-env + - name: Add Multidev URL to PR + uses: ./.github/actions/code-testing/github/add-pr-url + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + pr-number: ${{ github.event.pull_request.number }} + site-name: ${{ vars.PANTHEON_SITE_NAME }} + lock-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} + lock-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} + - uses: ./.github/actions/drainpipe/validate-terminus-timeout with: terminus_timeout_limit: ${{ vars.TERMINUS_TIMEOUT_LIMIT }} @@ -92,11 +101,3 @@ jobs: pantheon-site-name: ${{ secrets.PANTHEON_SITE_NAME }} multidev-name: pr-${{ github.event.pull_request.number }} - - name: Add Multidev URL to PR - uses: ./.github/actions/code-testing/github/add-pr-url - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - pr-number: ${{ github.event.pull_request.number }} - site-name: ${{ vars.PANTHEON_SITE_NAME }} - lock-username: ${{ secrets.PANTHEON_REVIEW_USERNAME }} - lock-password: ${{ secrets.PANTHEON_REVIEW_PASSWORD }} From dfa3a6c0b23ab2808f137ae28f322ca105e3c1e6 Mon Sep 17 00:00:00 2001 From: Chris Dart Date: Fri, 24 Jul 2026 18:08:30 -0500 Subject: [PATCH 34/34] T7RD-492 update README.md for clarity and new code changes. --- README.md | 214 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 160 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index dd349a5..cabbce7 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,16 @@ This is a transitional project, allowing TEN7 to build testing infrastructure fo existing lullabot/drainpipe projects and preparing for the switch to Pantheon-based deployments on GitHub. -This will install [lullabot/drainpipe](https://github.com/lullabot/drainpipe) as a -dependency, but drainpipe actions are only installed on sites that use -drainpipe. +This will install [lullabot/drainpipe](https://github.com/lullabot/drainpipe) as a dependency, but Drainpipe +actions are only installed on sites that use Drainpipe. Because this depends +on a certain version of Drainpipe, it is best to run `composer remove --dev +lullabot/drainpipe-dev -W` and `composer remove lullabot/drainpipe` so that +the version constraint equals what is installed by this repo. + +🗒️The intent is that this repo should be updated regularly to the latest +version of Drainpipe. All Drainpipe features are available to the site if +that is desired, however, most Pantheon-related functionality is +incorporated into the equivalent workflows on this project. # Requirements @@ -25,7 +32,8 @@ which will install a browserstack.yml file in the `test/playwright` directory. For the `CodeTests`, it is also important to have a phpunit configuration on your site. In most Drupal setups, this will be at least partly set up on -install. If there are no tests, Unit and ExistingSite steps will be skipped. +installation. If there are no tests, Unit and ExistingSite steps will be +skipped. As is mentioned below, This is not necessary as the tests can be run locally; however, if your site has php-based tests you want run, these can be a useful check on every run. @@ -33,23 +41,31 @@ useful check on every run. ## Installation This repo is not listed at packagist so you need to add the following to -your "repositories[]" in composer.json: +your "repositories[]" in composer.json. + ```json { - "type": "vcs", - "url": "https://github.com/ten7/github-code-testing" + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/ten7/github-code-testing" + } + ] } ``` Then you can run the following, though nothing will change in your codebase -until you define "github" in "extras" explained below. +until you define "GitHub" in "extras" explained below. + +⚠️ You may need to adjust your minimum stability if installation results in +a message that it cannot find the repo to install. Note: It is best to use the latest version when requiring this. Check the tags at https://github.com/ten7/github-code-testing. -```bash +```shell composer require "ten7/github-code-testing^1.0.7-beta" ``` @@ -69,8 +85,8 @@ context key and a list of workflow names. * `SSH_PRIVATE_KEY` is needed for all actions. * `SSH_KNOWN_HOSTS` is also needed for all actions. * `TERMINUS_MACHINE_TOKEN` is required for all actions -* `PANTHEON_REVIEW_RUN_INSTALLER` is required for drainpipe actions -* `PANTHEON_SITE_NAME` is the required by drainpipe actions. It is the UUID +* `PANTHEON_REVIEW_RUN_INSTALLER` is required for Drainpipe actions +* `PANTHEON_SITE_NAME` is the required by Drainpipe actions. It is the UUID for the site. It's annoying to have this in both variables and secrets. It really should just be a variable unless at some point Pantheon allows renaming a site and the UUID serves it's real purpose of being the @@ -82,12 +98,12 @@ context key and a list of workflow names. ##### Variables * `BROWSERSTACK_PRIMARY_BRANCH` is the branch (edge, main, master) that - browserstack -* tests should be run on. + browserstack tests should be run on. * `BROWSERSTACK_TESTS_ENABLED` is a boolean that indicates if browserstack tests should be run at all. * `TESTING_NEEDS_SEARCH_INDEXING` is a boolean that determines if tests run on - the site require a build to run the search_api index. + the site require a build to run the search_api index. This should be set + to either `true` or `false` (which is the same as not having it) * `PANTHEON_SITE_NAME` is the human-friendly site name that is used in multi-dev URLs: https:/dev-[site-name].pantheonsite.io @@ -118,30 +134,34 @@ On PRs some labels can be used for triggering actions these include ### Drainpipe Example This automatically loads all the lullabot/drainpipe actions that are needed -for the specific tasks. There is no need to call drainpipe separately unless +for the specific tasks. There is no need to call Drainpipe separately unless you have specific additional requirements for those. Just be sure not to overlap functionality. ⚠️ Note that the PlaywrightTests and BrowserstackTests must be merged to the root branch of the repo before they can be run on any PR. This is a -fundamental requirement of Github. This is generally acceptable especially +fundamental requirement of GitHub. This is generally acceptable especially for Browserstack since it should be used sparingly. ```json { - "code_testing": { - "github": { - "drainpipe": [ - "PlaywrightTests", - "BrowserStackTests", - "PantheonBuildEdge", - "PantheonBuildMain", - "PantheonReviewApps", - "CodeTests", - "LockDiff" - ] + "extras": [ + { + "code_testing": { + "github": { + "drainpipe": [ + "PlaywrightTests", + "BrowserStackTests", + "PantheonBuildEdge", + "PantheonBuildMain", + "PantheonReviewApps", + "CodeTests", + "LockDiff" + ] + } + } } - } + ] } ``` @@ -176,16 +196,55 @@ CodeTests and LockDiff can be run independently of a build. ##### CodeTests -CodeTests is not necessary as all of what it does can be run locally. Adding +CodeTests is not necessary as all of what it does can be run locally. ⚠️**It +is, however, the only workflow that runs PHP-based tests.** Adding it to your repo, can be a fairly inexpensive way to verify that code is working at a bare level. It runs the full suite of tests a site may have from Unit to ExistingSite tests, a code check, and any playwright tests against a DDEV environment on GitHub. This workflow expects a playwright -test called `test:ci-ddev` (see below). +test called `test:ci-ddev` (see below). To run this on a PR you must add the +label `playwright-tests`. + +Writing php existing-site and unit tests are beyond the scope of this README +but here are some expectations you will need to set up. You can learn more +at [Running PHPUnit Tests](https://www.drupal.org/docs/develop/automated-testing/phpunit-in-drupal/running-phpunit-tests) + +The CodeTests workflow expects the following tasks: + +* test:existing-site +* test:unit + +The assumption is that _all_ your custom modules are annotated with at least +one common group. Replace [your_group] in the code below with whatever that +group name is. + + +```yml +tasks: + test:existing-site: + desc: "Runs the test suite in development mode" + cmds: + - echo "🔬 Running existing-site tests in development mode..." + - exec ./vendor/bin/phpunit --testsuite existing-site --group [your_group] + + test:unit: + desc: "Runs the unit tests in development mode" + cmds: + - echo "🔬 Running unit tests in development mode..." + - exec ./vendor/bin/phpunit --testsuite unit --group [your_group] +``` + +You also need to run the following (or, at a bare minimum, `drupal/core-dev`). + +```shell +composer require --dev drupal/core-dev --with-all-dependencies +composer require --dev weitzman/drupal-test-traits --with-all-dependencies +composer require --dev weitzman/logintrait --with-all-dependencies +``` #### testRenovate -This is installed by drainpipe, but may not actually get installed. If you +This is installed by Drainpipe, but may not actually get installed. If you want to use this, and you have instructions in a renovate.json and have it configured on GitHub, you need to add the following to `extra.code_testing`. @@ -195,9 +254,17 @@ label - without it, the job is skipped entirely. ```json { - "test": [ - "Renovate" - ] + "extras": [ + { + "code_testing": { + "github": { + "test": [ + "Renovate" + ] + } + } + } + ] } ``` @@ -208,17 +275,19 @@ the options are simpler. ```json { - "code_testing": { - "github": { - "deployment": [ - "PlaywrightTests", - "BrowserStackTests", - "CodeTests", - "LockDiff" - ] +"extras":[ + { + "code_testing": { + "github": { + "deployment": [ + "PlaywrightTests", + "BrowserStackTests", + "CodeTests", + "LockDiff" + ] + } } - } -} + }]} ``` ### Workflow file patterns @@ -231,7 +300,7 @@ example above would scaffold: - `deploymentCodeTests.yml` - `testRenovate.yml` -It's entirely possible to skip the extras:code_testing" section and just copy +It's entirely possible to skip the "extras:code_testing" section and just copy the desired files from `./vendor/ten7/scaffold/.github/workflows`, but this should not be necessary. If there need to be new changes, they should be made here with broadly abstracted steps and making use of updates users can @@ -242,8 +311,8 @@ scripts `test/playwright/package.json` | Context | Use when | |--------------|--------------------------------------------------------------| -| `drainpipe` | The project uses drainpipe for its build and deploy pipeline | -| `deployment` | The project uses a non-drainpipe deployment pipeline | +| `drainpipe` | The project uses Drainpipe for its build and deploy pipeline | +| `deployment` | The project uses a non-Drainpipe deployment pipeline | | `test` | Standalone test utilities (e.g., Renovate) | ## Available workflows @@ -262,13 +331,33 @@ This plugin also installs certain lullabot/drainpipe actions as needed. Workflows not declared in `code_testing` are never written to `.github/workflows/`, so they never appear in the GitHub Actions tab. This keeps -Pantheon-specific or drainpipe-specific workflows out of projects that don't use +Pantheon-specific or Drainpipe-specific workflows out of projects that don't use them. ## How to use with Playwright and BrowserStack testing. -This project expects tests to be in a directory `./test/playwright`. In the -package.json file you will need to create scripts that you want to run as +This project expects tests to be in a directory `./test/playwright`. + +To install playwright, create a directory in the repo root: + +```shell +mkdir -p test/playwright +``` + +Switch to the new directory and run: + +```shell +npm init playwright@latest +``` + +Don't add the GitHub action if requested. This repo handles that work. For best +results, answer all other questions with the defaults. + +Specifics on how to write your tests and what to test for is beyond the +scope for this repo. Each site may have different requirements and levels of +thoroughness. + +In the package.json file you will need to create scripts that you want to run as follows: * test:ci-ddev @@ -279,12 +368,29 @@ These tests should define what should be run by npm. An example might be: ```json { - "test:ci-ddev": "playwright test --project=func-chromium", - "test:ci-pantheon": "playwright test --grep='@smoke' --project=func-chromium", - "test:browserstack": "BROWSERSTACK_BUILD=true browserstack-node-sdk playwright test --grep='@browserstack'" + "scripts": { + "test:ci-ddev": "playwright test --project=func-chromium", + "test:ci-pantheon": "playwright test --grep='@smoke' --project=func-chromium", + "test:browserstack": "BROWSERSTACK_BUILD=true browserstack-node-sdk playwright test --grep='@browserstack'" + } } - ``` The `test:browserstack` should be configured differently based on the rules for developing with BrowserStack that are beyond the scope of this repo. + +### Testing suggestions + +These are some simple guidelines to help you with making the best use of +this tool. + +* If you have a paid Browserstack Automate account, you probably don't need to +include the `PlaywrightTests` workflow. +* It is unlikely to be useful to run both `PlaywrightTests` and include + `playwright-tests` as a label in your repo to run them on `CodeTests` as + well. +* Visual regression tests are notoriously flaky. It may be useful to include in +each test a warming function to load the page before actually testing it. +* Visual regression tests can also be very time-consuming as both the GitHub +runner VMs and the Pantheon Multidevs are much slower than a live site or your +local DDEV environment. \ No newline at end of file