8000 ci: benchmark workflow improvements · timonvo/libgit2@02435d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02435d7

Browse files
committed
ci: benchmark workflow improvements
Publish the site as an artifact during workflow_dispatch events.
1 parent 9c2b827 commit 02435d7

File tree

1 file changed

+58
-31
lines changed

1 file changed

+58
-31
lines changed

.github/workflows/benchmark.yml

Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
debug:
1010
type: boolean
1111
description: Debugging output
12+
deploy:
13+
type: boolean
14+
description: Deploy the benchmark site
1215
schedule:
1316
- cron: '15 4 * * *'
1417

@@ -70,11 +73,15 @@ jobs:
7073
if: matrix.platform.setup-script != ''
7174
- name: Clone resource repositories
7275
run: |
76+
# TODO:
7377
# we need a superior way to package the benchmark resources; lfs
7478
# is too expensive
7579
# git lfs install
7680
# git clone https://github.com/libgit2/benchmark-resources resources
81+
7782
git clone --bare https://github.com/git/git resources/git
83+
84+
# TODO:
7885
# avoid linux temporarily; the linux blame benchmarks are simply
7986
# too slow to use
8087
# git clone --bare https://github.com/torvalds/linux resources/linux
@@ -85,7 +92,9 @@ jobs:
8592
shell: bash
8693
- name: Benchmark
8794
run: |
88-
export BENCHMARK_RESOURCES_PATH="$(pwd)/resources"
95+
# TODO:
96+
# avoid benchmark resource path currently
97+
#export BENCHMARK_RESOURCES_PATH="$(pwd)/resources"
8998
export BENCHMARK_GIT_PATH="$(pwd)/resources/git"
9099
# avoid linux temporarily; the linux blame benchmarks are simply
91100
# too slow to use
@@ -122,7 +131,7 @@ jobs:
122131
publish:
123132
name: Publish results
124133
needs: [ build ]
125-
if: always() && github.repository == 'libgit2/libgit2' && github.event_name == 'schedule'
134+
if: always() && github.repository == 'libgit2/libgit2'
126135
runs-on: ubuntu-latest
127136
steps:
128137
- name: Check out benchmark repository
@@ -134,40 +143,58 @@ jobs:
134143
ssh-key: ${{ secrets.BENCHMARKS_PUBLISH_KEY }}
135144
- name: Download test results
136145
uses: actions/download-artifact@v4
146+
- name: Generate API
147+
run: |
148+
# Move today's benchmark run into the right place
149+
for platform in linux macos windows; do
150+
TIMESTAMP=$(jq .time.start < "benchmark-${platform}/benchmarks.json")
151+
TIMESTAMP_LEN=$(echo -n ${TIMESTAMP} | wc -c | xargs)
152+
DENOMINATOR=1
153+
if [ "${TIMESTAMP_LEN}" = "19" ]; then
154+
DENOMINATOR="1000000000"
155+
elif [ "${TIMESTAMP_LEN}" = "13" ]; then
156+
DENOMINATOR="1000"
157+
else
158+
echo "unknown timestamp"
159+
exit 1
160+
fi
161+
162+
if [[ "$(uname -s)" == "Darwin" ]]; then
163+
DATE=$(date -R -r $(("${TIMESTAMP}/${DENOMINATOR}")) +"%Y-%m-%d")
164+
else
165+
DATE=$(date -d @$(("${TIMESTAMP}/${DENOMINATOR}")) +"%Y-%m-%d")
166+
fi
167+
168+
# move the complete results in
169+
mkdir -p "site/public/api/runs/${DATE}"
170+
cp "benchmark-${platform}/benchmarks.json" "site/public/api/runs/${DATE}/${platform}.json"
171+
172+
# unzip the individual results
173+
PLATFORM_TEMP=$(mktemp -d)
174+
unzip "benchmark-${platform}/benchmarks.zip" -d "${PLATFORM_TEMP}"
175+
176+
mkdir -p "site/public/api/runs/${DATE}/${platform}"
177+
find "${PLATFORM_TEMP}" -name \*\.svg -exec cp {} "site/public/api/runs/${DATE}/${platform}" \;
178+
done
179+
180+
(cd site && node scripts/aggregate.js)
181+
shell: bash
182+
183+
# in debug mode, don't deploy the site; only create a zip file and
184+
# upload it for debugging
185+
- name: Upload site
186+
uses: actions/upload-artifact@v4
187+
with:
188+
name: site
189+
path: site
190+
if: github.event_name == 'workflow_dispatch'
137191
- name: Publish API
138192
run: |
139-
# Move today's benchmark run into the right place
140-
for platform in linux macos windows; do
141-
TIMESTAMP=$(jq .time.start < "benchmark-${platform}/benchmarks.json")
142-
TIMESTAMP_LEN=$(echo -n ${TIMESTAMP} | wc -c | xargs)
143-
DENOMINATOR=1
144-
if [ "${TIMESTAMP_LEN}" = "19" ]; then
145-
DENOMINATOR="1000000000"
146-
elif [ "${TIMESTAMP_LEN}" = "13" ]; then
147-
DENOMINATOR="1000"
148-
else
149-
echo "unknown timestamp"
150-
exit 1
151-
fi
152-
153-
if [[ "$(uname -s)" == "Darwin" ]]; then
154-
DATE=$(date -R -r $(("${TIMESTAMP}/${DENOMINATOR}")) +"%Y-%m-%d")
155-
else
156-
DATE=$(date -d @$(("${TIMESTAMP}/${DENOMINATOR}")) +"%Y-%m-%d")
157-
fi
158-
159-
mkdir -p "site/public/api/runs/${DATE}"
160-
cp "benchmark-${platform}/benchmarks.json" "site/public/api/runs/${DATE}/${platform}.json"
161-
done
162-
163-
(cd site && node scripts/aggregate.js)
164-
165-
(
166-
cd site &&
167193
git config user.name 'Benchmark Site Generation' &&
168194
git config user.email 'libgit2@users.noreply.github.com' &&
169195
git add . &&
170196
git commit --allow-empty -m"benchmark update ${DATE}" &&
171197
git push origin main
172-
)
173198
shell: bash
199+
working-directory: site
200+
if: github.event_name == 'schedule' || github.event.inputs.deploy == 'true'

0 commit comments

Comments
 (0)
0