From ff53ea93931dafec9a4b17f615fd70a0b8044e98 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 10:17:49 -0600 Subject: [PATCH 01/22] add copying the changes in the PR to the subdomain tests --- .github/workflows/playwright.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 9b6ed21b..208955fa 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -358,6 +358,7 @@ jobs: echo "SITE_NAME=$SITE_NAME" >> $GITHUB_ENV echo "SITE_URL=$SITE_URL" >> $GITHUB_ENV echo "SUBDOMAIN_URL=$SUBDOMAIN_URL" >> $GITHUB_ENV + echo "SITE_ID=wpcm-subdom-playwright-tests" >> $GITHUB_ENV - name: Install SSH keys uses: webfactory/ssh-agent@v0.9.0 @@ -385,6 +386,37 @@ jobs: echo "Install Playwright Browsers" npx playwright install --with-deps + - name: Copy changes from PR + run: | + echo "Commit Message: ${{ env.COMMIT_MSG }}" + echo "Setting up some git config..." + git config --global user.email "cms-platform+sage-testing@pantheon.io" + git config --global user.name "Pantheon WPCM Bot" + + echo "Clone the site locally and copy PR updates" + terminus local:clone ${{ env.SITE_ID }} + cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" + echo "Copying latest changes and committing to the site." + rsync -a --exclude='.git' --exclude='status-*.txt' "${{ github.workspace }}/" . + git add -A + git commit -m "Update to latest commit: ${{ env.COMMIT_MSG }}" || true + git push origin master || true + + echo "Checking WordPress install status" + terminus wp "${{ env.SITE_ID }}".dev -- cli info + if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true MULTISITE; then + echo -e "${RED}Multisite not found!${RESET}" + exit 1 + fi + # Check SUBDOMAIN_INSTALL value + SUBDOMAIN_INSTALL=$(terminus wp "${{ env.SITE_ID }}".dev -- config get SUBDOMAIN_INSTALL) + if [[ "${SUBDOMAIN_INSTALL}" != "1" ]]; then + # SUBDOMAIN_INSTALL should be true. + echo -e "${RED}Subdomain configuration not found!${RESET}" + exit 1 + fi + # Wait for the git push to finish. + terminus workflow:wait "${{ env.SITE_ID }}".dev - name: Run Playwright tests env: SITE_NAME: ${{ env.SITE_NAME }} From 75e933f5f4160e8d5839bfd442d7aa5e6ccf3efb Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 11:38:14 -0600 Subject: [PATCH 02/22] switch to git mode before we try pushing things --- .github/workflows/playwright.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 208955fa..68f16f7a 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -393,6 +393,9 @@ jobs: git config --global user.email "cms-platform+sage-testing@pantheon.io" git config --global user.name "Pantheon WPCM Bot" + echo "Switching to git mode..." + terminus connection:set "${{ env.SITE_ID }}".dev git + echo "Clone the site locally and copy PR updates" terminus local:clone ${{ env.SITE_ID }} cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" From 20daa86ce479586c9f9cfb7521adbde71ec7c90d Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 11:39:50 -0600 Subject: [PATCH 03/22] remove color tags --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 68f16f7a..94faa725 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -408,14 +408,14 @@ jobs: echo "Checking WordPress install status" terminus wp "${{ env.SITE_ID }}".dev -- cli info if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true MULTISITE; then - echo -e "${RED}Multisite not found!${RESET}" + echo -e "Multisite not found!" exit 1 fi # Check SUBDOMAIN_INSTALL value SUBDOMAIN_INSTALL=$(terminus wp "${{ env.SITE_ID }}".dev -- config get SUBDOMAIN_INSTALL) if [[ "${SUBDOMAIN_INSTALL}" != "1" ]]; then # SUBDOMAIN_INSTALL should be true. - echo -e "${RED}Subdomain configuration not found!${RESET}" + echo -e "Subdomain configuration not found!" exit 1 fi # Wait for the git push to finish. From b425a1d878a83c74baa296ffb261a767d7f0e1a2 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 11:57:08 -0600 Subject: [PATCH 04/22] exclude node_modules from rsync playwright runs on the ci, not on the fixture --- .github/workflows/playwright.yml | 2 +- devops/scripts/setup-playwright-tests.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 94faa725..6b18ad0b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -400,7 +400,7 @@ jobs: terminus local:clone ${{ env.SITE_ID }} cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" echo "Copying latest changes and committing to the site." - rsync -a --exclude='.git' --exclude='status-*.txt' "${{ github.workspace }}/" . + rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${{ github.workspace }}/" . git add -A git commit -m "Update to latest commit: ${{ env.COMMIT_MSG }}" || true git push origin master || true diff --git a/devops/scripts/setup-playwright-tests.sh b/devops/scripts/setup-playwright-tests.sh index 623a6a65..68108c08 100755 --- a/devops/scripts/setup-playwright-tests.sh +++ b/devops/scripts/setup-playwright-tests.sh @@ -70,7 +70,7 @@ copy_pr_updates() { echo "Commit Message: ${commit_msg}" cd ~/pantheon-local-copies/"${site_id}" echo -e "${YELLOW}Copying latest changes and committing to the site.${RESET}" - rsync -a --exclude='.git' --exclude='status-*.txt' "${workspace}/" . + rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" ${workspace}/" . git add -A git commit -m "Update to latest commit: ${commit_msg}" || true git push origin master || true From 3f0e604e026660f10f897c5e9adeed260cad1fdc Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 13:49:58 -0600 Subject: [PATCH 05/22] add multisite config to the fixture site this shouldn't need to be done every time, so we check if multisite is true and add the config if it's not true --- .github/workflows/playwright.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 6b18ad0b..382c8325 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -399,6 +399,18 @@ jobs: echo "Clone the site locally and copy PR updates" terminus local:clone ${{ env.SITE_ID }} cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" + + if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true MULTISITE; then + echo "Multisite not configured yet..." + echo "Copying multisite application.php" + rm ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php + cp "${{ github.workspace }}/.github/fixtures/config/application.subdom.php" ~/pantheon-local-copies/${{ env.SITE_ID }}/config/ + mv ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.${type}.php" ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php + cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" + git add ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php + git commit -m "Set up ${type} multisite config" || true + fi + echo "Copying latest changes and committing to the site." rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${{ github.workspace }}/" . git add -A From 7405de377236d4104e678405598fe02dd4f8dfe5 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 13:53:01 -0600 Subject: [PATCH 06/22] fix quoting --- devops/scripts/setup-playwright-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devops/scripts/setup-playwright-tests.sh b/devops/scripts/setup-playwright-tests.sh index 68108c08..5aedad8d 100755 --- a/devops/scripts/setup-playwright-tests.sh +++ b/devops/scripts/setup-playwright-tests.sh @@ -70,7 +70,7 @@ copy_pr_updates() { echo "Commit Message: ${commit_msg}" cd ~/pantheon-local-copies/"${site_id}" echo -e "${YELLOW}Copying latest changes and committing to the site.${RESET}" - rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" ${workspace}/" . + rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${workspace}/" . git add -A git commit -m "Update to latest commit: ${commit_msg}" || true git push origin master || true From 90296bbcca747e0dbd7f19a54a3187b654dce7b1 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 14:08:53 -0600 Subject: [PATCH 07/22] remove lingering ${type} vars and stray quote --- .github/workflows/playwright.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 382c8325..4abb759a 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -405,10 +405,10 @@ jobs: echo "Copying multisite application.php" rm ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php cp "${{ github.workspace }}/.github/fixtures/config/application.subdom.php" ~/pantheon-local-copies/${{ env.SITE_ID }}/config/ - mv ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.${type}.php" ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php + mv ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.subdom.php ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" git add ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php - git commit -m "Set up ${type} multisite config" || true + git commit -m "Set up subdomain multisite config" || true fi echo "Copying latest changes and committing to the site." From 1619e06f9839176e7cd44861a45b3e93c5fddbbe Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 14:17:48 -0600 Subject: [PATCH 08/22] don't run playwright tests if files we don't care about were affected --- .github/workflows/playwright.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 4abb759a..61a429e7 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -1,6 +1,21 @@ name: WordPress Composer Playwright Tests on: pull_request: + paths-ignore: + - '.github/workflows/ci.yml' + - '.github/workflows/composer-diff.yml' + - '.github/workflows/phpcbf.yml' + - '.github/workflows/sage-test.yml' + - '.github/workflows/sync-default.yml' + - '.github/tests/*.bats' + - 'private/scripts/**' + - 'docs/**' + - '*.md' + - 'phpcs.yml' + - 'wp-cli.yml' + - '.lando.upstream.yml' + - 'CODEOWNERS' + - '.editorconfig' types: - opened - reopened From 3312f0d28aac0bacba2da2fae29137f3298f7488 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 11:39:50 -0600 Subject: [PATCH 09/22] remove color tags From fe79af5a2cb3ce46c10ea1a4997342b32e71e7a4 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 11:39:14 -0600 Subject: [PATCH 10/22] don't save in a variable Co-authored-by: Phil Tyler --- .github/workflows/playwright.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 61a429e7..d1992814 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -439,9 +439,7 @@ jobs: exit 1 fi # Check SUBDOMAIN_INSTALL value - SUBDOMAIN_INSTALL=$(terminus wp "${{ env.SITE_ID }}".dev -- config get SUBDOMAIN_INSTALL) - if [[ "${SUBDOMAIN_INSTALL}" != "1" ]]; then - # SUBDOMAIN_INSTALL should be true. + if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true SUBDOMAIN_INSTALL; then echo -e "Subdomain configuration not found!" exit 1 fi From f8ae367c894f72f564784edee7755d1e616f6d6e Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 11:57:08 -0600 Subject: [PATCH 11/22] exclude node_modules from rsync playwright runs on the ci, not on the fixture --- devops/scripts/setup-playwright-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devops/scripts/setup-playwright-tests.sh b/devops/scripts/setup-playwright-tests.sh index 5aedad8d..68108c08 100755 --- a/devops/scripts/setup-playwright-tests.sh +++ b/devops/scripts/setup-playwright-tests.sh @@ -70,7 +70,7 @@ copy_pr_updates() { echo "Commit Message: ${commit_msg}" cd ~/pantheon-local-copies/"${site_id}" echo -e "${YELLOW}Copying latest changes and committing to the site.${RESET}" - rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${workspace}/" . + rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" ${workspace}/" . git add -A git commit -m "Update to latest commit: ${commit_msg}" || true git push origin master || true From 47e8d920c6c5090d3ce69a300077e0ceee1c8979 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 13:53:01 -0600 Subject: [PATCH 12/22] fix quoting --- devops/scripts/setup-playwright-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devops/scripts/setup-playwright-tests.sh b/devops/scripts/setup-playwright-tests.sh index 68108c08..5aedad8d 100755 --- a/devops/scripts/setup-playwright-tests.sh +++ b/devops/scripts/setup-playwright-tests.sh @@ -70,7 +70,7 @@ copy_pr_updates() { echo "Commit Message: ${commit_msg}" cd ~/pantheon-local-copies/"${site_id}" echo -e "${YELLOW}Copying latest changes and committing to the site.${RESET}" - rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" ${workspace}/" . + rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${workspace}/" . git add -A git commit -m "Update to latest commit: ${commit_msg}" || true git push origin master || true From 3f4d2992a7432c4eea78504ff53b55590196fe5b Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 14:08:53 -0600 Subject: [PATCH 13/22] remove lingering ${type} vars and stray quote From dffdcfbb3a3a288705d13b2347319bd811c63890 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 14:17:48 -0600 Subject: [PATCH 14/22] don't run playwright tests if files we don't care about were affected From 2899f3653629b9afa2f2150cb001ba86d0b6bf4f Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 15:13:07 -0600 Subject: [PATCH 15/22] move the wait to earlier we can't check the config if it hasn't finished being updated --- .github/workflows/playwright.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d1992814..988afbee 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -432,6 +432,9 @@ jobs: git commit -m "Update to latest commit: ${{ env.COMMIT_MSG }}" || true git push origin master || true + # Wait for the git push to finish. + terminus workflow:wait "${{ env.SITE_ID }}".dev + echo "Checking WordPress install status" terminus wp "${{ env.SITE_ID }}".dev -- cli info if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true MULTISITE; then @@ -443,8 +446,6 @@ jobs: echo -e "Subdomain configuration not found!" exit 1 fi - # Wait for the git push to finish. - terminus workflow:wait "${{ env.SITE_ID }}".dev - name: Run Playwright tests env: SITE_NAME: ${{ env.SITE_NAME }} From 60c3da83a0aaadcd6ce2331fa8f6870a5e8f5433 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 15:46:58 -0600 Subject: [PATCH 16/22] give up on the multisite checking we should know it already is multisite so we'll just check that the domains exist --- .github/workflows/playwright.yml | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 988afbee..e78c1960 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -415,17 +415,6 @@ jobs: terminus local:clone ${{ env.SITE_ID }} cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" - if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true MULTISITE; then - echo "Multisite not configured yet..." - echo "Copying multisite application.php" - rm ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php - cp "${{ github.workspace }}/.github/fixtures/config/application.subdom.php" ~/pantheon-local-copies/${{ env.SITE_ID }}/config/ - mv ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.subdom.php ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php - cd ~/pantheon-local-copies/"${{ env.SITE_ID }}" - git add ~/pantheon-local-copies/${{ env.SITE_ID }}/config/application.php - git commit -m "Set up subdomain multisite config" || true - fi - echo "Copying latest changes and committing to the site." rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${{ github.workspace }}/" . git add -A @@ -437,15 +426,15 @@ jobs: echo "Checking WordPress install status" terminus wp "${{ env.SITE_ID }}".dev -- cli info - if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true MULTISITE; then - echo -e "Multisite not found!" + + # Run curl checks against the site URLs to ensure the main site and the subdomain site exist. + echo "Checking site URLs" + SITE_URL_TEST=$(curl -s -o /dev/null -w "%{http_code}" ${{ env.SITE_URL }}) + SUBDOMAIN_URL_TEST=$(curl -s -o /dev/null -w "%{http_code}" ${{ env.SUBDOMAIN_URL }}) + if [ $SITE_URL_TEST -ne 200 ] || [ $SUBDOMAIN_URL_TEST -ne 200 ]; then + echo "One or more site URLs are not returning a 200 status code. Exiting." exit 1 fi - # Check SUBDOMAIN_INSTALL value - if ! terminus wp "${{ env.SITE_ID }}".dev -- config is-true SUBDOMAIN_INSTALL; then - echo -e "Subdomain configuration not found!" - exit 1 - fi - name: Run Playwright tests env: SITE_NAME: ${{ env.SITE_NAME }} From fc08498f48772fb81cb654676533e72af1ef0c33 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 16:14:50 -0600 Subject: [PATCH 17/22] install graphql as part of the workflow --- .github/workflows/playwright.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index e78c1960..31ef1c59 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -417,6 +417,10 @@ jobs: echo "Copying latest changes and committing to the site." rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${{ github.workspace }}/" . + + echo "Installing wp-graphql..." + composer require wp-graphql/wp-graphql + git add -A git commit -m "Update to latest commit: ${{ env.COMMIT_MSG }}" || true git push origin master || true @@ -427,6 +431,9 @@ jobs: echo "Checking WordPress install status" terminus wp "${{ env.SITE_ID }}".dev -- cli info + # Activte WP-GraphQL plugin + terminus wp "${{ env.SITE_ID }}".dev -- plugin activate wp-graphql + # Run curl checks against the site URLs to ensure the main site and the subdomain site exist. echo "Checking site URLs" SITE_URL_TEST=$(curl -s -o /dev/null -w "%{http_code}" ${{ env.SITE_URL }}) From 38c9386de50724861b15b99397407c0fd9375a47 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 16:22:01 -0600 Subject: [PATCH 18/22] clear ache after installing graphql --- .github/workflows/playwright.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 31ef1c59..dac42600 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -433,6 +433,7 @@ jobs: # Activte WP-GraphQL plugin terminus wp "${{ env.SITE_ID }}".dev -- plugin activate wp-graphql + terminus env:clear-cache "${{ env.SITE_ID }}".dev # Run curl checks against the site URLs to ensure the main site and the subdomain site exist. echo "Checking site URLs" From 17d4860479bf549c8906abc45b5c0a4199226206 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 16:33:04 -0600 Subject: [PATCH 19/22] break the subdomain sites up so we can pass different values in --- .github/workflows/playwright.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index dac42600..d9099541 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -443,13 +443,13 @@ jobs: echo "One or more site URLs are not returning a 200 status code. Exiting." exit 1 fi - - name: Run Playwright tests + - name: Run Playwright tests on main site env: SITE_NAME: ${{ env.SITE_NAME }} SITE_URL: ${{ env.SITE_URL }} - run: | - npm run test .github/tests/wpcm.spec.ts - SITE_NAME=Foo - SITE_URL=${{ env.SUBDOMAIN_URL }} - echo "Running Playwright tests on WordPress Subdomain subsite" - npm run test .github/tests/wpcm.spec.ts + run: npm run test .github/tests/wpcm.spec.ts + - name: Run Playwright tests on subdomain site + env: + SITE_NAME: Foo + SITE_URL: ${{ env.SUBDOMAIN_URL }} + run: npm run test .github/tests/wpcm.spec.ts From 46aaa50e7b4b9c705c6e84d0a3de415d27b11721 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 16:47:32 -0600 Subject: [PATCH 20/22] allow the graphql endpoint to be passed we can use this to fix the subdirectory test, too, but later --- .github/tests/wpcm.spec.ts | 4 ++-- .github/workflows/playwright.yml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/tests/wpcm.spec.ts b/.github/tests/wpcm.spec.ts index 573fa177..daa4d933 100644 --- a/.github/tests/wpcm.spec.ts +++ b/.github/tests/wpcm.spec.ts @@ -3,6 +3,7 @@ import { test, expect } from "@playwright/test"; const exampleArticle = "Hello world!"; const siteTitle = process.env.SITE_NAME || "WPCM Playwright Tests"; const siteUrl = process.env.SITE_URL || "https://dev-wpcm-playwright-tests.pantheonsite.io"; +let graphqlEndpoint = process.env.GRAPHQL_ENDPOINT || `${siteUrl}/wp/graphql`; test("homepage loads and contains example content", async ({ page }) => { await page.goto(siteUrl); @@ -41,8 +42,7 @@ test("validate core resource URLs", async ({ request }) => { }); test("graphql is able to access hello world post", async ({ request }) => { - let graphqlEndpoint = `${siteUrl}/wp/graphql`; - let apiRoot = await request.get(`${siteUrl}/wp/graphql`); + let apiRoot = await request.get(graphqlEndpoint); // If the above request doesn't resolve, it's because we're on a subsite where the path is ${siteUrl}/graphql -- similar to the rest api. if (!apiRoot.ok()) { graphqlEndpoint = `${siteUrl}/graphql`; diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index d9099541..b739cd30 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -447,9 +447,11 @@ jobs: env: SITE_NAME: ${{ env.SITE_NAME }} SITE_URL: ${{ env.SITE_URL }} + GRAPHQL_ENDPOINT: ${{ env.SITE_URL }}/wp/graphql run: npm run test .github/tests/wpcm.spec.ts - name: Run Playwright tests on subdomain site env: SITE_NAME: Foo SITE_URL: ${{ env.SUBDOMAIN_URL }} + GRAPHQL_ENDPOINT: ${{ env.SUBDOMAIN_URL }}/wp/graphql run: npm run test .github/tests/wpcm.spec.ts From 22c30220ea06334ecd86adb409141908668b5602 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Wed, 31 Jul 2024 17:03:22 -0600 Subject: [PATCH 21/22] copy the application.php for subdom this is getting reset, too, for some reason --- .github/workflows/playwright.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index b739cd30..7c74a688 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -417,15 +417,21 @@ jobs: echo "Copying latest changes and committing to the site." rsync -a --exclude='.git' --exclude='status-*.txt' --exclude="node_modules" "${{ github.workspace }}/" . + git add -A + git commit -m "Update to latest commit: ${{ env.COMMIT_MSG }}" || true echo "Installing wp-graphql..." composer require wp-graphql/wp-graphql + git add composer.json composer.lock + git commit -m "Add WP-GraphQL plugin" || true - git add -A - git commit -m "Update to latest commit: ${{ env.COMMIT_MSG }}" || true - git push origin master || true + echo "Copying the subdomain multisite config/application.php file..." + cp -f "${{ github.workspace }}/.github/fixtures/config/application.subdom.php" config/application.php + git add config/application.php + git commit -m "Add subdomain multisite config" || true - # Wait for the git push to finish. + # Push and wait for the git push to finish. + git push origin master || true terminus workflow:wait "${{ env.SITE_ID }}".dev echo "Checking WordPress install status" From 4e9d82788b3d85c2f8ef21647414748c57c36fad Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 1 Aug 2024 14:38:37 -0600 Subject: [PATCH 22/22] add more debugging info to failure output Co-authored-by: Phil Tyler --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 7c74a688..bde19cb7 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -447,6 +447,8 @@ jobs: SUBDOMAIN_URL_TEST=$(curl -s -o /dev/null -w "%{http_code}" ${{ env.SUBDOMAIN_URL }}) if [ $SITE_URL_TEST -ne 200 ] || [ $SUBDOMAIN_URL_TEST -ne 200 ]; then echo "One or more site URLs are not returning a 200 status code. Exiting." + echo "${{ env.SITE_URL }} - ${SITE_URL_TEST}" + echo "${{ env.SUBDOMAIN_URL }} - ${SUBDOMAIN_URL_TEST}" exit 1 fi - name: Run Playwright tests on main site