99 description : ' The GitHub token used to create PR comments.'
1010 required : false
1111 default : ${{ github.token }}
12+ create-comment :
13+ description : ' Whether to create PR comments with performance results.'
14+ required : false
15+ default : ' '
1216 debug :
1317 description : ' Whether to log additional debugging information.'
1418 default : ${{ runner.debug == '1' }}
@@ -90,18 +94,20 @@ runs:
9094 cache : ' '
9195
9296 - name : Install dependencies
93- run : npm ci
97+ run : npm ci ${{ inputs.debug != 'true' && '--silent' }}
9498 shell : ' bash'
9599 working-directory : ${{ github.action_path }}/env
96100
97101 - name : Install Playwright Browsers
98- run : npx playwright install --with-deps
102+ run : npx ${{ inputs.debug != 'true' && '--silent' }} playwright install --with-deps
99103 if : ${{ inputs.action == 'test' }}
100104 shell : ' bash'
101105 working-directory : ${{ github.action_path }}/env
102106
103107 - name : Prepare wp-env
104108 run : |
109+ echo "Preparing wp-env..."
110+
105111 PLUGINS=${PLUGINS%$'\n'}
106112 THEMES=${THEMES%$'\n'}
107113
@@ -177,7 +183,10 @@ runs:
177183 '{core: $wp, phpVersion: $php, plugins: [($rp | split("\n")), ($p | split("\n"))] | add, themes: [($rt | split("\n")), ($t | split("\n"))] | add}' \
178184 > ${{ env.ABS_ACTION_PATH }}/env/.wp-env.override.json
179185
180- cat ${{ env.ABS_ACTION_PATH }}/env/.wp-env.override.json
186+ if [[ ${{ inputs.debug == 'true' }} == true ]]; then
187+ echo "Generated .wp-env.override.json file:"
188+ cat ${{ env.ABS_ACTION_PATH }}/env/.wp-env.override.json
189+ fi
181190 if : ${{ inputs.action == 'test' }}
182191 env :
183192 PLUGINS : ${{ inputs.plugins }}
@@ -187,46 +196,46 @@ runs:
187196 shell : ' bash'
188197
189198 - name : Start WordPress
190- run : npm run wp-env start
199+ run : npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env start
191200 if : ${{ inputs.action == 'test' }}
192201 shell : ' bash'
193202 working-directory : ${{ github.action_path }}/env
194203
195204 - name : Update permalink structure
196- run : npm run wp-env run tests-cli wp rewrite structure '/%postname%/' -- --hard
205+ run : npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp rewrite structure '/%postname%/' -- --hard
197206 if : ${{ inputs.action == 'test' }}
198207 shell : ' bash'
199208 working-directory : ${{ github.action_path }}/env
200209
201210 - name : Import mock data
202211 run : |
203- npm run wp-env run tests-cli wp plugin list
204- npm run wp-env run tests-cli curl -s https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml -- --output /tmp/themeunittestdata.wordpress.xml
205- npm run wp-env run tests-cli wp import /tmp/themeunittestdata.wordpress.xml -- --authors=create --quiet
206- npm run wp-env run tests-cli wp plugin deactivate wordpress-importer --quiet
212+ npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp plugin list
213+ npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli curl -s https://raw.githubusercontent.com/WordPress/theme-test-data/b9752e0533a5acbb876951a8cbb5bcc69a56474c/themeunittestdata.wordpress.xml -- --output /tmp/themeunittestdata.wordpress.xml
214+ npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp import /tmp/themeunittestdata.wordpress.xml -- --authors=create --quiet
215+ npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp plugin deactivate wordpress-importer --quiet
207216 if : ${{ inputs.action == 'test' }}
208217 shell : ' bash'
209218 working-directory : ${{ github.action_path }}/env
210219
211220 - name : Prepare test site
212221 run : |
213- npm run wp-env run tests-cli wp theme activate $THEME --quiet
214- npm run wp-env run tests-cli wp config set WP_HTTP_BLOCK_EXTERNAL true --raw --type=constant
215- npm run wp-env run tests-cli wp config set DISABLE_WP_CRON true --raw --type=constant
222+ npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp theme activate $THEME --quiet
223+ npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp config set WP_HTTP_BLOCK_EXTERNAL true --raw --type=constant
224+ npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp config set DISABLE_WP_CRON true --raw --type=constant
216225 if : ${{ inputs.action == 'test' }}
217226 env :
218227 THEME : ${{ inputs.active-theme }}
219228 shell : ' bash'
220229 working-directory : ${{ github.action_path }}/env
221230
222231 - name : List defined constants
223- run : npm run wp-env run tests-cli wp config list --path=/var/www/${{ env.LOCAL_DIR }}
232+ run : npm run ${{ inputs.debug != 'true' && '--silent' }} wp-env run tests-cli wp config list --path=/var/www/${{ env.LOCAL_DIR }}
224233 if : ${{ inputs.action == 'test' && inputs.debug == 'true' }}
225234 shell : ' bash'
226235 working-directory : ${{ github.action_path }}/env
227236
228237 - name : Run tests
229- run : npm run test:performance $ADDITIONAL_ARGS
238+ run : npm run ${{ inputs.debug != 'true' && '--silent' }} test:performance $ADDITIONAL_ARGS
230239 if : ${{ inputs.action == 'test' }}
231240 env :
232241 WP_ARTIFACTS_PATH : ${{ github.action_path }}/env/artifacts
@@ -247,17 +256,17 @@ runs:
247256 path : performance-blob-report
248257
249258 - name : Merge into single performance report
250- run : npm run test:performance:merge-reports ${{steps.download.outputs.download-path}}
259+ run : npm run ${{ inputs.debug != 'true' && '--silent' }} test:performance:merge-reports ${{steps.download.outputs.download-path}}
251260 if : ${{ inputs.action == 'merge' }}
252261 shell : ' bash'
253262 working-directory : ${{ github.action_path }}/env
254263
255264 - name : Print results
256265 run : |
257266 if [ ! -z $PREVIOUS_RESULTS ] && [ -f $PREVIOUS_RESULTS ]; then
258- npm run test:performance:results $WP_ARTIFACTS_PATH/performance-results.json $PREVIOUS_RESULTS
267+ npm run ${{ inputs.debug != 'true' && '--silent' }} test:performance:results $WP_ARTIFACTS_PATH/performance-results.json $PREVIOUS_RESULTS
259268 else
260- npm run test:performance:results
269+ npm run ${{ inputs.debug != 'true' && '--silent' }} test:performance:results
261270 fi;
262271 if : ${{ inputs.action == 'test' || inputs.action == 'merge' }}
263272 env :
@@ -275,6 +284,24 @@ runs:
275284 shell : ' bash'
276285 working-directory : ${{ github.action_path }}/env
277286
287+ - name : Check if a comment was already made
288+ id : find-comment
289+ if : ${{ inputs.create-comment == 'true' }}
290+ uses : peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1
291+ with :
292+ issue-number : ${{ github.event.pull_request.number }}
293+ body-includes : Performance test results for
294+
295+ - name : Comment on PR with test results
296+ uses : peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa
297+ if : ${{ inputs.create-comment == 'true' }}
298+ with :
299+ issue-number : ${{ github.event.pull_request.number }}
300+ comment-id : ${{ steps.find-comment.outputs.comment-id }}
301+ edit-mode : replace
302+ body-path : ${{ github.action_path }}/env/artifacts/performance-results.md
303+ token : ${{ inputs.github-token }}
304+
278305 - name : Share raw results
279306 id : share-results
280307 run : echo "results=$WP_ARTIFACTS_PATH/performance-results.json" >> $GITHUB_OUTPUT
0 commit comments