Skip to content

Commit 39138e0

Browse files
feat(ci): add /ci-run-regression trigger + accept refs in inputs (#25245)
* chore(ci): accept refs in regression workflow and add /ci-run-regression trigger * Shorten /ci-run-regression description * chore(ci): drop unneeded actions: write and grant id-token on regression caller * chore(ci): use startsWith and simplify regression baseline parsing
1 parent e59ac57 commit 39138e0

2 files changed

Lines changed: 85 additions & 43 deletions

File tree

.github/workflows/ci-review-trigger.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@
2323
# /ci-run-unit-windows : runs Unit - Windows
2424
# /ci-run-environment : runs Environment Suite
2525
# /ci-run-k8s : runs K8s E2E Suite
26+
#
27+
# Not included in /ci-run-all:
28+
#
29+
# /ci-run-regression : runs Regression Detection Suite. The comparison ref is
30+
# the review's commit. An optional baseline ref can be
31+
# passed as an argument, otherwise the baseline defaults
32+
# to the SHA from 7 days ago. Examples:
33+
# /ci-run-regression
34+
# /ci-run-regression origin/master
35+
# /ci-run-regression v0.55.0
36+
# Not included in `/ci-run-all` because it is expensive.
2637

2738
name: CI Review Trigger
2839

@@ -70,6 +81,7 @@ jobs:
7081
|| startsWith(github.event.review.body, '/ci-run-unit-windows')
7182
|| startsWith(github.event.review.body, '/ci-run-environment')
7283
|| startsWith(github.event.review.body, '/ci-run-k8s')
84+
|| startsWith(github.event.review.body, '/ci-run-regression')
7385
steps:
7486
- name: Generate authentication token
7587
id: generate_token
@@ -197,6 +209,40 @@ jobs:
197209
ref: ${{ github.event.review.commit_id }}
198210
secrets: inherit
199211

212+
# Parse an optional baseline ref from a `/ci-run-regression <ref>` comment line.
213+
# The captured ref is passed to the regression workflow; an empty value lets it
214+
# fall back to its default (the SHA from 7 days ago).
215+
regression-parse:
216+
needs: validate
217+
if: startsWith(github.event.review.body, '/ci-run-regression')
218+
runs-on: ubuntu-24.04
219+
timeout-minutes: 5
220+
outputs:
221+
baseline-sha: ${{ steps.parse.outputs.baseline }}
222+
steps:
223+
- name: Parse baseline ref from review body
224+
id: parse
225+
env:
226+
REVIEW_BODY: ${{ github.event.review.body }}
227+
run: |
228+
# The body starts with `/ci-run-regression`; take the second whitespace-
229+
# delimited token on the first line as the optional baseline ref.
230+
read -r _ BASELINE _ <<< "${REVIEW_BODY}"
231+
echo "Parsed baseline ref: '${BASELINE}'"
232+
echo "baseline=${BASELINE}" >> "$GITHUB_OUTPUT"
233+
234+
regression:
235+
needs: [validate, regression-parse]
236+
if: startsWith(github.event.review.body, '/ci-run-regression')
237+
permissions:
238+
contents: read # Required to checkout code
239+
id-token: write # Required for AWS OIDC token exchange in regression.yml
240+
uses: ./.github/workflows/regression.yml
241+
with:
242+
baseline-sha: ${{ needs.regression-parse.outputs.baseline-sha }}
243+
comparison-sha: ${{ github.event.review.commit_id }}
244+
secrets: inherit
245+
200246
coverage:
201247
needs: validate
202248
if: contains(github.event.review.body, '/ci-run-coverage')

.github/workflows/regression.yml

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
# Regression Detection Suite
22
#
33
# This workflow runs under the following conditions:
4-
# - Once per day, based on a schedule
5-
# - On demand, triggered from https://github.com/vectordotdev/vector/actions/workflows/regression_v2.yml
4+
# - Once per week, based on a schedule
5+
# - On demand, triggered from https://github.com/vectordotdev/vector/actions/workflows/regression.yml
6+
# - On demand, via the `/ci-run-regression` (or `/ci-run-all`) PR review comment,
7+
# which invokes this workflow via `workflow_call` from `ci-review-trigger.yml`.
68
#
79
# The workflow accepts two optional inputs:
8-
# - The baseline SHA:
10+
# - The baseline ref:
911
# - If not specified, the SHA from 7 days ago on origin/master is used.
10-
# - The comparison SHA:
12+
# - The comparison ref:
1113
# - If not specified, the current HEAD of origin/master is used.
1214
#
15+
# Both inputs accept any git ref that `git rev-parse` can resolve: a full commit
16+
# SHA, a short SHA, a branch name (e.g. `origin/master`), or a tag.
17+
#
1318
# This workflow runs regression detection experiments, performing relative
1419
# evaluations of the baseline SHA and comparison SHA. The exact SHAs are determined
1520
# by how the workflow is triggered.
@@ -26,11 +31,21 @@ on:
2631
workflow_dispatch:
2732
inputs:
2833
baseline-sha:
29-
description: "The SHA to use as the baseline (optional). If not provided, it defaults to the SHA from 7 days ago."
34+
description: "Baseline git ref (full/short SHA, branch such as `origin/master`, or tag). Defaults to the SHA from 7 days ago."
35+
required: false
36+
comparison-sha:
37+
description: "Comparison git ref (full/short SHA, branch such as `origin/master`, or tag). Defaults to the current HEAD of origin/master."
38+
required: false
39+
workflow_call:
40+
inputs:
41+
baseline-sha:
42+
description: "Baseline git ref (full/short SHA, branch such as `origin/master`, or tag). Defaults to the SHA from 7 days ago."
3043
required: false
44+
type: string
3145
comparison-sha:
32-
description: "The SHA to use for comparison (optional). If not provided, it defaults to the current HEAD of the origin/master branch."
46+
description: "Comparison git ref (full/short SHA, branch such as `origin/master`, or tag). Defaults to the current HEAD of origin/master."
3347
required: false
48+
type: string
3449
schedule:
3550
- cron: "0 7 * * 1" # Runs at 7 AM UTC on Mondays
3651

@@ -60,39 +75,32 @@ jobs:
6075

6176
- name: Set and Validate SHAs
6277
id: set_and_validate_shas
78+
env:
79+
BASELINE_INPUT: ${{ inputs.baseline-sha }}
80+
COMPARISON_INPUT: ${{ inputs.comparison-sha }}
6381
run: |
64-
# Set baseline SHA
65-
if [ -z "${{ github.event.inputs.baseline-sha }}" ]; then
82+
# Resolve baseline ref to a full commit SHA
83+
if [ -z "${BASELINE_INPUT}" ]; then
6684
BASELINE_SHA=$(git rev-list -n 1 --before="7 days ago" origin/master)
6785
echo "Using baseline SHA from 7 days ago: ${BASELINE_SHA}"
6886
else
69-
BASELINE_SHA="${{ github.event.inputs.baseline-sha }}"
70-
echo "Using provided baseline SHA: ${BASELINE_SHA}"
87+
if ! BASELINE_SHA=$(git rev-parse --verify "${BASELINE_INPUT}^{commit}" 2>/dev/null); then
88+
echo "Invalid baseline ref: '${BASELINE_INPUT}'. Expected a full/short SHA, branch (e.g. origin/master), or tag."
89+
exit 1
90+
fi
91+
echo "Resolved baseline input '${BASELINE_INPUT}' to SHA: ${BASELINE_SHA}"
7192
fi
7293
73-
# Validate baseline SHA
74-
if [ -n "${BASELINE_SHA}" ] && git cat-file -e "${BASELINE_SHA}^{commit}"; then
75-
echo "Baseline SHA is valid."
76-
else
77-
echo "Invalid baseline SHA: ${BASELINE_SHA}."
78-
exit 1
79-
fi
80-
81-
# Set comparison SHA
82-
if [ -z "${{ github.event.inputs.comparison-sha }}" ]; then
94+
# Resolve comparison ref to a full commit SHA
95+
if [ -z "${COMPARISON_INPUT}" ]; then
8396
COMPARISON_SHA=$(git rev-parse origin/master)
84-
echo "Using current HEAD for comparison SHA: ${COMPARISON_SHA}"
97+
echo "Using current HEAD of origin/master as comparison SHA: ${COMPARISON_SHA}"
8598
else
86-
COMPARISON_SHA="${{ github.event.inputs.comparison-sha }}"
87-
echo "Using provided comparison SHA: ${COMPARISON_SHA}"
88-
fi
89-
90-
# Validate comparison SHA
91-
if [ -n "${COMPARISON_SHA}" ] && git cat-file -e "${COMPARISON_SHA}^{commit}"; then
92-
echo "Comparison SHA is valid."
93-
else
94-
echo "Invalid comparison SHA: ${COMPARISON_SHA}."
95-
exit 1
99+
if ! COMPARISON_SHA=$(git rev-parse --verify "${COMPARISON_INPUT}^{commit}" 2>/dev/null); then
100+
echo "Invalid comparison ref: '${COMPARISON_INPUT}'. Expected a full/short SHA, branch (e.g. origin/master), or tag."
101+
exit 1
102+
fi
103+
echo "Resolved comparison input '${COMPARISON_INPUT}' to SHA: ${COMPARISON_SHA}"
96104
fi
97105
98106
# Set tags and export them
@@ -192,10 +200,6 @@ jobs:
192200
needs:
193201
- should-run-gate
194202
- resolve-inputs
195-
# Job-level permissions for artifact upload
196-
permissions:
197-
contents: read # Required to checkout code
198-
actions: write # Required to upload artifacts
199203
steps:
200204
- uses: colpal/actions-clean@36e6ca1abd35efe61cb60f912bd7837f67887c8a # v1.1.1
201205

@@ -235,10 +239,6 @@ jobs:
235239
needs:
236240
- should-run-gate
237241
- resolve-inputs
238-
# Job-level permissions for artifact upload
239-
permissions:
240-
contents: read # Required to checkout code
241-
actions: write # Required to upload artifacts
242242
steps:
243243
- uses: colpal/actions-clean@36e6ca1abd35efe61cb60f912bd7837f67887c8a # v1.1.1
244244

@@ -392,10 +392,8 @@ jobs:
392392
- resolve-inputs
393393
- upload-baseline-image-to-ecr
394394
- upload-comparison-image-to-ecr
395-
# Job-level permissions for artifact upload
396395
permissions:
397396
contents: read # Required to checkout code
398-
actions: write # Required to upload artifacts
399397
id-token: write # Required for GitHub OIDC token exchange
400398
steps:
401399
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -513,10 +511,8 @@ jobs:
513511
- should-run-gate
514512
- submit-job
515513
- resolve-inputs
516-
# Job-level permissions for artifact upload
517514
permissions:
518515
contents: read # Required to checkout code
519-
actions: write # Required to upload artifacts
520516
id-token: write # Required for GitHub OIDC token exchange
521517
steps:
522518
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

0 commit comments

Comments
 (0)