duel 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AGENT_PROMPT.md +51 -27
- data/CHANGELOG.md +247 -1
- data/README.md +30 -14
- data/docs/benchmarks.md +28 -24
- data/docs/ci.md +328 -362
- data/docs/configuration.md +40 -37
- data/docs/how-it-works.md +23 -10
- data/docs/json.md +21 -25
- data/docs/plugins.md +40 -22
- data/docs/troubleshooting.md +3 -2
- data/lib/duel/across.rb +18 -18
- data/lib/duel/badge.rb +174 -0
- data/lib/duel/baseline.rb +38 -15
- data/lib/duel/cli.rb +175 -107
- data/lib/duel/comment.rb +80 -71
- data/lib/duel/config.rb +145 -63
- data/lib/duel/context.rb +29 -24
- data/lib/duel/forge.rb +87 -0
- data/lib/duel/init.rb +44 -87
- data/lib/duel/json_report.rb +34 -25
- data/lib/duel/lane.rb +107 -61
- data/lib/duel/lock.rb +1 -1
- data/lib/duel/mark_passed.rb +132 -0
- data/lib/duel/metric.rb +28 -27
- data/lib/duel/native.rb +7 -5
- data/lib/duel/platform.rb +4 -0
- data/lib/duel/process_sample.rb +9 -6
- data/lib/duel/rake_task.rb +4 -5
- data/lib/duel/resource.rb +10 -11
- data/lib/duel/result.rb +22 -14
- data/lib/duel/rubies.rb +6 -2
- data/lib/duel/runner.rb +27 -15
- data/lib/duel/spawn.rb +29 -4
- data/lib/duel/stats.rb +14 -12
- data/lib/duel/summary.rb +31 -29
- data/lib/duel/templates/benchmark_duel.rb.erb +2 -2
- data/lib/duel/templates/duel.gitlab-ci.yml.erb +18 -54
- data/lib/duel/templates/duel.rb.erb +7 -7
- data/lib/duel/templates/perf-caller.yml.erb +22 -5
- data/lib/duel/templates/perf-comment.yml.erb +11 -11
- data/lib/duel/templates/perf-push-jobs.yml.erb +127 -0
- data/lib/duel/templates/perf-push.yml.erb +50 -0
- data/lib/duel/templates/perf.yml.erb +113 -335
- data/lib/duel/testing.rb +20 -25
- data/lib/duel/version.rb +1 -1
- data/lib/duel/worker.rb +16 -9
- data/lib/duel/worker_process.rb +6 -6
- data/lib/duel.rb +88 -33
- data/sig/duel/across.rbs +4 -0
- data/sig/duel/badge.rbs +51 -0
- data/sig/duel/baseline.rbs +7 -2
- data/sig/duel/cli.rbs +31 -20
- data/sig/duel/comment.rbs +14 -15
- data/sig/duel/config.rbs +71 -29
- data/sig/duel/context.rbs +4 -4
- data/sig/duel/forge.rbs +42 -0
- data/sig/duel/init.rbs +8 -26
- data/sig/duel/json_report.rbs +7 -6
- data/sig/duel/lane.rbs +29 -6
- data/sig/duel/mark_passed.rbs +39 -0
- data/sig/duel/metric.rbs +10 -10
- data/sig/duel/native.rbs +3 -0
- data/sig/duel/platform.rbs +1 -0
- data/sig/duel/process_sample.rbs +3 -0
- data/sig/duel/resource.rbs +3 -3
- data/sig/duel/result.rbs +12 -5
- data/sig/duel/rubies.rbs +3 -0
- data/sig/duel/runner.rbs +23 -16
- data/sig/duel/spawn.rbs +7 -0
- data/sig/duel/stats.rbs +4 -1
- data/sig/duel/summary.rbs +8 -0
- data/sig/duel/testing.rbs +2 -2
- data/sig/duel/worker.rbs +6 -5
- data/sig/duel/worker_process.rbs +3 -3
- data/sig/duel.rbs +50 -31
- metadata +9 -1
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
name: Duel
|
|
3
3
|
|
|
4
4
|
# Duel's Perf workflow, reusable: a project's own Perf workflow (as
|
|
5
|
-
# `duel init
|
|
5
|
+
# `duel init` writes it) calls it, with its triggers and its
|
|
6
6
|
# concurrency, and passes on what .duel.rb sets that it needs as its
|
|
7
|
-
# inputs. Its
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
7
|
+
# inputs. Its Duel job runs as the whole Perf workflow's that
|
|
8
|
+
# `duel init --standalone` writes does, and only reads (the caller
|
|
9
|
+
# grants contents: read, and pull-requests: read for the labels): it
|
|
10
|
+
# runs the branch's code. The jobs for a push, which write, are Duel's
|
|
11
|
+
# push workflow's (duel-push.yml), which the caller calls apart, with
|
|
12
|
+
# what this one's outputs say, and grants contents: write to alone. See
|
|
13
|
+
# Duel's docs/ci.md.
|
|
11
14
|
on:
|
|
12
15
|
workflow_call:
|
|
13
16
|
inputs:
|
|
@@ -19,12 +22,12 @@ on:
|
|
|
19
22
|
description: Whether each version runs on the Ruby its .ruby-version names (c.ruby = :version_file)
|
|
20
23
|
type: boolean
|
|
21
24
|
default: false
|
|
22
|
-
|
|
23
|
-
description:
|
|
24
|
-
type:
|
|
25
|
-
default:
|
|
25
|
+
jit:
|
|
26
|
+
description: The JIT the benchmarks run with on (Ruby runs one at most), none, yjit (RUBY_YJIT_ENABLE=1), or zjit (RUBY_ZJIT_ENABLE=1, on Ruby 4.0 or later)
|
|
27
|
+
type: string
|
|
28
|
+
default: none
|
|
26
29
|
runs-on:
|
|
27
|
-
description: The runner the Duel job runs on (a larger one, say, for steadier timings), Linux or
|
|
30
|
+
description: The runner the Duel job runs on (a larger one, say, for steadier timings), Linux, macOS or Windows
|
|
28
31
|
type: string
|
|
29
32
|
default: ubuntu-latest
|
|
30
33
|
timeout-minutes:
|
|
@@ -47,43 +50,16 @@ on:
|
|
|
47
50
|
description: Shell commands that set up what else the tests need (packages, services), before Ruby's
|
|
48
51
|
type: string
|
|
49
52
|
default: ""
|
|
50
|
-
|
|
51
|
-
description:
|
|
53
|
+
setup-after-ruby:
|
|
54
|
+
description: Shell commands that set up what needs Ruby first (on Windows, a package of Ruby's devkit, from pacman, say), before the bundle's installed
|
|
52
55
|
type: string
|
|
53
56
|
default: ""
|
|
54
|
-
|
|
55
|
-
description:
|
|
57
|
+
report:
|
|
58
|
+
description: A name for this call's report (yjit, say), where the workflow calls this one more than once. The Perf comment workflow comments with every call's, each under its name
|
|
56
59
|
type: string
|
|
57
60
|
default: ""
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
type: string
|
|
61
|
-
default: v*
|
|
62
|
-
comment-on-pushes:
|
|
63
|
-
description: Whether to comment on a pushed commit (c.fail_on = :pull_requests)
|
|
64
|
-
type: boolean
|
|
65
|
-
default: false
|
|
66
|
-
mark-passed:
|
|
67
|
-
description: Whether to mark a push passed (c.push_base = :last_passed)
|
|
68
|
-
type: boolean
|
|
69
|
-
default: false
|
|
70
|
-
badge:
|
|
71
|
-
description: Whether to keep a badge for the README
|
|
72
|
-
type: boolean
|
|
73
|
-
default: false
|
|
74
|
-
passed-branch:
|
|
75
|
-
description: What names the branches that mark the last commit Duel passed
|
|
76
|
-
type: string
|
|
77
|
-
default: duel/passed
|
|
78
|
-
badge-branch:
|
|
79
|
-
description: The branch that holds the badge
|
|
80
|
-
type: string
|
|
81
|
-
default: duel/badge
|
|
82
|
-
marker:
|
|
83
|
-
description: What marks Duel's comments
|
|
84
|
-
type: string
|
|
85
|
-
default: duel
|
|
86
|
-
# What Duel said, for the caller's own jobs (a notice, say).
|
|
61
|
+
# What Duel said, for Duel's push workflow (duel-push.yml), and the
|
|
62
|
+
# caller's own jobs (a notice, say).
|
|
87
63
|
outputs:
|
|
88
64
|
comment:
|
|
89
65
|
description: Whether Duel said to comment (post or change), or nothing
|
|
@@ -92,7 +68,7 @@ on:
|
|
|
92
68
|
description: The run's status (passed, failed or neutral), or nothing where Duel didn't get to compare
|
|
93
69
|
value: ${{ jobs.duel.outputs.status }}
|
|
94
70
|
passed:
|
|
95
|
-
description:
|
|
71
|
+
description: The branch to mark a push passed on, or nothing
|
|
96
72
|
value: ${{ jobs.duel.outputs.passed }}
|
|
97
73
|
|
|
98
74
|
<% else -%>
|
|
@@ -134,7 +110,7 @@ jobs:
|
|
|
134
110
|
runs-on: ubuntu-latest
|
|
135
111
|
<% end -%>
|
|
136
112
|
# Whether to comment (post, change or none), the run's status (passed,
|
|
137
|
-
# failed or neutral), and
|
|
113
|
+
# failed or neutral), and the branch to mark a push passed on (or
|
|
138
114
|
# nothing), from Duel.
|
|
139
115
|
outputs:
|
|
140
116
|
comment: ${{ steps.compare.outputs.comment }}
|
|
@@ -143,12 +119,19 @@ jobs:
|
|
|
143
119
|
<% if working_directory -%>
|
|
144
120
|
# The project is in a subdirectory of the repository: Duel runs there,
|
|
145
121
|
# and checks out the whole repository for the baseline.
|
|
122
|
+
<% end -%>
|
|
123
|
+
<% if working_directory || reusable? -%>
|
|
146
124
|
defaults:
|
|
147
125
|
run:
|
|
126
|
+
<% if reusable? -%>
|
|
127
|
+
shell: bash # (on every runner: on Windows, not PowerShell, but Git's, and once Ruby's set up, its devkit's)
|
|
128
|
+
<% end -%>
|
|
129
|
+
<% if working_directory -%>
|
|
148
130
|
working-directory: <%= working_directory %>
|
|
131
|
+
<% end -%>
|
|
149
132
|
<% end -%>
|
|
150
133
|
steps:
|
|
151
|
-
- uses: actions/checkout@v7
|
|
134
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
152
135
|
with:
|
|
153
136
|
fetch-depth: 0 # the baseline comes from history, tags included
|
|
154
137
|
persist-credentials: false
|
|
@@ -158,36 +141,18 @@ jobs:
|
|
|
158
141
|
# The labels of the pull request (or for a push, of the one that
|
|
159
142
|
# merged it), for c.accept_label in .duel.rb, as a JSON array. They're
|
|
160
143
|
# read as the job runs, and adding the label (or taking it off) runs
|
|
161
|
-
# the job again: see the Perf comment workflow.
|
|
162
|
-
|
|
163
|
-
#
|
|
164
|
-
# pull request with the label (ACCEPT_LABEL, as .duel.rb names it):
|
|
165
|
-
# what that slowed down was accepted, so it's compared with instead.
|
|
166
|
-
<% end -%>
|
|
144
|
+
# the job again: see the Perf comment workflow. (On a schedule, Duel
|
|
145
|
+
# finds the last change merged with the label since the last
|
|
146
|
+
# release itself.)
|
|
167
147
|
- name: Find the pull request's labels
|
|
168
148
|
id: labels
|
|
169
|
-
if: github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'push'
|
|
149
|
+
if: github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'push'
|
|
170
150
|
continue-on-error: true # (without them, nothing's accepted)
|
|
171
151
|
env:
|
|
172
152
|
GH_TOKEN: ${{ github.token }}
|
|
173
153
|
PR: ${{ github.event.pull_request.number }}
|
|
174
154
|
QUEUED: ${{ github.event.merge_group.head_ref }}
|
|
175
|
-
<% if accept_label -%>
|
|
176
|
-
ACCEPT_LABEL: '<%= accept_label.gsub("'", "''") %>'
|
|
177
|
-
RELEASE_TAGS: "<%= release_tags %>"
|
|
178
|
-
<% end -%>
|
|
179
155
|
run: |
|
|
180
|
-
<% if accept_label -%>
|
|
181
|
-
if [ "$GITHUB_EVENT_NAME" = schedule ]; then
|
|
182
|
-
tag=$(git describe --tags --abbrev=0 --match "$RELEASE_TAGS" HEAD^ 2>/dev/null) || exit 0
|
|
183
|
-
since=$(TZ=UTC git log -1 --date=format-local:%Y-%m-%dT%H:%M:%SZ --format=%cd "$tag")
|
|
184
|
-
merged=$(gh pr list --repo "$GITHUB_REPOSITORY" --state merged --label "$ACCEPT_LABEL" --search "merged:>=$since" --limit 1000 \
|
|
185
|
-
--json mergeCommit --jq '.[].mergeCommit.oid')
|
|
186
|
-
accepted=$(git rev-list "$tag..HEAD" | grep -Fx -m 1 -f <(echo "$merged")) || accepted=
|
|
187
|
-
echo "accepted=$accepted" >> "$GITHUB_OUTPUT"
|
|
188
|
-
exit 0
|
|
189
|
-
fi
|
|
190
|
-
<% end -%>
|
|
191
156
|
# (In a merge queue, the last pull request queued, which the queue's
|
|
192
157
|
# branch names: gh-readonly-queue/main/pr-123-<sha>.)
|
|
193
158
|
if [ -n "$QUEUED" ]; then
|
|
@@ -215,59 +180,78 @@ jobs:
|
|
|
215
180
|
if: inputs.gemfile != ''
|
|
216
181
|
env:
|
|
217
182
|
GEMFILE: ${{ inputs.gemfile }}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
183
|
+
# (On Windows, as C:/..., not bash's /c/..., which Ruby can't read.)
|
|
184
|
+
run: echo "BUNDLE_GEMFILE=$(pwd -W 2> /dev/null || pwd)/$GEMFILE" >> "$GITHUB_ENV"
|
|
185
|
+
# The JIT the caller says to turn on, YJIT or ZJIT, for every worker
|
|
186
|
+
# of both versions.
|
|
187
|
+
- name: Turn on the JIT
|
|
188
|
+
if: inputs.jit != 'none'
|
|
189
|
+
env:
|
|
190
|
+
JIT: ${{ inputs.jit }}
|
|
191
|
+
run: |
|
|
192
|
+
case "$JIT" in
|
|
193
|
+
yjit) echo "RUBY_YJIT_ENABLE=1" >> "$GITHUB_ENV" ;;
|
|
194
|
+
zjit) echo "RUBY_ZJIT_ENABLE=1" >> "$GITHUB_ENV" ;;
|
|
195
|
+
*) echo "::error::jit: $JIT: give none, yjit or zjit" && exit 1 ;;
|
|
196
|
+
esac
|
|
223
197
|
<% else -%>
|
|
224
198
|
# (And whatever else your tests need set up: packages, services.)
|
|
199
|
+
<% end -%>
|
|
200
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
201
|
+
id: ruby
|
|
202
|
+
with:
|
|
203
|
+
<% if working_directory -%>
|
|
204
|
+
working-directory: <%= working_directory %>
|
|
205
|
+
<% end -%>
|
|
206
|
+
<% if ruby_version -%>
|
|
207
|
+
ruby-version: "<%= ruby_version %>"
|
|
208
|
+
<% end -%>
|
|
209
|
+
<% if reusable? -%>
|
|
210
|
+
# (Or once what needs Ruby is set up: see below.)
|
|
211
|
+
bundler-cache: ${{ inputs.setup-after-ruby == '' }}
|
|
212
|
+
# What needs Ruby to set up, as the caller says (on Windows, a
|
|
213
|
+
# package of Ruby's devkit, from pacman, that a gem's native
|
|
214
|
+
# extension links, say), and then the bundle, which may need it.
|
|
215
|
+
- name: Set up, once Ruby is
|
|
216
|
+
if: inputs.setup-after-ruby != ''
|
|
217
|
+
env:
|
|
218
|
+
SETUP: ${{ inputs.setup-after-ruby }}
|
|
219
|
+
run: eval "$SETUP"
|
|
220
|
+
- name: Install the bundle
|
|
221
|
+
if: inputs.setup-after-ruby != ''
|
|
222
|
+
run: bundle install
|
|
223
|
+
<% else -%>
|
|
224
|
+
bundler-cache: true
|
|
225
225
|
<% end -%>
|
|
226
226
|
<% if version_file -%>
|
|
227
227
|
# Each version runs on the Ruby its own .ruby-version names (see
|
|
228
228
|
# .duel.rb). When the baseline's names another Ruby than this code's,
|
|
229
|
-
# that one is installed too, and linked where Duel
|
|
230
|
-
# chruby would),
|
|
231
|
-
#
|
|
232
|
-
#
|
|
233
|
-
# base, the commit before a push (or the last commit Duel passed, PASSED, if there is
|
|
234
|
-
# one: see the Mark the commit passed job), or on a schedule the last
|
|
235
|
-
# release, the newest tag before HEAD that RELEASE_TAGS matches<% if accept_label %>
|
|
236
|
-
# (or ACCEPTED, the last change accepted since then)<% end %>. (If
|
|
237
|
-
# .duel.rb sets c.main_branch or c.release_tags, set MAIN_BRANCH or
|
|
238
|
-
# RELEASE_TAGS to match.)
|
|
229
|
+
# that one is installed too, with its bundle, and linked where Duel
|
|
230
|
+
# finds it (as chruby would), and the project's own Ruby, which runs
|
|
231
|
+
# Duel, comes first again. The baseline is the one the Compare step
|
|
232
|
+
# compares with, as Duel finds it (duel base).
|
|
239
233
|
- name: Find the baseline's Ruby
|
|
240
234
|
id: baseline
|
|
241
235
|
<% if reusable? -%>
|
|
242
236
|
if: inputs.version-file
|
|
243
237
|
<% end -%>
|
|
244
238
|
env:
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
MAIN_BRANCH: origin/${{ github.base_ref || github.event.repository.default_branch }}
|
|
249
|
-
RELEASE_TAGS: "<%= release_tags %>"
|
|
250
|
-
<% if accept_label -%>
|
|
251
|
-
ACCEPTED: ${{ steps.labels.outputs.accepted }}
|
|
252
|
-
<% end -%>
|
|
239
|
+
# (On a schedule, for the last change a label accepted since the
|
|
240
|
+
# last release, which Duel finds with gh.)
|
|
241
|
+
GH_TOKEN: ${{ github.event_name == 'schedule' && github.token || '' }}
|
|
253
242
|
run: |
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
merge_group) base=$QUEUE_BASE ;;
|
|
259
|
-
schedule) base=${ACCEPTED:-$(git describe --tags --abbrev=0 --match "$RELEASE_TAGS" HEAD^ 2>/dev/null)} || base= ;;
|
|
260
|
-
*) base=$(git merge-base HEAD "$MAIN_BRANCH" 2>/dev/null) || base= ;;
|
|
261
|
-
esac
|
|
262
|
-
ruby_of() { git show "$1:./.ruby-version" 2>/dev/null | awk 'NF { print $1; exit }'; }
|
|
243
|
+
base=$(bundle exec duel base)
|
|
244
|
+
# (None where the commit has no .ruby-version: git fails, which
|
|
245
|
+
# fails the pipeline, under pipefail.)
|
|
246
|
+
ruby_of() { git show "$1:./.ruby-version" 2>/dev/null | awk 'NF { print $1; exit }' || true; }
|
|
263
247
|
ruby=
|
|
264
248
|
# (None without a baseline: a branch's first push, or no release yet.)
|
|
265
|
-
if [ -n "$base" ]
|
|
249
|
+
if [ -n "$base" ]; then
|
|
266
250
|
ruby=$(ruby_of "$base")
|
|
267
251
|
[ "$ruby" = "$(ruby_of HEAD)" ] && ruby=
|
|
268
252
|
fi
|
|
269
253
|
echo "ruby=$ruby" >> "$GITHUB_OUTPUT"
|
|
270
|
-
- uses: ruby/setup-ruby@v1
|
|
254
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
271
255
|
id: baseline-ruby
|
|
272
256
|
if: steps.baseline.outputs.ruby != ''
|
|
273
257
|
with:
|
|
@@ -277,42 +261,52 @@ jobs:
|
|
|
277
261
|
ruby-version: ${{ steps.baseline.outputs.ruby }}
|
|
278
262
|
# The bundle for this Ruby too, which the baseline's workers load.
|
|
279
263
|
# (Gems installed for one Ruby version don't load on another.)
|
|
264
|
+
<% if reusable? -%>
|
|
265
|
+
# (Or once what needs Ruby is set up: see below.)
|
|
266
|
+
bundler-cache: ${{ inputs.setup-after-ruby == '' }}
|
|
267
|
+
<% else -%>
|
|
280
268
|
bundler-cache: true
|
|
269
|
+
<% end -%>
|
|
281
270
|
- name: Link the baseline's Ruby where Duel finds it
|
|
282
271
|
if: steps.baseline.outputs.ruby != ''
|
|
283
272
|
env:
|
|
284
273
|
PREFIX: ${{ steps.baseline-ruby.outputs.ruby-prefix }}
|
|
274
|
+
RUBY_PREFIX: ${{ steps.ruby.outputs.ruby-prefix }}
|
|
275
|
+
<% if reusable? -%>
|
|
276
|
+
SETUP: ${{ inputs.setup-after-ruby }}
|
|
277
|
+
<% end -%>
|
|
278
|
+
MSYS: winsymlinks:nativestrict # (on Windows, bash's ln links, not copies)
|
|
285
279
|
run: |
|
|
280
|
+
<% if reusable? -%>
|
|
281
|
+
# (Its bundle, once what needs Ruby is set up: see above.)
|
|
282
|
+
if [ -n "$SETUP" ]; then bundle install; fi
|
|
283
|
+
<% end -%>
|
|
284
|
+
# (The project's own Ruby first again, for the steps after: it
|
|
285
|
+
# runs Duel.)
|
|
286
|
+
echo "$RUBY_PREFIX/bin" >> "$GITHUB_PATH"
|
|
287
|
+
# (On Windows, as bash's /c/..., not C:\..., which it can't run.)
|
|
288
|
+
if command -v cygpath > /dev/null; then PREFIX=$(cygpath -u "$PREFIX"); fi
|
|
286
289
|
mkdir -p ~/.rubies
|
|
287
290
|
ln -sfn "$PREFIX" ~/.rubies/ruby-"$("$PREFIX/bin/ruby" -e 'print RUBY_VERSION')"
|
|
288
291
|
<% end -%>
|
|
289
|
-
- uses: ruby/setup-ruby@v1
|
|
290
|
-
with:
|
|
291
|
-
<% if working_directory -%>
|
|
292
|
-
working-directory: <%= working_directory %>
|
|
293
|
-
<% end -%>
|
|
294
|
-
<% if ruby_version -%>
|
|
295
|
-
ruby-version: "<%= ruby_version %>"
|
|
296
|
-
<% end -%>
|
|
297
|
-
bundler-cache: true
|
|
298
292
|
# Against the branch it targets for a pull request, the queue's base
|
|
299
293
|
# for a merge queue, what was there before for a push (or as
|
|
300
294
|
# c.push_base in .duel.rb says, the last commit Duel passed), and the
|
|
301
|
-
# last release on a schedule (slow creep)
|
|
295
|
+
# last release on a schedule (slow creep), as Duel finds them, from
|
|
296
|
+
# the run's event. Duel adds its report to
|
|
302
297
|
# the job's summary, writes it to duel.md for the comment, and sets
|
|
303
298
|
# the step's outputs to say whether to comment, as c.comment in
|
|
304
299
|
# .duel.rb says, whatever the outcome.
|
|
305
300
|
- name: Compare
|
|
306
301
|
id: compare
|
|
307
302
|
env:
|
|
308
|
-
DUEL_BASE: ${{ github.event_name == 'schedule' && 'last-release' || github.event_name == 'push' && github.event.before || github.event_name == 'merge_group' && github.event.merge_group.base_sha || '' }}
|
|
309
303
|
# (Run by hand, it compares anyway: with nothing changed, the code
|
|
310
304
|
# with itself, which checks the setup.)
|
|
311
305
|
DUEL_FORCE: ${{ github.event_name == 'workflow_dispatch' && '1' || '' }}
|
|
312
306
|
DUEL_LABELS: ${{ steps.labels.outputs.labels }}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
307
|
+
# (On a schedule, for the last change a label accepted since the
|
|
308
|
+
# last release, which Duel finds with gh.)
|
|
309
|
+
GH_TOKEN: ${{ github.event_name == 'schedule' && github.token || '' }}
|
|
316
310
|
run: bundle exec duel --markdown "$RUNNER_TEMP/duel/duel.md"
|
|
317
311
|
# For a pull request, what Duel said, for the Perf comment workflow,
|
|
318
312
|
# which can't see this job's outputs.
|
|
@@ -328,229 +322,13 @@ jobs:
|
|
|
328
322
|
# The report, for the comments.
|
|
329
323
|
- name: Keep the report
|
|
330
324
|
if: ${{ !cancelled() && (github.event_name == 'pull_request' || github.event_name == 'push') }}
|
|
331
|
-
uses: actions/upload-artifact@v7
|
|
325
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
332
326
|
with:
|
|
333
327
|
name: duel-report<%= "${{ inputs.report != '' && format('-{0}', inputs.report) || '' }}" if reusable? %>
|
|
334
328
|
path: ${{ runner.temp }}/duel/
|
|
335
329
|
if-no-files-found: ignore # none when Duel didn't get to compare
|
|
336
330
|
retention-days: 1
|
|
337
|
-
<%
|
|
331
|
+
<% unless reusable? -%>
|
|
338
332
|
|
|
339
|
-
|
|
340
|
-
# author, when Duel says to, as for a pull request (see the Perf comment
|
|
341
|
-
# workflow). It does only where a regression in a push passes, with
|
|
342
|
-
# c.fail_on = :pull_requests in .duel.rb, so the comment says what the
|
|
343
|
-
# check doesn't. Its last comment is the last one on any commit. This
|
|
344
|
-
# job checks nothing out and runs none of the code.
|
|
345
|
-
commit-comment:
|
|
346
|
-
name: Comment on the commit
|
|
347
|
-
needs: duel
|
|
348
|
-
if: ${{ <%= "inputs.comment-on-pushes && " if reusable? %>!cancelled() && github.event_name == 'push' && (needs.duel.outputs.comment == 'post' || needs.duel.outputs.comment == 'change') }}
|
|
349
|
-
runs-on: ubuntu-latest
|
|
350
|
-
permissions:
|
|
351
|
-
contents: write # to comment on the commit with the report
|
|
352
|
-
steps:
|
|
353
|
-
- name: Get the report
|
|
354
|
-
id: report
|
|
355
|
-
continue-on-error: true # there's none when the Duel job failed before comparing
|
|
356
|
-
uses: actions/download-artifact@v8
|
|
357
|
-
with:
|
|
358
|
-
name: duel-report<%= "${{ inputs.report != '' && format('-{0}', inputs.report) || '' }}" if reusable? %>
|
|
359
|
-
path: ${{ runner.temp }}/report
|
|
360
|
-
- name: Comment on the commit
|
|
361
|
-
if: steps.report.outcome == 'success'
|
|
362
|
-
env:
|
|
363
|
-
GH_TOKEN: ${{ github.token }}
|
|
364
|
-
COMMENT: ${{ needs.duel.outputs.comment }}
|
|
365
|
-
STATUS: ${{ needs.duel.outputs.status }}
|
|
366
|
-
<% if reusable? -%>
|
|
367
|
-
MARKER: ${{ inputs.marker }}
|
|
368
|
-
<% end -%>
|
|
369
|
-
run: |
|
|
370
|
-
marker="<!-- <%= reusable? ? "$MARKER" : marker %>"
|
|
371
|
-
last=$(gh api --paginate "repos/$GITHUB_REPOSITORY/comments" \
|
|
372
|
-
--jq ".[] | select(.user.login == \"github-actions[bot]\") | .body | split(\"\n\")[0] | rtrimstr(\"\r\") | select(startswith(\"$marker status=\"))" | tail -n 1)
|
|
373
|
-
if [ "$COMMENT" = post ] || { [ -n "$last" ] && [ "$last" != "$marker status=$STATUS -->" ]; }; then
|
|
374
|
-
{ echo "$marker status=$STATUS -->"; cat "$RUNNER_TEMP/report/duel.md"; } > "$RUNNER_TEMP/comment.md"
|
|
375
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
|
|
376
|
-
fi
|
|
377
|
-
<% end -%>
|
|
378
|
-
<% if mark_passed? -%>
|
|
379
|
-
|
|
380
|
-
# With c.push_base = :last_passed in .duel.rb, a push is compared with
|
|
381
|
-
# the last commit Duel passed, which a branch marks (each branch pushed
|
|
382
|
-
# has its own), so slowdowns too small for any one push to fail add up
|
|
383
|
-
# until they fail one. This job moves the branch to a push that passed
|
|
384
|
-
# (or makes it), but never back: where a newer push's run moved it
|
|
385
|
-
# first, it stays. It checks nothing out and runs none of the code. To
|
|
386
|
-
# accept a regression, move the branch yourself (for main, git push
|
|
387
|
-
# origin main:<%= passed_branch %>/main).
|
|
388
|
-
passed:
|
|
389
|
-
name: Mark the commit passed
|
|
390
|
-
needs: duel
|
|
391
|
-
# One at a time for each branch, so that two runs can't both find no
|
|
392
|
-
# branch and race to make it (a push's run doesn't wait for the one
|
|
393
|
-
# before it). One that's running is never cancelled, and one that's
|
|
394
|
-
# waiting gives way to a newer push's, which moves it further anyway.
|
|
395
|
-
concurrency:
|
|
396
|
-
group: ${{ github.workflow }}-passed-${{ github.ref_name }}
|
|
397
|
-
cancel-in-progress: false
|
|
398
|
-
if: ${{ <%= "inputs.mark-passed && " if reusable? %>!cancelled() && github.event_name == 'push' && needs.duel.outputs.passed == 'true' }}
|
|
399
|
-
runs-on: ubuntu-latest
|
|
400
|
-
permissions:
|
|
401
|
-
contents: write # to move the branch
|
|
402
|
-
steps:
|
|
403
|
-
- name: Move the branch to the commit
|
|
404
|
-
env:
|
|
405
|
-
GH_TOKEN: ${{ github.token }}
|
|
406
|
-
BRANCH: <%= passed_branch %>/${{ github.ref_name }}
|
|
407
|
-
run: |
|
|
408
|
-
# (Git can't make a branch where another's name is a folder of its
|
|
409
|
-
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
410
|
-
# this names it.)
|
|
411
|
-
blocked() {
|
|
412
|
-
prefix=$BRANCH
|
|
413
|
-
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
414
|
-
prefix=${prefix%/*}
|
|
415
|
-
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
416
|
-
echo "::error::The branch $prefix keeps Duel from making $BRANCH, as Git can't have both. Delete it (git push origin --delete $prefix), or rename it."
|
|
417
|
-
fi
|
|
418
|
-
done
|
|
419
|
-
exit 1
|
|
420
|
-
}
|
|
421
|
-
# (Forward: GitHub moves it only where it's behind the push. Where
|
|
422
|
-
# there's no branch, and making it fails, it looks once more, as
|
|
423
|
-
# something else may have made it: a push of it, say.)
|
|
424
|
-
for _ in 1 2; do
|
|
425
|
-
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null 2>&1 && exit 0
|
|
426
|
-
at=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$BRANCH" --jq .object.sha 2>/dev/null) || at=
|
|
427
|
-
[ -n "$at" ] && break
|
|
428
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null && exit 0
|
|
429
|
-
done
|
|
430
|
-
[ -n "$at" ] || blocked
|
|
431
|
-
compared=$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$at" --jq .status 2>&1) || case "$compared" in
|
|
432
|
-
# (GitHub can't compare commits with no history in common.)
|
|
433
|
-
*"No common ancestor"*) compared=unrelated ;;
|
|
434
|
-
esac
|
|
435
|
-
case "$compared" in
|
|
436
|
-
# (A newer push's run moved it, or this one's did, run again.)
|
|
437
|
-
ahead | identical) ;;
|
|
438
|
-
# (History rewritten, a force push's, say, or replaced: moved anyway.)
|
|
439
|
-
diverged | behind | unrelated) gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null ;;
|
|
440
|
-
*) echo "::error::Couldn't compare $BRANCH with this push: $compared" && exit 1 ;;
|
|
441
|
-
esac
|
|
442
|
-
<% end -%>
|
|
443
|
-
<% if badge? -%>
|
|
444
|
-
|
|
445
|
-
# Duel's badge, for the README: green (perf guarded), red (perf
|
|
446
|
-
# regressed) or grey (not measured), as the last push to the default
|
|
447
|
-
# branch that Duel compared left it. It's red where Duel failed the push
|
|
448
|
-
# or found a regression, even one that passed (with
|
|
449
|
-
# c.fail_on = :pull_requests in .duel.rb), and grey where the Duel job
|
|
450
|
-
# failed before Duel could judge the push (its runner ran out of memory,
|
|
451
|
-
# say). A push with nothing to compare leaves it as it was, and so does
|
|
452
|
-
# a run for an older push than the badge's. This job writes the badge,
|
|
453
|
-
# alone, to a branch of its own, which the README shows:
|
|
454
|
-
#
|
|
455
|
-
# [](https://github.com/sferik/duel-ruby)
|
|
456
|
-
#
|
|
457
|
-
# It checks nothing out, runs none of the code, and fetches nothing.
|
|
458
|
-
badge:
|
|
459
|
-
name: Update the badge
|
|
460
|
-
needs: duel
|
|
461
|
-
# One at a time, so that one run's check of which push the badge
|
|
462
|
-
# shows can't interleave with another run's write (a push's run
|
|
463
|
-
# doesn't wait for the one before it). A badge job that's running is
|
|
464
|
-
# never cancelled, and one that's waiting gives way to a newer push's,
|
|
465
|
-
# whose result the badge should show anyway.
|
|
466
|
-
concurrency:
|
|
467
|
-
group: ${{ github.workflow }}-badge
|
|
468
|
-
cancel-in-progress: false
|
|
469
|
-
if: ${{ <%= "inputs.badge && " if reusable? %>!cancelled() && github.event_name == 'push' && github.ref_name == github.event.repository.default_branch && (needs.duel.result == 'failure' || needs.duel.outputs.status == 'passed' || needs.duel.outputs.status == 'failed') }}
|
|
470
|
-
runs-on: ubuntu-latest
|
|
471
|
-
permissions:
|
|
472
|
-
contents: write # to move the badge's branch
|
|
473
|
-
steps:
|
|
474
|
-
- name: Update the badge
|
|
475
|
-
env:
|
|
476
|
-
GH_TOKEN: ${{ github.token }}
|
|
477
|
-
BRANCH: <%= badge_branch %>
|
|
478
|
-
RESULT: ${{ needs.duel.result }}
|
|
479
|
-
STATUS: ${{ needs.duel.outputs.status }}
|
|
480
|
-
run: |
|
|
481
|
-
# (Git can't make a branch where another's name is a folder of its
|
|
482
|
-
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
483
|
-
# this names it.)
|
|
484
|
-
blocked() {
|
|
485
|
-
prefix=$BRANCH
|
|
486
|
-
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
487
|
-
prefix=${prefix%/*}
|
|
488
|
-
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
489
|
-
echo "::error::The branch $prefix keeps Duel from making $BRANCH, as Git can't have both. Delete it (git push origin --delete $prefix), or rename it."
|
|
490
|
-
fi
|
|
491
|
-
done
|
|
492
|
-
exit 1
|
|
493
|
-
}
|
|
494
|
-
# (Where the badge is a newer push's, that push's run has the say.
|
|
495
|
-
# Its commit names the push.)
|
|
496
|
-
last=$(gh api "repos/$GITHUB_REPOSITORY/commits/$BRANCH" --jq .commit.message 2>/dev/null | sed -n 's/^Duel.s badge, for \([0-9a-f]*\)$/\1/p') || true
|
|
497
|
-
if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
|
|
498
|
-
# (Its image, written here rather than fetched from anywhere: green,
|
|
499
|
-
# red where Duel failed the push or found a regression, or grey
|
|
500
|
-
# where the Duel job failed before Duel said either.)
|
|
501
|
-
state="perf guarded" width=133 top="#34D058" bottom="#28A745" right="76.939C78.629 0 80 1.343 80"
|
|
502
|
-
if [ "$STATUS" = failed ]; then
|
|
503
|
-
state="perf regressed" width=142 top="#EA4A5A" bottom="#D73A49" right="85.939C87.629 0 89 1.343 89"
|
|
504
|
-
elif [ "$RESULT" = failure ] && [ "$STATUS" != passed ]; then
|
|
505
|
-
state="not measured" width=138 top="#959DA5" bottom="#6A737D" right="81.939C83.629 0 85 1.343 85"
|
|
506
|
-
fi
|
|
507
|
-
cat > "$RUNNER_TEMP/badge.svg" <<SVG
|
|
508
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="$width" height="20">
|
|
509
|
-
<title>Duel - $state</title>
|
|
510
|
-
<defs>
|
|
511
|
-
<linearGradient id="duel-fill" x1="50%" y1="0%" x2="50%" y2="100%">
|
|
512
|
-
<stop stop-color="#444D56" offset="0%"></stop>
|
|
513
|
-
<stop stop-color="#24292E" offset="100%"></stop>
|
|
514
|
-
</linearGradient>
|
|
515
|
-
<linearGradient id="state-fill" x1="50%" y1="0%" x2="50%" y2="100%">
|
|
516
|
-
<stop stop-color="$top" offset="0%"></stop>
|
|
517
|
-
<stop stop-color="$bottom" offset="100%"></stop>
|
|
518
|
-
</linearGradient>
|
|
519
|
-
</defs>
|
|
520
|
-
<g fill="none" fill-rule="evenodd">
|
|
521
|
-
<g font-family="'DejaVu Sans',Verdana,Geneva,sans-serif" font-size="11">
|
|
522
|
-
<path d="M0,3 C0,1.3431 1.3552,0 3.02702703,0 L53,0 L53,20 L3.02702703,20 C1.3552,20 0,18.6569 0,17 L0,3 Z" fill="url(#duel-fill)" fill-rule="nonzero"></path>
|
|
523
|
-
<text fill="#010101" fill-opacity=".3">
|
|
524
|
-
<tspan x="22.1981982" y="15" aria-hidden="true">Duel</tspan>
|
|
525
|
-
</text>
|
|
526
|
-
<text fill="#FFFFFF">
|
|
527
|
-
<tspan x="22.1981982" y="14">Duel</tspan>
|
|
528
|
-
</text>
|
|
529
|
-
</g>
|
|
530
|
-
<g transform="translate(53)" font-family="'DejaVu Sans',Verdana,Geneva,sans-serif" font-size="11">
|
|
531
|
-
<path d="M0 0h$right 3v14c0 1.657-1.37 3-3.061 3H0V0z" fill="url(#state-fill)" fill-rule="nonzero"></path>
|
|
532
|
-
<text fill="#010101" fill-opacity=".3" aria-hidden="true">
|
|
533
|
-
<tspan x="4" y="15">$state</tspan>
|
|
534
|
-
</text>
|
|
535
|
-
<text fill="#FFFFFF">
|
|
536
|
-
<tspan x="4" y="14">$state</tspan>
|
|
537
|
-
</text>
|
|
538
|
-
</g>
|
|
539
|
-
<g fill="#959DA5">
|
|
540
|
-
<path d="M4.6 3.6L6.9 4.5L14.3 11.9L12.9 13.3L5.5 5.9Z M17.4 3.6L15.1 4.5L7.7 11.9L9.1 13.3L16.5 5.9Z"></path>
|
|
541
|
-
<circle cx="16.6" cy="15.6" r="1.1"></circle>
|
|
542
|
-
<circle cx="5.4" cy="15.6" r="1.1"></circle>
|
|
543
|
-
</g>
|
|
544
|
-
<g stroke="#959DA5" stroke-linecap="round">
|
|
545
|
-
<path d="M12.1 14.5L15.5 11.1 M9.9 14.5L6.5 11.1" stroke-width="1.6"></path>
|
|
546
|
-
<path d="M13.8 12.8L16 15 M8.2 12.8L6 15" stroke-width="1.8"></path>
|
|
547
|
-
</g>
|
|
548
|
-
</g>
|
|
549
|
-
</svg>
|
|
550
|
-
SVG
|
|
551
|
-
tree=$(jq -n --rawfile svg "$RUNNER_TEMP/badge.svg" '{tree: [{path: "badge.svg", mode: "100644", type: "blob", content: $svg}]}' |
|
|
552
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/git/trees" --input - --jq .sha)
|
|
553
|
-
commit=$(gh api --method POST "repos/$GITHUB_REPOSITORY/git/commits" -f message="Duel's badge, for $GITHUB_SHA" -f tree="$tree" --jq .sha)
|
|
554
|
-
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$commit" -F force=true > /dev/null 2>&1 ||
|
|
555
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$commit" > /dev/null || blocked
|
|
333
|
+
<%= render("perf-push-jobs.yml") -%>
|
|
556
334
|
<% end -%>
|