Skip to content

Commit fbaf37a

Browse files
alexeyrclaude
andcommitted
Generate the skipped benchmark matrix row from a real suite
Build the no-suite-selected placeholder via suite_row (overriding only suite_id and a friendly job_name) instead of hand-maintaining a parallel EMPTY_MATRIX_ROW literal. This guarantees the placeholder shares a real row's exact key set (the matrix include: requires it, and the workflow reads matrix.<field> on the skipped path too) and emits the same string pro_env/generate_packs values real rows produce. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 3e1ee83 commit fbaf37a

2 files changed

Lines changed: 12 additions & 24 deletions

File tree

benchmarks/generate_matrix.rb

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -70,28 +70,6 @@
7070
}
7171
].freeze
7272

73-
EMPTY_MATRIX_ROW = {
74-
suite_id: "none",
75-
suite_name: "No benchmark suite",
76-
job_name: "Benchmark suites skipped",
77-
shard_index: 0,
78-
shard_total: 1,
79-
shard_label: "1/1",
80-
bencher_suite_name: "No benchmark suite",
81-
report_marker: "<!-- BENCHER_REPORT_SKIPPED -->",
82-
app_directory: ".",
83-
artifact_name_prefix: "benchmark-skipped",
84-
artifact_name_suffix: "",
85-
benchmark_tool: "none",
86-
benchmark_script: "",
87-
benchmark_timeout_minutes: 1,
88-
pro_env: false,
89-
generate_packs: false,
90-
server_kind: "none",
91-
summary_file: "",
92-
summary_title: ""
93-
}.freeze
94-
9573
# Every app_version any suite accepts. The workflow_dispatch input is constrained
9674
# to these, but validating guards against a typo or future rename silently
9775
# selecting no suites (which would skip benchmarks while CI stays green).
@@ -219,6 +197,14 @@ def report_marker(suite, suite_prefix, shard_slug)
219197
suite[:report_marker] || "<!-- BENCHER_REPORT_#{suite_prefix}_#{shard_slug.upcase.tr('-', '_')} -->"
220198
end
221199

200+
# No suite selected: emit one row so the matrix `include:` stays non-empty and all
201+
# rows share keys. Built from a real suite (any will do — its job is gated off via
202+
# run_benchmark_suites) with the "none" sentinel the gate keys on; the friendlier
203+
# job_name is all that's user-visible, as the skipped job's label.
204+
def empty_matrix_row
205+
suite_rows(SUITES.first).first.merge(suite_id: "none", job_name: "Benchmark suites skipped")
206+
end
207+
222208
def build_matrix
223209
labels = pull_request_labels
224210
rows = if truthy_env?("BENCHMARK_NON_RUNTIME_ONLY")
@@ -227,7 +213,7 @@ def build_matrix
227213
SUITES.select { |suite| suite_enabled?(suite, labels) }.flat_map { |suite| suite_rows(suite) }
228214
end
229215

230-
{ include: rows.empty? ? [EMPTY_MATRIX_ROW] : rows }
216+
{ include: rows.empty? ? [empty_matrix_row] : rows }
231217
end
232218

233219
# Only emit when run as a script; `require`-ing the file (e.g. from specs) just

benchmarks/spec/benchmark_matrix_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def suite_ids_for(env)
3030
)
3131

3232
expect(rows.size).to eq(1)
33-
expect(rows.first).to include(suite_id: "none", benchmark_tool: "none")
33+
# suite_id "none" is the only load-bearing field (it drives
34+
# run_benchmark_suites); the placeholder is otherwise a real row's shape.
35+
expect(rows.first).to include(suite_id: "none")
3436
end
3537

3638
it "forces the placeholder for non-runtime-only changes regardless of other inputs" do

0 commit comments

Comments
 (0)