Skip to content

Commit 5e5b663

Browse files
committed
fix: Move "should run tests" from buildkite to github action
Our internal check to alarm us if a post-PR A/B-test fails does not fire if a "bailed out" run (e.g. one where we decide not to run A/B-tests because we only modified, say, .md files) happens while a previous A/B-test is still running. This is because it only looks at the most recent buildkite run. Therefore, move the check whether to run an A/B-test at all from buildkite to the GitHub action that orchestrates the runs, so that "bail outs" happen outside of buildkite. Signed-off-by: Patrick Roy <[email protected]>
1 parent cc8464e commit 5e5b663

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

.buildkite/pipeline_perf.py

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,7 @@
55
"""Generate Buildkite performance pipelines dynamically"""
66
import os
77

8-
from common import (
9-
COMMON_PARSER,
10-
get_changed_files,
11-
group,
12-
overlay_dict,
13-
pipeline_to_json,
14-
)
8+
from common import COMMON_PARSER, group, overlay_dict, pipeline_to_json
159

1610
# In `devtool_opts`, we restrict both the set of CPUs on which the docker container's threads can run,
1711
# and its memory node. For the cpuset, we pick a continuous set of CPUs from a single NUMA node
@@ -96,37 +90,25 @@ def build_group(test):
9690
action="append",
9791
)
9892

99-
RUN_TESTS = True
100-
if REVISION_A is not None:
101-
changed_files = get_changed_files(f"{REVISION_A}..{REVISION_B}")
102-
# Our A/B-Testing setup by design only A/B-tests firecracker binaries.
103-
# So we only trigger A/B-tests on file changes that have impact on the firecracker
104-
# binary. These include ".rs" files, "Cargo.toml" and "Cargo.lock" files, as well
105-
# as ".cargo/config".
106-
RUN_TESTS = any(
107-
x.suffix in [".rs", ".toml", ".lock", "config"] for x in changed_files
108-
)
109-
11093
group_steps = []
11194

112-
if RUN_TESTS:
113-
args = parser.parse_args()
114-
tests = [perf_test[test] for test in args.test or perf_test.keys()]
115-
for test_data in tests:
116-
test_data.setdefault("platforms", args.platforms)
117-
test_data.setdefault("instances", args.instances)
118-
# use ag=1 instances to make sure no two performance tests are scheduled on the same instance
119-
test_data.setdefault("agents", {"ag": 1})
120-
test_data = overlay_dict(test_data, args.step_param)
121-
test_data["retry"] = {
122-
"automatic": [
123-
# Agent was lost, retry one time
124-
# this can happen if we terminate the instance or the agent gets
125-
# disconnected for whatever reason
126-
{"exit_status": -1, "limit": 1},
127-
]
128-
}
129-
group_steps.append(build_group(test_data))
95+
args = parser.parse_args()
96+
tests = [perf_test[test] for test in args.test or perf_test.keys()]
97+
for test_data in tests:
98+
test_data.setdefault("platforms", args.platforms)
99+
test_data.setdefault("instances", args.instances)
100+
# use ag=1 instances to make sure no two performance tests are scheduled on the same instance
101+
test_data.setdefault("agents", {"ag": 1})
102+
test_data = overlay_dict(test_data, args.step_param)
103+
test_data["retry"] = {
104+
"automatic": [
105+
# Agent was lost, retry one time
106+
# this can happen if we terminate the instance or the agent gets
107+
# disconnected for whatever reason
108+
{"exit_status": -1, "limit": 1},
109+
]
110+
}
111+
group_steps.append(build_group(test_data))
130112

131113
pipeline = {
132114
"env": {},

.github/workflows/trigger_ab_tests.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,34 @@ jobs:
99
runs-on: ubuntu-latest
1010
if: ${{ github.event.forced == false }}
1111
steps:
12+
- name: "Check out repository"
13+
uses: actions/checkout@v4
14+
with:
15+
# Required to make it fetch more than the just fetched commits (we need it to resolve at least one commit
16+
# _before_ what was pushed so that below "git diff" works.
17+
fetch-depth: 0
1218
- name: "Trigger Buildkite Pipeline"
1319
run: |
14-
curl -X POST https://api.buildkite.com/v2/organizations/firecracker/pipelines/performance-a-b-tests/builds \
15-
-H 'Content-Type: application/json' \
16-
-H 'Authorization: Bearer ${{ secrets.BUILDKITE_TOKEN }}' \
17-
-d "{
18-
\"commit\": \"HEAD\",
19-
\"branch\": \"$GITHUB_REF_NAME\",
20-
\"env\": {
21-
\"REVISION_A\": \"${{ github.event.before }}\",
22-
\"REVISION_B\": \"${{ github.event.after }}\"
23-
}
24-
}"
20+
should_schedule_ab_test=0
21+
# Iterates over all files modified in the just-merged PR. If any of them is rust-related (e.g. .rs, .toml,
22+
# .lock or .cargo/config) or a seccomp definition (resources/seccomp/*), sets `should_schedule_ab_test` to 1,
23+
# meaning we will schedule a build of the A/B-testing pipeline to check the just-merged PR for
24+
# performance regressions.
25+
for f in $(git --no-pager diff --name-only ${{ github.event.before }}..${{ github.event.after }}); do
26+
if [[ "$(basename $f)" =~ (\.(rs|toml|lock)|config)$ ]] || [[ "$f" ~= ^resources/seccomp/ ]]; then
27+
should_schedule_ab_test=1
28+
fi
29+
done
30+
if [[ $should_schedule_ab_test -eq 1 ]]; then
31+
curl -X POST https://api.buildkite.com/v2/organizations/firecracker/pipelines/performance-a-b-tests/builds \
32+
-H 'Content-Type: application/json' \
33+
-H 'Authorization: Bearer ${{ secrets.BUILDKITE_TOKEN }}' \
34+
-d "{
35+
\"commit\": \"HEAD\",
36+
\"branch\": \"$GITHUB_REF_NAME\",
37+
\"env\": {
38+
\"REVISION_A\": \"${{ github.event.before }}\",
39+
\"REVISION_B\": \"${{ github.event.after }}\"
40+
}
41+
}"
42+
fi

0 commit comments

Comments
 (0)