Update README-internal #155
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: WordPress Composer Playwright Tests | |
on: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- ready_for_review | |
permissions: | |
contents: write | |
actions: read | |
jobs: | |
playwright-single: | |
name: Single site | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Wait for status artifacts | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
max_attempts=10 | |
delay_seconds=30 | |
attempt=0 | |
success=0 | |
status=0 | |
echo "Checking for status artifacts..." | |
while [ $attempt -lt $max_attempts ]; do | |
# Attempt to download the artifacts. | |
gh run download -n status-8.1-${{ github.sha }} || true | |
gh run download -n status-8.2-${{ github.sha }} || true | |
gh run download -n status-8.3-${{ github.sha }} || true | |
if [ -f status-8.1-${{ github.sha }}.txt ] && [ -f status-8.2-${{ github.sha }}.txt ] && [ -f status-8.3-${{ github.sha }}.txt ]; then | |
success=1 | |
break | |
else | |
echo "Status files not found. Sleeping for $delay_seconds seconds..." | |
sleep $delay_seconds | |
fi | |
attempt=$(( attempt + 1 )) | |
done | |
if [ $success -eq 0 ]; then | |
echo "Timed out waiting for status artifacts." | |
exit 1 | |
fi | |
for file in status-*.txt; do | |
status=$(cat $file) | |
if [ $status -eq 1 ]; then | |
echo "status=$status" >> $GITHUB_ENV | |
exit 1 | |
fi | |
done | |
echo "Linting tests passed. Proceeding with Playwright tests. ✅" | |
echo "status=$status" >> $GITHUB_ENV | |
- name: Linting failed | |
if: env.status == '1' | |
run: | | |
echo "One or more jobs in a previous workflow failed. Exiting." | |
exit 1 | |
- name: Get last commit message | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
cd ${{ github.workspace }}/ | |
PR_NUMBER=$(echo ${{ github.event.pull_request.number }}) | |
COMMIT_MSG=$(gh pr view $PR_NUMBER --json commits --jq '.commits[-1] | "\(.messageHeadline) \(.messageBody)"') | |
# Remove newlines and carriage returns | |
CLEAN_COMMIT_MSG=$(echo "$COMMIT_MSG" | tr -d '\n' | tr -d '\r') | |
# Replace newlines and carriage returns with spaces | |
CLEAN_COMMIT_MSG=$(echo "$COMMIT_MSG" | tr '\n\r' ' ') | |
# Remove single quotes | |
CLEAN_COMMIT_MSG=$(echo "$CLEAN_COMMIT_MSG" | sed "s/'//g") | |
echo "Cleaned commit message: ${CLEAN_COMMIT_MSG}" | |
echo "COMMIT_MSG=${CLEAN_COMMIT_MSG}" >> $GITHUB_ENV | |
- name: Set up env variables | |
run: | | |
SITE_NAME="WordPress (Composer Managed) Single Site Test" | |
SITE_URL="https://dev-wpcm-playwright-tests.pantheonsite.io" | |
echo "Site name: $SITE_NAME" | |
echo "Site url: $SITE_URL" | |
echo "SITE_NAME=$SITE_NAME" >> $GITHUB_ENV | |
echo "SITE_URL=$SITE_URL" >> $GITHUB_ENV | |
- name: Install SSH keys | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Validate Pantheon Host Key | |
shell: bash | |
run: | | |
echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config | |
echo "Host *.drush.in PubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config | |
echo "StrictHostKeyChecking no" >> ~/.ssh/config | |
- name: Get latest Terminus release | |
uses: pantheon-systems/terminus-github-actions@v1 | |
with: | |
pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }} | |
- name: Install dependencies | |
run: | | |
echo "Install Composer dependencies" | |
composer update --no-progress --prefer-dist --optimize-autoloader | |
echo "Install NPM dependencies" | |
npm install | |
echo "Install Playwright Browsers" | |
npx playwright install --with-deps | |
- name: Setup Single Site Tests | |
env: | |
SITE_ID: wpcm-playwright-tests | |
SITE_NAME: ${{ env.SITE_NAME }} | |
SITE_URL: ${{ env.SITE_URL }} | |
TYPE: single | |
TERMINUS_TOKEN: ${{ secrets.TERMINUS_TOKEN }} | |
COMMIT_MSG: ${{ env.COMMIT_MSG }} | |
WORKSPACE: ${{ github.workspace }} | |
run: bash ${{ github.workspace }}/devops/scripts/setup-playwright-tests.sh | |
- name: Run Playwright tests | |
env: | |
SITE_NAME: ${{ env.SITE_NAME }} | |
SITE_URL: ${{ env.SITE_URL }} | |
run: npm run test .github/tests/wpcm.spec.ts | |
- name: Delete Site | |
if: success() | |
shell: bash | |
run: terminus site:delete wpcm-playwright-tests -y | |
playwright-subdir: | |
name: Subdirectory multisite | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Wait for status artifacts | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
max_attempts=10 | |
delay_seconds=30 | |
attempt=0 | |
success=0 | |
status=0 | |
echo "Checking for status artifacts..." | |
while [ $attempt -lt $max_attempts ]; do | |
# Attempt to download the artifacts. | |
gh run download -n status-8.1-${{ github.sha }} || true | |
gh run download -n status-8.2-${{ github.sha }} || true | |
gh run download -n status-8.3-${{ github.sha }} || true | |
if [ -f status-8.1-${{ github.sha }}.txt ] && [ -f status-8.2-${{ github.sha }}.txt ] && [ -f status-8.3-${{ github.sha }}.txt ]; then | |
success=1 | |
break | |
else | |
echo "Status files not found. Sleeping for $delay_seconds seconds..." | |
sleep $delay_seconds | |
fi | |
attempt=$(( attempt + 1 )) | |
done | |
if [ $success -eq 0 ]; then | |
echo "Timed out waiting for status artifacts." | |
exit 1 | |
fi | |
for file in status-*.txt; do | |
status=$(cat $file) | |
if [ $status -eq 1 ]; then | |
echo "status=$status" >> $GITHUB_ENV | |
exit 1 | |
fi | |
done | |
echo "status=$status" >> $GITHUB_ENV | |
- name: Linting failed | |
if: env.status == '1' | |
run: | | |
echo "One or more jobs in a previous workflow failed. Exiting." | |
exit 1 | |
- name: Get last commit message | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
cd ${{ github.workspace }}/ | |
PR_NUMBER=$(echo ${{ github.event.pull_request.number }}) | |
COMMIT_MSG=$(gh pr view $PR_NUMBER --json commits --jq '.commits[-1] | "\(.messageHeadline) \(.messageBody)"') | |
# Remove newlines and carriage returns | |
CLEAN_COMMIT_MSG=$(echo "$COMMIT_MSG" | tr -d '\n' | tr -d '\r') | |
# Replace newlines and carriage returns with spaces | |
CLEAN_COMMIT_MSG=$(echo "$COMMIT_MSG" | tr '\n\r' ' ') | |
# Remove single quotes | |
CLEAN_COMMIT_MSG=$(echo "$CLEAN_COMMIT_MSG" | sed "s/'//g") | |
echo "Cleaned commit message: ${CLEAN_COMMIT_MSG}" | |
echo "COMMIT_MSG=${CLEAN_COMMIT_MSG}" >> $GITHUB_ENV | |
- name: Set up env variables | |
run: | | |
SITE_NAME="WordPress (Composer Managed) Subdirectory Multisite Test" | |
SITE_URL="https://dev-wpcm-subdir-playwright-tests.pantheonsite.io" | |
echo "Site name: $SITE_NAME" | |
echo "Site url: $SITE_URL" | |
echo "SITE_NAME=$SITE_NAME" >> $GITHUB_ENV | |
echo "SITE_URL=$SITE_URL" >> $GITHUB_ENV | |
- name: Install SSH keys | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Validate Pantheon Host Key | |
shell: bash | |
run: | | |
echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config | |
echo "Host *.drush.in PubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config | |
echo "StrictHostKeyChecking no" >> ~/.ssh/config | |
- name: Get latest Terminus release | |
uses: pantheon-systems/terminus-github-actions@v1 | |
with: | |
pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }} | |
- name: Install dependencies | |
run: | | |
echo "Install Composer dependencies" | |
composer update --no-progress --prefer-dist --optimize-autoloader | |
echo "Install NPM dependencies" | |
npm install | |
echo "Install Playwright Browsers" | |
npx playwright install --with-deps | |
- name: Setup Subdirectory Multisite Tests | |
env: | |
SITE_ID: wpcm-subdir-playwright-tests | |
SITE_NAME: ${{ env.SITE_NAME }} | |
SITE_URL: ${{ env.SITE_URL }} | |
TYPE: subdir | |
TERMINUS_TOKEN: ${{ secrets.TERMINUS_TOKEN }} | |
COMMIT_MSG: ${{ env.COMMIT_MSG }} | |
WORKSPACE: ${{ github.workspace }} | |
run: bash ${{ github.workspace }}/devops/scripts/setup-playwright-tests.sh | |
- name: Run Playwright tests | |
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.SITE_URL }}/foo | |
echo "Running Playwright tests on WordPress subdirectory subsite" | |
npm run test .github/tests/wpcm.spec.ts | |
- name: Delete Site | |
if: success() | |
shell: bash | |
run: terminus site:delete wpcm-subdir-playwright-tests -y | |
playwright-subdom: | |
name: Subdomain multisite | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Wait for status artifacts | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
max_attempts=10 | |
delay_seconds=30 | |
attempt=0 | |
success=0 | |
status=0 | |
echo "Checking for status artifacts..." | |
while [ $attempt -lt $max_attempts ]; do | |
# Attempt to download the artifacts. | |
gh run download -n status-8.1-${{ github.sha }} || true | |
gh run download -n status-8.2-${{ github.sha }} || true | |
gh run download -n status-8.3-${{ github.sha }} || true | |
if [ -f status-8.1-${{ github.sha }}.txt ] && [ -f status-8.2-${{ github.sha }}.txt ] && [ -f status-8.3-${{ github.sha }}.txt ]; then | |
success=1 | |
break | |
else | |
echo "Status files not found. Sleeping for $delay_seconds seconds..." | |
sleep $delay_seconds | |
fi | |
attempt=$(( attempt + 1 )) | |
done | |
if [ $success -eq 0 ]; then | |
echo "Timed out waiting for status artifacts." | |
exit 1 | |
fi | |
for file in status-*.txt; do | |
status=$(cat $file) | |
if [ $status -eq 1 ]; then | |
echo "status=$status" >> $GITHUB_ENV | |
exit 1 | |
fi | |
done | |
echo "status=$status" >> $GITHUB_ENV | |
- name: Linting failed | |
if: env.status == '1' | |
run: | | |
echo "One or more jobs in a previous workflow failed. Exiting." | |
exit 1 | |
- name: Get last commit message | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
cd ${{ github.workspace }}/ | |
PR_NUMBER=$(echo ${{ github.event.pull_request.number }}) | |
COMMIT_MSG=$(gh pr view $PR_NUMBER --json commits --jq '.commits[-1] | "\(.messageHeadline) \(.messageBody)"') | |
# Remove newlines and carriage returns | |
CLEAN_COMMIT_MSG=$(echo "$COMMIT_MSG" | tr -d '\n' | tr -d '\r') | |
# Replace newlines and carriage returns with spaces | |
CLEAN_COMMIT_MSG=$(echo "$COMMIT_MSG" | tr '\n\r' ' ') | |
# Remove single quotes | |
CLEAN_COMMIT_MSG=$(echo "$CLEAN_COMMIT_MSG" | sed "s/'//g") | |
echo "Cleaned commit message: ${CLEAN_COMMIT_MSG}" | |
echo "COMMIT_MSG=${CLEAN_COMMIT_MSG}" >> $GITHUB_ENV | |
- name: Set up env variables | |
run: | | |
SITE_NAME="WordPress (Composer Managed) Subdomain Multisite Test" | |
SITE_URL="https://dev-wpcm-subdom-playwright-tests.pantheonsite.io" | |
SUBDOMAIN_URL="https://foo.dev-wpcm-subdom-playwright-tests.pantheonsite.io" | |
echo "Site name: $SITE_NAME" | |
echo "Site url: $SITE_URL" | |
echo "Subdomain url: $SUBDOMAIN_URL" | |
echo "SITE_NAME=$SITE_NAME" >> $GITHUB_ENV | |
echo "SITE_URL=$SITE_URL" >> $GITHUB_ENV | |
echo "SUBDOMAIN_URL=$SUBDOMAIN_URL" >> $GITHUB_ENV | |
- name: Install SSH keys | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Validate Pantheon Host Key | |
shell: bash | |
run: | | |
echo "Host *.drush.in HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/config | |
echo "Host *.drush.in PubkeyAcceptedKeyTypes +ssh-rsa" >> ~/.ssh/config | |
echo "StrictHostKeyChecking no" >> ~/.ssh/config | |
- name: Get latest Terminus release | |
uses: pantheon-systems/terminus-github-actions@v1 | |
with: | |
pantheon-machine-token: ${{ secrets.TERMINUS_TOKEN }} | |
- name: Install dependencies | |
run: | | |
echo "Install Composer dependencies" | |
composer update --no-progress --prefer-dist --optimize-autoloader | |
echo "Install NPM dependencies" | |
npm install | |
echo "Install Playwright Browsers" | |
npx playwright install --with-deps | |
- name: Run Playwright tests | |
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 |