Skip to content

Commit 9c45032

Browse files
authored
Skip nightly benchmarks if no new commits (#173)
This PR adds a file in the gh-pages benchmark data to store the commits of fvdb-core and fvdb-reality-capture of the last benchmark run. It also adds metadata for each run containing these commits. The workflow is updated to check the current and previous commits and not run if there are no new commits. When there are no new commits this finishes within seconds: https://github.com/openvdb/fvdb-reality-capture/actions/runs/19330065132/job/55290639222 --------- Signed-off-by: Mark Harris <mharris@nvidia.com>
1 parent c61a70c commit 9c45032

File tree

1 file changed

+102
-3
lines changed

1 file changed

+102
-3
lines changed

.github/workflows/nightly.yml

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ jobs:
3131
runs-on: ubuntu-latest
3232
outputs:
3333
fvdb_core_commit_hash: ${{ steps.get-commit-hash.outputs.fvdb_core_commit_hash }}
34+
fvdb_reality_capture_commit_hash: ${{ steps.get-commit-hash.outputs.fvdb_reality_capture_commit_hash }}
35+
should_skip: ${{ steps.check-changes.outputs.should_skip }}
3436
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
ref: gh-pages
40+
path: gh-pages
41+
3542
- name: Get fvdb-core commit hash
3643
id: get-commit-hash
3744
env:
@@ -46,12 +53,50 @@ jobs:
4653
FVDB_CORE_COMMIT_HASH=$(gh api repos/openvdb/fvdb-core/commits/main --jq .sha)
4754
echo "FVDB_CORE_COMMIT_HASH=${FVDB_CORE_COMMIT_HASH}"
4855
echo "fvdb_core_commit_hash=${FVDB_CORE_COMMIT_HASH}" >> "$GITHUB_OUTPUT"
56+
57+
# Get fvdb-reality-capture commit hash (current commit)
58+
FVDB_RC_COMMIT_HASH="${{ github.sha }}"
59+
echo "FVDB_RC_COMMIT_HASH=${FVDB_RC_COMMIT_HASH}"
60+
echo "fvdb_reality_capture_commit_hash=${FVDB_RC_COMMIT_HASH}" >> "$GITHUB_OUTPUT"
61+
62+
- name: Check if commits changed since last run
63+
id: check-changes
64+
run: |
65+
SHOULD_SKIP="false"
66+
67+
if [ -f "gh-pages/dev/bench/last_run_commits.txt" ]; then
68+
echo "Found last run commits file"
69+
cat gh-pages/dev/bench/last_run_commits.txt
70+
71+
LAST_FVDB_CORE=$(grep "fvdb_core:" gh-pages/dev/bench/last_run_commits.txt | cut -d' ' -f2)
72+
LAST_FVDB_RC=$(grep "fvdb_reality_capture:" gh-pages/dev/bench/last_run_commits.txt | cut -d' ' -f2)
73+
74+
CURRENT_FVDB_CORE="${{ steps.get-commit-hash.outputs.fvdb_core_commit_hash }}"
75+
CURRENT_FVDB_RC="${{ steps.get-commit-hash.outputs.fvdb_reality_capture_commit_hash }}"
76+
77+
echo "Last run - fvdb-core: ${LAST_FVDB_CORE}, fvdb-reality-capture: ${LAST_FVDB_RC}"
78+
echo "Current - fvdb-core: ${CURRENT_FVDB_CORE}, fvdb-reality-capture: ${CURRENT_FVDB_RC}"
79+
80+
if [ -n "${LAST_FVDB_CORE}" ] && [ -n "${LAST_FVDB_RC}" ] && \
81+
[ "${LAST_FVDB_CORE}" = "${CURRENT_FVDB_CORE}" ] && \
82+
[ "${LAST_FVDB_RC}" = "${CURRENT_FVDB_RC}" ]; then
83+
echo "No changes detected. Skipping workflow."
84+
SHOULD_SKIP="true"
85+
else
86+
echo "Changes detected. Running workflow."
87+
fi
88+
else
89+
echo "No previous run found. Running workflow."
90+
fi
91+
92+
echo "should_skip=${SHOULD_SKIP}" >> "$GITHUB_OUTPUT"
4993
##############################################################################
5094
# BUILD FVDB
5195
##############################################################################
5296
start-build-runner:
53-
if: ${{ github.repository == 'openvdb/fvdb-reality-capture' }}
97+
if: ${{ github.repository == 'openvdb/fvdb-reality-capture' && needs.get-fvdb-core-commit-hash.outputs.should_skip != 'true' }}
5498
name: Start CPU-only EC2 runner for build
99+
needs: get-fvdb-core-commit-hash
55100
runs-on: ubuntu-latest
56101
outputs:
57102
label: ${{ steps.start-build-runner.outputs.label }}
@@ -146,7 +191,7 @@ jobs:
146191
retention-days: 30
147192

148193
fvdb-build-stop-runner:
149-
if: ${{ always() && github.repository == 'openvdb/fvdb-reality-capture' }}
194+
if: ${{ always() && github.repository == 'openvdb/fvdb-reality-capture' && needs.start-build-runner.result != 'skipped' }}
150195
name: Stop CPU-only EC2 runner for build
151196
needs:
152197
- start-build-runner # required to get output from the start-build-runner job
@@ -281,7 +326,28 @@ jobs:
281326
cd tests;
282327
pytest benchmarks --benchmark-json benchmarks/output.json
283328
329+
- name: Add commit metadata to benchmark results
330+
run: |
331+
# Add both commit hashes to the benchmark JSON for reference
332+
python3 << 'EOF'
333+
import json
334+
335+
with open('tests/benchmarks/output.json', 'r') as f:
336+
data = json.load(f)
337+
338+
# Add metadata about both commits
339+
if 'commit_info' not in data:
340+
data['commit_info'] = {}
341+
342+
data['commit_info']['fvdb_core_commit'] = '${{ needs.get-fvdb-core-commit-hash.outputs.fvdb_core_commit_hash }}'
343+
data['commit_info']['fvdb_reality_capture_commit'] = '${{ needs.get-fvdb-core-commit-hash.outputs.fvdb_reality_capture_commit_hash }}'
344+
345+
with open('tests/benchmarks/output.json', 'w') as f:
346+
json.dump(data, f, indent=2)
347+
EOF
348+
284349
- name: Store benchmark result
350+
id: store-benchmark
285351
uses: benchmark-action/github-action-benchmark@v1
286352
with:
287353
name: fvdb-reality-capture Benchmark with pytest-benchmark
@@ -294,12 +360,45 @@ jobs:
294360
comment-on-alert: true
295361
fail-on-alert: true
296362
alert-comment-cc-users: '@openvdb/fvdb-dev'
363+
# Always comment on benchmark results, even without alerts
364+
comment-always: true
365+
366+
- name: Save commit hashes for next run
367+
if: steps.store-benchmark.outcome == 'success' || steps.store-benchmark.outcome == 'failure'
368+
env:
369+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
370+
run: |
371+
# Check out gh-pages branch with token authentication
372+
rm -rf gh-pages-repo
373+
git clone --branch gh-pages https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git gh-pages-repo
374+
cd gh-pages-repo
375+
376+
# Create directory if it doesn't exist
377+
mkdir -p dev/bench
378+
379+
# Save current commit hashes for skip detection
380+
cat > dev/bench/last_run_commits.txt << EOF
381+
fvdb_core: ${{ needs.get-fvdb-core-commit-hash.outputs.fvdb_core_commit_hash }}
382+
fvdb_reality_capture: ${{ needs.get-fvdb-core-commit-hash.outputs.fvdb_reality_capture_commit_hash }}
383+
EOF
384+
385+
# Append to commit mapping log (for historical tracking)
386+
echo "$(date -Iseconds) | fvdb-reality-capture: ${{ needs.get-fvdb-core-commit-hash.outputs.fvdb_reality_capture_commit_hash }} | fvdb-core: ${{ needs.get-fvdb-core-commit-hash.outputs.fvdb_core_commit_hash }}" >> dev/bench/commit_mapping.log
387+
388+
# Configure git
389+
git config user.name "github-actions[bot]"
390+
git config user.email "github-actions[bot]@users.noreply.github.com"
391+
392+
# Commit and push
393+
git add dev/bench/last_run_commits.txt dev/bench/commit_mapping.log
394+
git commit -m "Save commit hashes for workflow run ${{ github.run_id }}" || echo "No changes to commit"
395+
git push || { echo "Failed to push commit hashes. This may cause the next run to not skip properly."; exit 1; }
297396
298397
##############################################################################
299398
# STOP FVDB TESTS GPU RUNNER
300399
##############################################################################
301400
fvdb-benchmarks-stop-gpu-runner:
302-
if: ${{ always() && github.repository == 'openvdb/fvdb-reality-capture' }}
401+
if: ${{ always() && github.repository == 'openvdb/fvdb-reality-capture' && needs.start-benchmarks-gpu-runner.result != 'skipped' }}
303402
name: Stop GPU EC2 runner for tests
304403
needs:
305404
- start-benchmarks-gpu-runner # required to get output from the start-benchmarks-gpu-runner job

0 commit comments

Comments
 (0)