Enhance CI workflow to download and include benchmark reports in documentation output

This commit is contained in:
Palash Tyagi 2025-05-05 21:32:51 +01:00
parent 4d4b6d1656
commit d8154a1175
2 changed files with 32 additions and 1 deletions

View File

@ -10,6 +10,10 @@ on:
# pull_request: # pull_request:
# branches: [main] # branches: [main]
workflow_dispatch: workflow_dispatch:
workflow_run:
workflows: ["run-benchmarks"]
types:
- completed
permissions: permissions:
contents: read contents: read
@ -100,6 +104,30 @@ jobs:
<(echo '{}') \ <(echo '{}') \
> last-commit-date.json > last-commit-date.json
- name: Download last available benchmark report
run: |
artifact_url=$(gh api -H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/actions/artifacts \
| jq -r '.artifacts[] | select(.name | startswith("benchmark-reports")) | .archive_download_url' | head -n 1)
if [ -z "$artifact_url" ]; then
echo "No benchmark artifact found!"
exit 1
fi
curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-o benchmark-report.zip "$artifact_url"
mkdir -p benchmark-report
unzip benchmark-report.zip -d benchmark-report
# there will be a tar file in the benchmark-report directory
# called artifact.tar. unzip it into the benchmark-report
tar -xvf benchmark-report/artifact.tar -C benchmark-report
# remove the artifact.tar file
rm benchmark-report/artifact.tar
# add an index.html that points to benchmark-report/report/index.html
echo "<meta http-equiv=\"refresh\" content=\"0; url=report/index.html\">" > benchmark-report/index.html
- name: Copy files to output directory - name: Copy files to output directory
run: | run: |
# mkdir docs # mkdir docs
@ -116,6 +144,9 @@ jobs:
echo "<meta http-equiv=\"refresh\" content=\"0; url=docs\">" > target/doc/index.html echo "<meta http-equiv=\"refresh\" content=\"0; url=docs\">" > target/doc/index.html
touch target/doc/.nojekyll touch target/doc/.nojekyll
# copy the benchmark report to the output directory
cp -r benchmark-report target/doc/
# verify that logo exists in the output directory # verify that logo exists in the output directory
- name: Verify logo directory - name: Verify logo directory
run: | run: |

View File

@ -1,4 +1,4 @@
name: Run benchmarks name: run-benchmarks
on: on:
workflow_dispatch: workflow_dispatch: