Skip to content

Commit 6f321e4

Browse files
chore: publish performance data to gh-pages (#3907)
* Use `benchmark-action/github-action-benchmark@v1` to automate perf metric storage and deployment. * Switch repo's GitHub Pages to deployment from branch `gh-pages`. Required, as now there are 2 sources of information for gh-pages (WPT + performance). * Update WPT report to override `wpt/index.html` and `wpt/wptreport-2023.html` in `gh-pages` branch. * Add `index.html` with links to the perf metrics and to the WPT reports the root of `gh-pages` branch. * Example perf page: https://googlechromelabs.github.io/chromium-bidi/bench/index.html
1 parent d6d8947 commit 6f321e4

File tree

2 files changed

+53
-24
lines changed

2 files changed

+53
-24
lines changed

.github/workflows/performance.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,23 @@ jobs:
106106
# Do not store these artifacts for long, as they will be present in the `all-performance-metrics`.
107107
retention-days: 1
108108
combine_metrics:
109+
if: ${{ !cancelled() }}
109110
name: Combine performance metrics
111+
environment:
112+
name: github-pages
113+
url: ${{ steps.deployment.outputs.page_url }}
114+
permissions:
115+
deployments: write
116+
# Add perf metrics to PR's comment
117+
pull-requests: write
118+
contents: write
110119
runs-on: ubuntu-latest
111120
needs: performance_metric
112121
steps:
122+
- name: Checkout
123+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
124+
- name: Setup Pages
125+
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
113126
- name: Download all performance metrics artifacts
114127
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
115128
with:
@@ -118,10 +131,39 @@ jobs:
118131
run: |
119132
find artifacts -name "performance_metrics.txt" -exec cat {} + > all_performance_metrics.txt
120133
echo "Combined performance metrics:"
121-
sort -o all_performance_metrics.txt all_performance_metrics.txt
122134
cat all_performance_metrics.txt
135+
136+
# Convert to JSON format suitable for github-action-benchmark
137+
echo "[" > all_performance_metrics.json
138+
first_metric=true
139+
while IFS= read -r line; do
140+
if [ "$first_metric" = false ]; then
141+
echo "," >> all_performance_metrics.json
142+
fi
143+
key=${line%:*}
144+
value=${line##*:}
145+
echo " {\"name\": \"$key\", \"value\": $value, \"unit\": \"ms\"}" >> all_performance_metrics.json
146+
first_metric=false
147+
done < all_performance_metrics.txt
148+
echo "]" >> all_performance_metrics.json
149+
echo "Combined performance metrics in JSON format:"
150+
cat all_performance_metrics.json
123151
- name: Upload combined performance metrics
124152
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
125153
with:
126154
name: all-performance-metrics
127-
path: all_performance_metrics.txt
155+
path: |
156+
all_performance_metrics.txt
157+
all_performance_metrics.json
158+
- name: Store benchmark result
159+
uses: benchmark-action/github-action-benchmark@v1
160+
with:
161+
tool: 'customSmallerIsBetter'
162+
output-file-path: all_performance_metrics.json
163+
gh-pages-branch: gh-pages
164+
benchmark-data-dir-path: bench/
165+
github-token: ${{ secrets.GITHUB_TOKEN }}
166+
# Comment only when run in PR.
167+
comment-always: ${{ github.ref != 'refs/heads/main' }}
168+
# Push and deploy automatically on merge to main.
169+
auto-push: ${{ github.ref == 'refs/heads/main' }}

.github/workflows/wpt.yml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,8 @@ jobs:
285285
needs: wpt
286286
if: ${{ github.ref == 'refs/heads/main' }}
287287
runs-on: ubuntu-latest
288-
environment:
289-
name: github-pages
290-
url: ${{ steps.deployment.outputs.page_url }}
291-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
292288
permissions:
293-
contents: read
294-
pages: write
295-
id-token: write
289+
contents: write
296290
steps:
297291
- name: Checkout
298292
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -310,24 +304,17 @@ jobs:
310304
merge-multiple: true
311305
- name: Generate HTML test report
312306
run: >
307+
mkdir -p wpt-report;
313308
node tools/wpt-report-builder/builder.mjs \
314309
--bidi $(ls out/wptreport.*.json) \
315310
--interop $(ls out/wptreport-interop.*.json) \
316-
--out out/wptreport.html \
317-
--out-label-2023 out/wptreport-2023.html
318-
- name: Prepare Pages
319-
# TODO: Support merged wpt report as before
320-
# cp out/wptreport.json out/site/wptreport.json
321-
run: |
322-
mkdir -p out/site
323-
cp out/wptreport.html out/site/index.html
324-
cp out/wptreport-2023.html out/site/2023.html
311+
--out wpt-report/index.html \
312+
--out-label-2023 wpt-report/wptreport-2023.html
325313
- name: Setup Pages
326314
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
327-
- name: Upload Pages artifact
328-
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
315+
- name: Push to `gh-pages` branch
316+
uses: JamesIves/github-pages-deploy-action@v4
329317
with:
330-
path: out/site
331-
- name: Deploy to GitHub Pages
332-
id: deployment
333-
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
318+
folder: wpt-report
319+
branch: gh-pages
320+
target-folder: wpt

0 commit comments

Comments
 (0)