-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/npm_and_yarn/semver-5.7.2
- Loading branch information
Showing
12 changed files
with
248 additions
and
130 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
name: Test / E2E Cypress Job RC2 | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
browser: | ||
required: false | ||
type: string | ||
default: chrome | ||
theme: | ||
required: false | ||
type: string | ||
wpVersion: | ||
required: false | ||
type: string | ||
default: "" | ||
phpVersion: | ||
required: false | ||
type: string | ||
default: "8.2" | ||
secrets: | ||
record-key: | ||
description: 'Record key for Cypress Dashboard' | ||
required: false | ||
|
||
jobs: | ||
test_cypress_e2e: | ||
name: E2E Test | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
spec: | ||
- accordion.cypress.js | ||
- alert.cypress.js | ||
- author.cypress.js | ||
- click-to-tweet.cypress.js | ||
- counter.cypress.js | ||
- dynamic-separator.cypress.js | ||
- event-item.cypress.js | ||
- events.cypress.js | ||
- faq.cypress.js | ||
- feature.cypress.js | ||
- features.cypress.js | ||
- food-item.cypress.js | ||
- food-and-drinks.cypress.js | ||
- form.cypress.js | ||
- gallery-carousel.cypress.js | ||
- gallery-collage.cypress.js | ||
- gallery-masonry.cypress.js | ||
- gallery-offset.cypress.js | ||
- gallery-stacked.cypress.js | ||
- gif.cypress.js | ||
- gist.cypress.js | ||
- hero.cypress.js | ||
- highlight.cypress.js | ||
- icon.cypress.js | ||
- logos.cypress.js | ||
- map.cypress.js | ||
- media-card.cypress.js | ||
- opentable.cypress.js | ||
- post-carousel.cypress.js | ||
- posts.cypress.js | ||
- pricing-table-item.cypress.js | ||
- pricing-table.cypress.js | ||
- column.cypress.js | ||
- row.cypress.js | ||
- service.cypress.js | ||
- services.cypress.js | ||
- shape-divider.cypress.js | ||
- social-profiles.cypress.js | ||
- modal.cypress.js | ||
- media-filter-control.cypress.js | ||
- coblocks-labs.cypress.js | ||
- layout-selector.cypress.js | ||
- lightbox-controls-gallery.cypress.js | ||
- lightbox-controls-image.cypress.js | ||
- media-text-styles.cypress.js | ||
- padding-controls.cypress.js | ||
- settings-modal-control.cypress.js | ||
|
||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup wp-env | ||
uses: godaddy-wordpress/setup-wp-env@v1 | ||
with: | ||
core: ${{ inputs.wpVersion }} | ||
phpVersion: ${{ inputs.phpVersion }} | ||
plugins: '["."]' | ||
themes: '["https://downloads.wordpress.org/theme/go.zip"]' | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer install --prefer-dist --optimize-autoloader & | ||
yarn install --immutable | ||
- name: Build plugin | ||
run: | | ||
npx grunt build | ||
# moving the built directory to this location means no dev files in tests-container. | ||
mv ./build/coblocks $(wp-env install-path)/tests-wordpress-6.3-RC2/wp-content/plugins/ | ||
- name: Prepare Theme | ||
run: | | ||
if [ "${{ inputs.theme }}" = "https://downloads.wordpress.org/theme/go.zip" ]; then | ||
cd $(wp-env install-path)/go | ||
else | ||
cd $(wp-env install-path)/tests-wordpress-6.3-RC2/wp-content/themes/twentytwentythree | ||
fi | ||
mkdir -p coblocks/icons | ||
echo '<svg height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><circle class="inner-circle" cx="20" cy="20" r="8" stroke-width="8" stroke-dasharray="50.2655 50.2655" stroke-dashoffset="0"></circle></svg>' >> coblocks/icons/custom.svg | ||
- name: Prepare tests | ||
run: | | ||
WP_CORE_VERSION=$(wp-env run cli wp core version) | ||
echo "WP_CORE_VERSION=${WP_CORE_VERSION}" >> $GITHUB_ENV | ||
wp-env run tests-cli wp post generate --count=5 | ||
wp-env run cli wp post generate --count=5 | ||
wp-env run cli wp option update permalink_structure '/%postname%' | ||
if [ "${{ inputs.theme }}" = "https://downloads.wordpress.org/theme/go.zip" ]; then | ||
wp-env run tests-cli wp theme activate go | ||
fi | ||
# Only create a new post if running the migrated specs | ||
- name: Create post and get ID | ||
if: matrix.spec == 'alert.cypress.js' || matrix.spec == 'author.cypress.js' | ||
run: | | ||
# Generate application-password to use with WP REST API. | ||
app_password=$(wp-env run tests-cli wp user application-password create admin gha-password --porcelain) | ||
# Retrieve post content from fixture. | ||
post_content=$(cat .dev/tests/cypress/fixtures/${{matrix.spec}}.html) | ||
echo $post_content | ||
# Create a post using the REST API and parse the postId from the response. | ||
postId=$(curl -s -X POST 'http://localhost:8889/?rest_route=/wp/v2/posts' --data-urlencode "title=${{matrix.spec}}" --data-raw "content=$post_content" --data-urlencode "status=publish" --user "admin:$app_password"| jq '.id') | ||
# Save the postId to the output. | ||
echo "postId=$postId" >> $GITHUB_OUTPUT | ||
id: create-post | ||
|
||
# Only retrieve the post ID if running the first spec | ||
- name: Save post ID to file | ||
if: matrix.spec == 'alert.cypress.js' || matrix.spec == 'author.cypress.js' | ||
run: | | ||
path="$GITHUB_WORKSPACE/.dev/tests/cypress/fixtures/${{matrix.spec}}.json" | ||
touch "$path" | ||
echo "{\"${{matrix.spec}}\": \"$(echo "${{ steps.create-post.outputs.postId }}")\"}" > "$path" | ||
- name: Run tests | ||
run: | | ||
CYPRESS_SPEC=$(find ./src/* -name ${{ matrix.spec }} -type f) | ||
echo '{"wpUsername":"admin","wpPassword":"password","testURL":"http://localhost:8889"}' | jq . > cypress.env.json | ||
./node_modules/.bin/cypress verify | ||
./node_modules/.bin/cypress run --browser ${{ inputs.browser }} --spec $CYPRESS_SPEC | ||
- name: Upload failure video | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.spec }}-fail.mp4 | ||
path: ./.dev/tests/cypress/videos/${{ matrix.spec }}.mp4 | ||
retention-days: 1 | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,13 +34,12 @@ | |
"lint:php": "wp-env run tests-cli --env-cwd=/var/www/html 'composer run lint -d /var/www/html/wp-content/plugins/coblocks/'; #we use phpunit container because composer container only use php 8;", | ||
"lint:php:fix": "wp-env run tests-cli --env-cwd=/var/www/html 'composer run lint:fix -d /var/www/html/wp-content/plugins/coblocks/'; #we use phpunit container because composer container only use php 8;", | ||
"makepot": "./vendor/bin/wp i18n make-pot . --skip-audit --exclude=\".dev,.github,.wordpress-org,build,docs,dist,node_modules,vendor,wordpress\" --headers='{\"Last-Translator\":\"[email protected]\",\"Report-Msgid-Bugs-To\":\"https://github.com/godaddy-wordpress/coblocks/issues\"}' --file-comment=\"Copyright (c) $(date +'%Y') GoDaddy Operating Company, LLC. All Rights Reserved.\" languages/coblocks.pot && yarn run pot2json", | ||
"php:composer:install": "wp-env run wordpress 'composer install -d /var/www/html/wp-content/plugins/coblocks/'", | ||
"po2jed": "cd languages && find . -name '*.po' -execdir /bin/bash -c 'FROM=\"$0\" && TO=\"`basename $0 .po`-coblocks-editor.json\" && echo \"$FROM > $TO\" && po2json $FROM $TO -f jed' '{}' \\;", | ||
"po2mo": "cd languages && find . -name '*.po' -execdir /bin/bash -c 'FROM=\"$0\" && TO=\"`basename $0 .po`.mo\" && echo \"$FROM > $TO\" && msgfmt $FROM -o $TO' '{}' \\;", | ||
"postinstall": "yarn update:icon", | ||
"pot2json": "./vendor/bin/pot2json languages/coblocks.pot languages/coblocks.json", | ||
"prepare": "husky install .dev/husky", | ||
"setup": "yarn install && yarn run build && wp-env start && yarn php:composer:install", | ||
"setup": "yarn install && yarn run build && wp-env start", | ||
"start:debug": "DEBUG_MODE=on wp-scripts start --progress", | ||
"start": "wp-scripts start --progress", | ||
"test:a11y": "node .dev/tests/a11y/pa11y.js", | ||
|
Oops, something went wrong.