From d8154a117537b717e3a3b6c81e4b9745ddf28741 Mon Sep 17 00:00:00 2001
From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com>
Date: Mon, 5 May 2025 21:32:51 +0100
Subject: [PATCH] Enhance CI workflow to download and include benchmark reports
in documentation output
---
.github/workflows/docs-and-testcov.yml | 31 ++++++++++++++++++++++++++
.github/workflows/run-benchmarks.yml | 2 +-
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/docs-and-testcov.yml b/.github/workflows/docs-and-testcov.yml
index 8ace0a8..2f1f92e 100644
--- a/.github/workflows/docs-and-testcov.yml
+++ b/.github/workflows/docs-and-testcov.yml
@@ -10,6 +10,10 @@ on:
# pull_request:
# branches: [main]
workflow_dispatch:
+ workflow_run:
+ workflows: ["run-benchmarks"]
+ types:
+ - completed
permissions:
contents: read
@@ -100,6 +104,30 @@ jobs:
<(echo '{}') \
> 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 "" > benchmark-report/index.html
+
- name: Copy files to output directory
run: |
# mkdir docs
@@ -116,6 +144,9 @@ jobs:
echo "" > target/doc/index.html
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
- name: Verify logo directory
run: |
diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml
index 50ec98c..baea81a 100644
--- a/.github/workflows/run-benchmarks.yml
+++ b/.github/workflows/run-benchmarks.yml
@@ -1,4 +1,4 @@
-name: Run benchmarks
+name: run-benchmarks
on:
workflow_dispatch: