Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Add Pomodoro to test matrix (#9) #38

Add Pomodoro to test matrix (#9)

Add Pomodoro to test matrix (#9) #38

Workflow file for this run

name: Lint and Test
on:
push:
branches:
- main
pull_request:
jobs:
lint-js:
name: JS Lints
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint JS
run: npm run lint
performance-tests:
name: 'Performance Tests (trunk)'
runs-on: ubuntu-latest
env:
WP_ARTIFACTS_PATH: ${{ github.workspace }}/artifacts
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm
- name: Install dependencies
run: npm ci
- name: Configure WordPress version
run: |
echo "{\"core\":\"WordPress/WordPress#master\"}" >> .wp-env.override.json
- name: Install WordPress
run: |
chmod -R 767 ./ # TODO: Possibly integrate in wp-env
npm run wp-env start
- name: Update permalink structure
run: |
npm run wp-env run tests-cli wp rewrite structure '/%postname%/' -- --hard
- name: Import mock data
run: |
npm run wp-env run tests-cli curl https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml -- --output /tmp/themeunittestdata.wordpress.xml
npm run wp-env run tests-cli wp import /tmp/themeunittestdata.wordpress.xml -- --authors=create
# Ensure the wp-content/languages folder exists and is writable.
# See https://github.com/WordPress/gutenberg/issues/22515
# and https://github.com/WordPress/gutenberg/tree/trunk/packages/env#installing-a-plugin-or-theme-on-the-development-instance
- name: Install languages
run: |
WP_ENV_DIR=$(npm run wp-env install-path --silent 2>&1 | head -1)
cd $WP_ENV_DIR
mkdir -p tests-WordPress/wp-content/languages tests-WordPress/wp-content/upgrade
chmod -R 767 tests-WordPress/wp-content/languages tests-WordPress/wp-content/upgrade
docker-compose run --rm -u $(id -u) -e HOME=/tmp tests-cli wp language core install de_DE
docker-compose run --rm -u $(id -u) -e HOME=/tmp tests-cli wp language plugin install de_DE --all
docker-compose run --rm -u $(id -u) -e HOME=/tmp tests-cli wp language theme update --all
docker-compose run --rm -u $(id -u) -e HOME=/tmp tests-cli wp language theme install de_DE --all
docker-compose run --rm -u $(id -u) -e HOME=/tmp tests-cli wp language theme update --all
cd -
- name: Run tests
run: |
npm run test:performance
mv ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json ${{ runner.temp }}/results_after.json
- name: Check out base commit
run: |
if [[ -z "$BASE_REF" ]]; then
git fetch -n origin $BASE_SHA
git reset --hard $BASE_SHA
else
git fetch -n origin $BASE_REF
git reset --hard $BASE_SHA
fi
env:
BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.ref || '' }}
BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
# Run tests without causing job to fail if they don't pass (e.g. because of env issues).
- name: Run tests for base
run: |
npm run test:performance || true
if [ -f "{{ env.WP_ARTIFACTS_PATH }}/performance-results.json" ]; then
mv ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json ${{ runner.temp }}/results_before.json
fi;
- name: Reset to original commit
run: |
git reset --hard $GITHUB_SHA
- name: Compare results with base
run: |
if [ -f "${{ runner.temp }}/results_before.json" ]; then
node tests/performance/cli/results.js ${{ runner.temp }}/results_after.json ${{ runner.temp }}/results_before.json
else
node tests/performance/cli/results.js ${{ runner.temp }}/results_after.json
fi;
- name: Check if a comment was already made
id: find-comment
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1
if: >
github.event.pull_request.number &&
github.event.pull_request.head.repo.fork == false
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: swissspidy
body-includes: Performance test results for
- name: Comment on PR with test results
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa
if: >
github.event.pull_request.number &&
github.event.pull_request.head.repo.fork == false
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body-path: ${{ env.WP_ARTIFACTS_PATH }}/performance-results.md
token: ${{ secrets.PR_COMMENT_TOKEN }}
- name: Add workflow summary
run: |
cat ${{ env.WP_ARTIFACTS_PATH }}/performance-results.md >> $GITHUB_STEP_SUMMARY
- name: Archive performance results
if: success()
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
with:
name: performance-results
path: ${{ env.WP_ARTIFACTS_PATH }}/performance-results.json
- name: Archive debug artifacts (screenshots, HTML snapshots)
uses: actions/upload-artifact@v3
if: failure()
with:
name: failures-artifacts
path: artifacts
if-no-files-found: ignore