Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMCS-5353 - Update QAT tests #15

Merged
merged 14 commits into from
Jan 23, 2023
66 changes: 63 additions & 3 deletions .github/workflows/qat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ name: QAT

on:
workflow_call:
inputs:
SITE_URL:
default: ''
description: 'Site URL'
required: false
type: string
THEME_NAME:
default: ''
description: 'WP Theme'
required: false
type: string

secrets:
BITBUCKET_READ_ONLY_SSH_KEY:
required: true
Expand All @@ -16,10 +28,58 @@ jobs:
name: Playwright
runs-on: ubuntu-latest
timeout-minutes: 90
if: false
env:
FEATURE_BRANCH_NAME: $(echo "${{ github.head_ref || github.ref_name }}" | sed -e 's/feature\/\(.*\)/\1/' | tr '[:upper:]' '[:lower:]')
NPM_QAT_SCRIPT: "qat"
if: ${{ github.repository != 'penske-media-corp/github-workflows-wordpress' }}

steps:
- name: Prepare environment
uses: penske-media-corp/github-action-wordpress-test-setup@main
with:
bitbucket_read_only_ssh_key: "${{ secrets.BITBUCKET_READ_ONLY_SSH_KEY }}"
github_read_only_ssh_key: "${{ secrets.GITHUB_READ_ONLY_SSH_KEY }}"
nodejs: 1

- name: Check QAT Script and Feature Branch
run: |
has_qat=`jq -r '.scripts|to_entries[]|select(.key=="${{ env.NPM_QAT_SCRIPT }}")|.key' package.json 2>/dev/null | head -n 1 | wc -l`
if [ $has_qat -eq 1 ] && [[ "${{ github.head_ref || github.ref_name }}" =~ 'feature/' ]]; then
echo "RUN_QAT=true" >> $GITHUB_ENV
else
echo "Not a feature branch or qat script not found. Skipping Playwright tests."
echo "RUN_QAT=false" >> $GITHUB_ENV
fi

- name: Check PMCQA
if: ${{ env.RUN_QAT == 'true' }} && ${{ inputs.THEME_NAME != '' }} && ${{ inputs.SITE_URL != '' }}
timeout-minutes: 10
run: |
# `version-hash` is created by jenkins script when a branch is pushed
# https://github.com/penske-media-corp/pmc-jenkins-scripts/blob/8ee0244a8485b61cfa6d3f9af00f7e6a55ddb042/bin/push-pmcqa-repo.sh#L36-L38
hash_url="https://${{ env.FEATURE_BRANCH_NAME }}.${{ inputs.SITE_URL }}/wp-content-vipgo-sites/${{ env.FEATURE_BRANCH_NAME }}/themes/vip/${{ inputs.THEME_NAME }}/version-hash"
rnagatsukapmc marked this conversation as resolved.
Show resolved Hide resolved
echo "HASH_URL: $hash_url"
hash=`curl --insecure $hash_url`
until [[ $hash == ${{ github.event.pull_request.head.sha }} ]]; do
echo -n "Waiting for Jenkins Deployment ... \n"
hash=`curl --insecure $hash_url`
sleep 5
done

- name: Install Playwright
if: ${{ env.RUN_QAT == 'true' }}
run: |
. "$NVM_DIR/nvm.sh"

nvm install

# Playwright needs to be added in package.json as dependency
npm ci

- name: Run Playwright tests
if: ${{ env.RUN_QAT == 'true' }}
run: |
echo "Not implemented"
exit 0
if [ "${{ inputs.SITE_URL }}" != '' ]; then
export ENVIRONMENT_URL="https://${{ env.FEATURE_BRANCH_NAME }}.${{ inputs.SITE_URL }}"
fi
npm run ${{ env.NPM_QAT_SCRIPT }}