Repository navigation
64 lines (54 loc) · 2.69 KB
/
Copy pathdevelop-bench-trigger.yml
File metadata and controls
64 lines (54 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors
# Polls `develop` every three hours and dispatches `develop-bench.yml` when HEAD has moved past
# the latest non-cancelled Develop Benchmarks run. This caps triggers to at most one dispatch per
# three hours while keeping `develop-bench.yml` free of skipped no-op runs. Each run costs about
# 25 metal hosts, so the interval trades finer attribution of a regression for fewer runs: one run
# covers every commit that landed since the last one. A PR that needs results for its own merge
# commit takes the `action/bench-on-merge` label, handled by `develop-bench-on-merge.yml`.
name: Develop Benchmarks Trigger
concurrency:
group: develop-bench-trigger
cancel-in-progress: false
on:
schedule:
- cron: "7 */3 * * *"
workflow_dispatch: { }
permissions:
actions: write
contents: read
jobs:
dispatch-if-new-commits:
if: github.repository == 'vortex-data/vortex'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Dispatch develop benchmarks if develop HEAD is unbenchmarked
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
set -Eeuo pipefail
head_sha="$(gh api "repos/${GH_REPO}/commits/develop" --jq '.sha')"
echo "develop HEAD: ${head_sha}"
# Check recent non-cancelled runs of develop-bench.yml on develop.
# Checking the last 20 runs covers in-flight dispatches, failed runs (so a broken
# commit is not retried every interval), out-of-order completions, and runs that
# `develop-bench-on-merge.yml` dispatched for a given commit. Those name the commit in
# their title and are matched by it alone, because their `head_sha` is develop HEAD at
# dispatch time, which they did not benchmark.
already_ran="$(gh api \
"repos/${GH_REPO}/actions/workflows/develop-bench.yml/runs?branch=develop&per_page=20" \
| jq -r --arg sha "${head_sha}" \
'[.workflow_runs[] | select(.conclusion != "cancelled")
| if (.display_title | startswith("Develop Benchmarks for "))
then .display_title == "Develop Benchmarks for \($sha)"
else .head_sha == $sha end] | any')"
if [ "${already_ran}" = "true" ]; then
echo "develop HEAD ${head_sha} already has a Develop Benchmarks run; skipping."
exit 0
fi
echo "Dispatching develop-bench.yml for develop (${head_sha})..."
gh api --method POST \
"repos/${GH_REPO}/actions/workflows/develop-bench.yml/dispatches" \
-f ref="develop"