Skip to content

Commit

Permalink
Merge pull request swissspidy#9 from joemcgill/test/theme-choice
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Nov 1, 2023
2 parents 8ff16e3 + 7e86ae9 commit 13618c0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 77 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ on:
type: string
default: "trunk"
required: true
theme:
description: "Theme to test"
type: choice
options:
- twentytwentyone
- twentytwentythree
- twentytwentyfour
required: true

jobs:
benchmarks:
Expand Down Expand Up @@ -89,44 +97,36 @@ jobs:
(cd old && wp-env run tests-cli wp plugin deactivate wordpress-importer)
(cd new && wp-env run tests-cli wp plugin deactivate wordpress-importer)
- name: Install block theme
run: |
(cd old && wp-env run tests-cli wp theme activate twentytwentythree)
(cd new && wp-env run tests-cli wp theme activate twentytwentythree)
- name: Benchmark Web Vitals
working-directory: wpp-research
run: |
npm run research --silent -- benchmark-web-vitals -u http://localhost:8881/ -n 100 -p -o csv > before.csv
npm run research --silent -- benchmark-web-vitals -u http://localhost:8891/ -n 100 -p -o csv > after.csv
node ../scripts/results.js "Web Vitals (Block Theme)" before.csv after.csv > summary.md
cat summary.md >> $GITHUB_STEP_SUMMARY
- name: Benchmark Server-Timing
working-directory: wpp-research
- name: Post Debugging Info
run: |
npm run research --silent -- benchmark-server-timing -u http://localhost:8881/ -n 100 -p -o csv > before.csv
npm run research --silent -- benchmark-server-timing -u http://localhost:8891/ -n 100 -p -o csv > after.csv
node ../scripts/results.js "Server-Timing (Block Theme)" before.csv after.csv > summary.md
cat summary.md >> $GITHUB_STEP_SUMMARY
echo "Old version – Theme info"
(cd old && npm run wp-env run tests-cli wp theme list)
echo "New version – Theme info"
(cd new && npm run wp-env run tests-cli wp theme list)
- name: Install classic theme
- name: Install theme
run: |
(cd old && wp-env run tests-cli wp theme activate twentytwentyone)
(cd new && wp-env run tests-cli wp theme activate twentytwentyone)
(cd old && wp-env run tests-cli wp theme activate $THEME)
(cd new && wp-env run tests-cli wp theme activate $THEME)
env:
THEME: ${{ inputs.theme }}

- name: Benchmark Web Vitals
working-directory: wpp-research
run: |
npm run research --silent -- benchmark-web-vitals -u http://localhost:8881/ -n 100 -p -o csv > before.csv
npm run research --silent -- benchmark-web-vitals -u http://localhost:8891/ -n 100 -p -o csv > after.csv
node ../scripts/results.js "Web Vitals (Classic Theme)" before.csv after.csv > summary.md
node ../scripts/results.js "Web Vitals ($THEME)" before.csv after.csv > summary.md
cat summary.md >> $GITHUB_STEP_SUMMARY
env:
THEME: ${{ inputs.theme }}

- name: Benchmark Server-Timing
working-directory: wpp-research
run: |
npm run research --silent -- benchmark-server-timing -u http://localhost:8881/ -n 100 -p -o csv > before.csv
npm run research --silent -- benchmark-server-timing -u http://localhost:8891/ -n 100 -p -o csv > after.csv
node ../scripts/results.js "Server-Timing (Classic Theme)" before.csv after.csv > summary.md
node ../scripts/results.js "Server-Timing ($THEME)" before.csv after.csv > summary.md
cat summary.md >> $GITHUB_STEP_SUMMARY
env:
THEME: ${{ inputs.theme }}
8 changes: 5 additions & 3 deletions new/.wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
],
"themes": [
"https://downloads.wordpress.org/theme/twentytwentyone.zip",
"https://downloads.wordpress.org/theme/twentytwentythree.zip"
"https://downloads.wordpress.org/theme/twentytwentythree.zip",
"WordPress/twentytwentyfour"
],
"mappings": {
"wp-cli.yml": "../shared/wp-cli.yml",
Expand All @@ -17,6 +18,7 @@
"config": {
"WP_DEBUG": false,
"SCRIPT_DEBUG": false,
"SAVEQUERIES": false
"SAVEQUERIES": false,
"DISABLE_WP_CRON": true
}
}
}
8 changes: 5 additions & 3 deletions old/.wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
],
"themes": [
"https://downloads.wordpress.org/theme/twentytwentyone.zip",
"https://downloads.wordpress.org/theme/twentytwentythree.zip"
"https://downloads.wordpress.org/theme/twentytwentythree.zip",
"WordPress/twentytwentyfour"
],
"mappings": {
"wp-cli.yml": "../shared/wp-cli.yml",
Expand All @@ -17,6 +18,7 @@
"config": {
"WP_DEBUG": false,
"SCRIPT_DEBUG": false,
"SAVEQUERIES": false
"SAVEQUERIES": false,
"DISABLE_WP_CRON": true
}
}
}
66 changes: 19 additions & 47 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ fi

OLD_VERSION=${1-latest}
NEW_VERSION=${2-trunk}
SKIP_INIT=${3-false}
OUTPUT=${4-markdown}
SKIP_FORMATTING=${5-false}
PRINT_TO_FILES=${6-false}
THEME=${3-twentytwentyone}
SKIP_INIT=${4-false}
OUTPUT=${5-markdown}
SKIP_FORMATTING=${6-false}
PRINT_TO_FILES=${7-false}

# Configure WordPress versions

Expand Down Expand Up @@ -89,46 +90,17 @@ else

fi

# Install block theme
# Install theme

(cd old && npm run wp-env --silent run tests-cli wp theme activate twentytwentythree)
(cd new && npm run wp-env --silent run tests-cli wp theme activate twentytwentythree)
(cd old && npm run wp-env --silent run tests-cli wp theme activate $THEME)
(cd new && npm run wp-env --silent run tests-cli wp theme activate $THEME)

cd ./wpp-research || exit

# Benchmark Web Vitals
## Post debuging info.
echo "Old version – Theme info"
(cd old && npm run wp-env run tests-cli wp theme list)

npm run research --silent -- benchmark-web-vitals -u http://localhost:8881/ -n 20 -p -o csv > before.csv
npm run research --silent -- benchmark-web-vitals -u http://localhost:8891/ -n 20 -p -o csv > after.csv
if [[ $PRINT_TO_FILES == 'true' ]]; then
if [[ $OUTPUT == 'csv' ]]; then
node ../scripts/results.js "Web Vitals (Block Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > web-vitals-block-theme.csv
else
node ../scripts/results.js "Web Vitals (Block Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > web-vitals-block-theme.md
fi
else
node ../scripts/results.js "Web Vitals (Block Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING
fi

# Benchmark Server-Timing

npm run research --silent -- benchmark-server-timing -u http://localhost:8881/ -n 100 -p -o csv > before.csv
npm run research --silent -- benchmark-server-timing -u http://localhost:8891/ -n 100 -p -o csv > after.csv
if [[ $PRINT_TO_FILES == 'true' ]]; then
if [[ $OUTPUT == 'csv' ]]; then
node ../scripts/results.js "Server-Timing (Block Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > server-timing-block-theme.csv
else
node ../scripts/results.js "Server-Timing (Block Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > server-timing-block-theme.md
fi
else
node ../scripts/results.js "Server-Timing (Block Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING
fi

# Install classic theme

cd ../
(cd old && npm run wp-env --silent run tests-cli wp theme activate twentytwentyone)
(cd new && npm run wp-env --silent run tests-cli wp theme activate twentytwentyone)
echo "New version – Theme info"
(cd new && npm run wp-env run tests-cli wp theme list)

cd ./wpp-research || exit

Expand All @@ -138,12 +110,12 @@ npm run research --silent -- benchmark-web-vitals -u http://localhost:8881/ -n 2
npm run research --silent -- benchmark-web-vitals -u http://localhost:8891/ -n 20 -p -o csv > after.csv
if [[ $PRINT_TO_FILES == 'true' ]]; then
if [[ $OUTPUT == 'csv' ]]; then
node ../scripts/results.js "Web Vitals (Classic Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > web-vitals-classic-theme.csv
node ../scripts/results.js "Web Vitals ($THEME)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > web-vitals-$THEME.csv
else
node ../scripts/results.js "Web Vitals (Classic Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > web-vitals-classic-theme.md
node ../scripts/results.js "Web Vitals ($THEME)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > web-vitals-$THEME.md
fi
else
node ../scripts/results.js "Web Vitals (Classic Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING
node ../scripts/results.js "Web Vitals ($THEME)" before.csv after.csv $OUTPUT $SKIP_FORMATTING
fi

# Benchmark Server-Timing
Expand All @@ -152,12 +124,12 @@ npm run research --silent -- benchmark-server-timing -u http://localhost:8881/
npm run research --silent -- benchmark-server-timing -u http://localhost:8891/ -n 100 -p -o csv > after.csv
if [[ $PRINT_TO_FILES == 'true' ]]; then
if [[ $OUTPUT == 'csv' ]]; then
node ../scripts/results.js "Server-Timing (Classic Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > server-timing-classic-theme.csv
node ../scripts/results.js "Server-Timing ($THEME)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > server-timing-$THEME.csv
else
node ../scripts/results.js "Server-Timing (Classic Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > server-timing-classic-theme.md
node ../scripts/results.js "Server-Timing ($THEME)" before.csv after.csv $OUTPUT $SKIP_FORMATTING > server-timing-$THEME.md
fi
else
node ../scripts/results.js "Server-Timing (Classic Theme)" before.csv after.csv $OUTPUT $SKIP_FORMATTING
node ../scripts/results.js "Server-Timing ($THEME)" before.csv after.csv $OUTPUT $SKIP_FORMATTING
fi

# Shutdown sites again
Expand Down

0 comments on commit 13618c0

Please sign in to comment.