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
Merged

PMCS-5353 - Update QAT tests #15

merged 14 commits into from
Jan 23, 2023

Conversation

rnagatsukapmc
Copy link
Contributor

@rnagatsukapmc rnagatsukapmc commented Jan 20, 2023

This PR updates GH actions for QAT tests

Summary

  • Works the same / similar as how it worked in BitBucket
  • Runs qat tests only when npm run qat is available in repo
  • Can pass optional inputs - SITE_URL and THEME_NAME
    • If these are passed, it waits to run tests until pmcqa gets updated with new commit

Sample run (for sourcingjournal) - Raw log

https://github.com/penske-media-corp/pmc-sourcingjournal-2021/actions/runs/3969993790/jobs/6805188785

Screen Shot 2023-01-20 at 11 20 38 AM

Steps:

  1. Prepare environment
    • uses penske-media-corp/github-action-wordpress-test-setup@main with nodejs enabled
  2. Check QAT Script and Feature Branch
    • Checks if npm run qa:debug exists in package.json
    • Checks if it's a feature branch (e.g. feature/pmcs-5353)
    • Sets RUN_QAT=true or RUN_QAT=false in env. The rest of steps are skipped if its value is false. (it won't run qat tests)
  3. Check PMCQA
    • Blocks until pmcqa gets updated with new commit
  4. Install Playwright
  5. Run Playwright tests
    • Runs qat tests

Bash script used for BitBucket & SJ

(I used and converted this code to GH actions)

#!/bin/bash

# Define site specific variables
export SITE_URL="sourcingjournal-2021.pmcqa.com"
export THEME_NAME="pmc-sourcingjournal-2021"

if [[ $BITBUCKET_BRANCH =~ 'feature/' ]]; then
  export FEATURE_NAME=`echo $BITBUCKET_BRANCH | sed -e 's/feature\/\(.*\)/\1/' | tr '[:upper:]' '[:lower:]'`
  export ENVIRONMENT_URL="https://${FEATURE_NAME}.${SITE_URL}"
  export HASH_URL="${ENVIRONMENT_URL}/wp-content-vipgo-sites/${FEATURE_NAME}/themes/vip/${THEME_NAME}/version-hash"

  # Ensure that the code has been deployed to PMCQA first.
  HASH=`curl --insecure $HASH_URL`
  echo "PMCQA environment version: ${HASH}"
  echo "This commit: ${BITBUCKET_COMMIT}"
  until [[ $HASH == $BITBUCKET_COMMIT ]]; do
      echo -n "Waiting for Jenkins Deployment ... \n"
      HASH=`curl --insecure $HASH_URL`
      sleep 5
  done

  # Install dependencies
  npm ci

  # Run QA tests
  xvfb-run npm run qat:debug
else
  echo "Not a feature branch. Skipping Playwright tests."
fi

@rnagatsukapmc rnagatsukapmc requested a review from a team as a code owner January 20, 2023 19:31
ethitter
ethitter previously approved these changes Jan 20, 2023
Copy link
Member

@ethitter ethitter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

jamesmehorter
jamesmehorter previously approved these changes Jan 20, 2023
Copy link

@jamesmehorter jamesmehorter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!! 👏

.github/workflows/qat.yml Show resolved Hide resolved
.github/workflows/qat.yml Outdated Show resolved Hide resolved
Comment on lines 72 to 73
nvm install
nvm use

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick (install will install and use, or just use if it's already installed)

Suggested change
nvm install
nvm use
nvm install

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.github/workflows/qat.yml Outdated Show resolved Hide resolved
Copy link

@jamesmehorter jamesmehorter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!

@rnagatsukapmc rnagatsukapmc merged commit 14e7d19 into main Jan 23, 2023
@rnagatsukapmc rnagatsukapmc deleted the feature/PMCS-5353-qat branch January 23, 2023 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants