duel 0.1.1 → 0.1.3
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/CHANGELOG.md +134 -1
- data/README.md +42 -7
- data/docs/benchmarks.md +2 -1
- data/docs/ci.md +630 -61
- data/docs/configuration.md +91 -4
- data/docs/how-it-works.md +34 -5
- data/docs/json.md +2 -0
- data/docs/plugins.md +2 -2
- data/docs/troubleshooting.md +14 -0
- data/lib/duel/baseline.rb +34 -8
- data/lib/duel/cli.rb +174 -29
- data/lib/duel/config.rb +84 -6
- data/lib/duel/context.rb +6 -5
- data/lib/duel/init.rb +45 -7
- data/lib/duel/json_report.rb +4 -3
- data/lib/duel/lock.rb +52 -8
- data/lib/duel/native.rb +20 -0
- data/lib/duel/resource.rb +37 -2
- data/lib/duel/runner.rb +98 -9
- data/lib/duel/summary.rb +8 -3
- data/lib/duel/templates/duel.gitlab-ci.yml.erb +167 -0
- data/lib/duel/templates/duel.rb.erb +13 -0
- data/lib/duel/templates/perf-comment.yml.erb +59 -0
- data/lib/duel/templates/perf.yml.erb +196 -46
- data/lib/duel/testing.rb +2 -2
- data/lib/duel/version.rb +1 -1
- data/lib/duel/worker.rb +1 -1
- data/sig/duel/baseline.rbs +14 -1
- data/sig/duel/cli.rbs +64 -2
- data/sig/duel/config.rbs +39 -0
- data/sig/duel/init.rbs +16 -0
- data/sig/duel/lock.rbs +11 -0
- data/sig/duel/native.rbs +2 -0
- data/sig/duel/resource.rbs +10 -1
- data/sig/duel/runner.rbs +50 -3
- data/sig/duel/summary.rbs +6 -1
- metadata +3 -1
|
@@ -1,27 +1,40 @@
|
|
|
1
|
-
name: Perf
|
|
1
|
+
name: Perf<%= " (#{working_directory})" if working_directory %>
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
pull_request:
|
|
5
|
+
merge_group: # (a merge queue's)
|
|
5
6
|
push:
|
|
6
|
-
branches: [main]
|
|
7
|
+
branches: [main] # (and any other branch to guard, a stable one, say)
|
|
7
8
|
schedule:
|
|
8
9
|
- cron: "0 4 * * *"
|
|
9
10
|
workflow_dispatch:
|
|
10
11
|
|
|
12
|
+
# A pull request's newer push cancels its run, if that's still going, as
|
|
13
|
+
# only its newest commit's result counts. Every other run (a push's, say)
|
|
14
|
+
# runs to the end, so that each push is compared.
|
|
15
|
+
concurrency:
|
|
16
|
+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
|
|
17
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
18
|
+
|
|
11
19
|
# The Duel job runs the branch's code (its benchmarks too), so it only
|
|
12
|
-
# reads. Commenting is the Comment job's, which
|
|
20
|
+
# reads. Commenting on a commit is the Comment on the commit job's, which
|
|
21
|
+
# runs none of it, and commenting on a pull request is the Perf comment
|
|
22
|
+
# workflow's.
|
|
13
23
|
permissions:
|
|
14
24
|
contents: read
|
|
25
|
+
pull-requests: read # for the pull request's labels (see c.accept_label)
|
|
15
26
|
|
|
16
27
|
jobs:
|
|
17
28
|
duel:
|
|
18
29
|
name: Duel
|
|
19
30
|
runs-on: ubuntu-latest
|
|
20
|
-
# Whether
|
|
21
|
-
#
|
|
31
|
+
# Whether to comment (post, change or none), the run's status (passed,
|
|
32
|
+
# failed or neutral), and whether to mark a push passed (true, or
|
|
33
|
+
# nothing), from Duel.
|
|
22
34
|
outputs:
|
|
23
35
|
comment: ${{ steps.compare.outputs.comment }}
|
|
24
36
|
status: ${{ steps.compare.outputs.status }}
|
|
37
|
+
passed: ${{ steps.compare.outputs.passed }}
|
|
25
38
|
<% if working_directory -%>
|
|
26
39
|
# The project is in a subdirectory of the repository: Duel runs there,
|
|
27
40
|
# and checks out the whole repository for the baseline.
|
|
@@ -40,20 +53,27 @@ jobs:
|
|
|
40
53
|
# .duel.rb). When the baseline's names another Ruby than this code's,
|
|
41
54
|
# that one is installed too, and linked where Duel finds it (as
|
|
42
55
|
# chruby would), before the project's own Ruby, which runs Duel. The
|
|
43
|
-
# baseline is the Compare step's: where HEAD left the
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
#
|
|
56
|
+
# baseline is the Compare step's: where HEAD left the branch a pull
|
|
57
|
+
# request targets (or run by hand, the main branch), a merge queue's
|
|
58
|
+
# base, the commit before a push (or the last commit Duel passed, PASSED, if there is
|
|
59
|
+
# one: see the Mark the commit passed job), or on a schedule the last
|
|
60
|
+
# release, the newest tag before HEAD that RELEASE_TAGS matches. (If
|
|
61
|
+
# .duel.rb sets c.main_branch or c.release_tags, set MAIN_BRANCH or
|
|
62
|
+
# RELEASE_TAGS to match.)
|
|
48
63
|
- name: Find the baseline's Ruby
|
|
49
64
|
id: baseline
|
|
50
65
|
env:
|
|
51
66
|
BEFORE: ${{ github.event.before }}
|
|
52
|
-
|
|
67
|
+
QUEUE_BASE: ${{ github.event.merge_group.base_sha }}
|
|
68
|
+
PASSED: origin/<%= passed_branch %>/${{ github.ref_name }}
|
|
69
|
+
MAIN_BRANCH: origin/${{ github.base_ref || github.event.repository.default_branch }}
|
|
53
70
|
RELEASE_TAGS: "<%= release_tags %>"
|
|
54
71
|
run: |
|
|
55
72
|
case "$GITHUB_EVENT_NAME" in
|
|
56
|
-
push)
|
|
73
|
+
push)
|
|
74
|
+
base=$BEFORE
|
|
75
|
+
if git merge-base --is-ancestor "$PASSED" HEAD 2>/dev/null; then base=$PASSED; fi ;;
|
|
76
|
+
merge_group) base=$QUEUE_BASE ;;
|
|
57
77
|
schedule) base=$(git describe --tags --abbrev=0 --match "$RELEASE_TAGS" HEAD^ 2>/dev/null) || base= ;;
|
|
58
78
|
*) base=$(git merge-base HEAD "$MAIN_BRANCH" 2>/dev/null) || base= ;;
|
|
59
79
|
esac
|
|
@@ -93,50 +113,80 @@ jobs:
|
|
|
93
113
|
ruby-version: "<%= ruby_version %>"
|
|
94
114
|
<% end -%>
|
|
95
115
|
bundler-cache: true
|
|
96
|
-
#
|
|
97
|
-
#
|
|
98
|
-
#
|
|
99
|
-
|
|
100
|
-
|
|
116
|
+
# The labels of the pull request (or for a push, of the one that
|
|
117
|
+
# merged it), for c.accept_label in .duel.rb, as a JSON array. They're
|
|
118
|
+
# read as the job runs, so after adding the label, run it again.
|
|
119
|
+
- name: Find the pull request's labels
|
|
120
|
+
id: labels
|
|
121
|
+
if: github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'push'
|
|
122
|
+
continue-on-error: true # (without them, nothing's accepted)
|
|
123
|
+
env:
|
|
124
|
+
GH_TOKEN: ${{ github.token }}
|
|
125
|
+
PR: ${{ github.event.pull_request.number }}
|
|
126
|
+
QUEUED: ${{ github.event.merge_group.head_ref }}
|
|
127
|
+
run: |
|
|
128
|
+
# (In a merge queue, the last pull request queued, which the queue's
|
|
129
|
+
# branch names: gh-readonly-queue/main/pr-123-<sha>.)
|
|
130
|
+
if [ -n "$QUEUED" ]; then
|
|
131
|
+
PR=${QUEUED##*/pr-}
|
|
132
|
+
PR=${PR%%-*}
|
|
133
|
+
fi
|
|
134
|
+
if [ -n "$PR" ]; then
|
|
135
|
+
labels=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR/labels" --jq '[.[].name]')
|
|
136
|
+
else
|
|
137
|
+
labels=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" --jq '[.[0].labels[]?.name]')
|
|
138
|
+
fi
|
|
139
|
+
echo "labels=$labels" >> "$GITHUB_OUTPUT"
|
|
140
|
+
# Against the branch it targets for a pull request, the queue's base
|
|
141
|
+
# for a merge queue, what was there before for a push (or as
|
|
142
|
+
# c.push_base in .duel.rb says, the last commit Duel passed), and the
|
|
143
|
+
# last release on a schedule (slow creep). Duel adds its report to
|
|
144
|
+
# the job's summary, writes it to duel.md for the comment, and sets
|
|
145
|
+
# the step's outputs to say whether to comment, as c.comment in
|
|
146
|
+
# .duel.rb says, whatever the outcome.
|
|
101
147
|
- name: Compare
|
|
102
148
|
id: compare
|
|
103
149
|
env:
|
|
104
|
-
DUEL_BASE: ${{ github.event_name == 'schedule' && 'last-release' || github.event_name == 'push' && github.event.before || '' }}
|
|
150
|
+
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 || '' }}
|
|
105
151
|
# (Run by hand, it compares anyway: with nothing changed, the code
|
|
106
152
|
# with itself, which checks the setup.)
|
|
107
153
|
DUEL_FORCE: ${{ github.event_name == 'workflow_dispatch' && '1' || '' }}
|
|
154
|
+
DUEL_LABELS: ${{ steps.labels.outputs.labels }}
|
|
155
|
+
run: bundle exec duel --markdown "$RUNNER_TEMP/duel/duel.md"
|
|
156
|
+
# For a pull request, what Duel said, for the Perf comment workflow,
|
|
157
|
+
# which can't see this job's outputs.
|
|
158
|
+
- name: Say whether to comment
|
|
159
|
+
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
|
|
160
|
+
env:
|
|
161
|
+
PR: ${{ github.event.pull_request.number }}
|
|
162
|
+
COMMENT: ${{ steps.compare.outputs.comment }}
|
|
163
|
+
STATUS: ${{ steps.compare.outputs.status }}
|
|
108
164
|
run: |
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
echo "::notice::No commit before this push to compare against"
|
|
113
|
-
exit 0
|
|
114
|
-
fi
|
|
115
|
-
bundle exec duel --markdown "$RUNNER_TEMP/duel.md"
|
|
116
|
-
# The report, for the Comment job.
|
|
165
|
+
mkdir -p "$RUNNER_TEMP/duel"
|
|
166
|
+
printf 'pr=%s\ncomment=%s\nstatus=%s\n' "$PR" "$COMMENT" "$STATUS" > "$RUNNER_TEMP/duel/comment.env"
|
|
167
|
+
# The report, for the comments.
|
|
117
168
|
- name: Keep the report
|
|
118
|
-
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
|
|
169
|
+
if: ${{ !cancelled() && (github.event_name == 'pull_request' || github.event_name == 'push') }}
|
|
119
170
|
uses: actions/upload-artifact@v7
|
|
120
171
|
with:
|
|
121
172
|
name: duel-report
|
|
122
|
-
path: ${{ runner.temp }}/duel
|
|
173
|
+
path: ${{ runner.temp }}/duel/
|
|
123
174
|
if-no-files-found: ignore # none when Duel didn't get to compare
|
|
124
175
|
retention-days: 1
|
|
125
176
|
|
|
126
|
-
# The report, as a new comment on
|
|
127
|
-
#
|
|
128
|
-
#
|
|
129
|
-
#
|
|
130
|
-
#
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
name: Comment
|
|
177
|
+
# The report, as a new comment on a pushed commit, which notifies its
|
|
178
|
+
# author, when Duel says to, as for a pull request (see the Perf comment
|
|
179
|
+
# workflow). It does only where a regression in a push passes, with
|
|
180
|
+
# c.fail_on = :pull_requests in .duel.rb, so the comment says what the
|
|
181
|
+
# check doesn't. Its last comment is the last one on any commit. This
|
|
182
|
+
# job checks nothing out and runs none of the code.
|
|
183
|
+
commit-comment:
|
|
184
|
+
name: Comment on the commit
|
|
135
185
|
needs: duel
|
|
136
|
-
if: ${{ !cancelled() && github.event_name == '
|
|
186
|
+
if: ${{ !cancelled() && github.event_name == 'push' && (needs.duel.outputs.comment == 'post' || needs.duel.outputs.comment == 'change') }}
|
|
137
187
|
runs-on: ubuntu-latest
|
|
138
188
|
permissions:
|
|
139
|
-
|
|
189
|
+
contents: write # to comment on the commit with the report
|
|
140
190
|
steps:
|
|
141
191
|
- name: Get the report
|
|
142
192
|
id: report
|
|
@@ -145,20 +195,120 @@ jobs:
|
|
|
145
195
|
with:
|
|
146
196
|
name: duel-report
|
|
147
197
|
path: ${{ runner.temp }}/report
|
|
148
|
-
- name: Comment on the
|
|
198
|
+
- name: Comment on the commit
|
|
149
199
|
if: steps.report.outcome == 'success'
|
|
150
200
|
env:
|
|
151
201
|
GH_TOKEN: ${{ github.token }}
|
|
152
|
-
PR: ${{ github.event.pull_request.number }}
|
|
153
202
|
COMMENT: ${{ needs.duel.outputs.comment }}
|
|
154
203
|
STATUS: ${{ needs.duel.outputs.status }}
|
|
155
204
|
run: |
|
|
156
205
|
marker="<!-- <%= marker %>"
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
last=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR/comments" \
|
|
160
|
-
--jq ".[] | select(.user.login == \"github-actions[bot]\") | .body | split(\"\n\")[0] | rtrimstr(\"\r\") | select(startswith(\"$marker status=\") or . == \"$marker -->\")" | tail -n 1)
|
|
206
|
+
last=$(gh api --paginate "repos/$GITHUB_REPOSITORY/comments" \
|
|
207
|
+
--jq ".[] | select(.user.login == \"github-actions[bot]\") | .body | split(\"\n\")[0] | rtrimstr(\"\r\") | select(startswith(\"$marker status=\"))" | tail -n 1)
|
|
161
208
|
if [ "$COMMENT" = post ] || { [ -n "$last" ] && [ "$last" != "$marker status=$STATUS -->" ]; }; then
|
|
162
209
|
{ echo "$marker status=$STATUS -->"; cat "$RUNNER_TEMP/report/duel.md"; } > "$RUNNER_TEMP/comment.md"
|
|
163
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/
|
|
210
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
|
|
211
|
+
fi
|
|
212
|
+
|
|
213
|
+
# With c.push_base = :last_passed in .duel.rb, a push is compared with
|
|
214
|
+
# the last commit Duel passed, which a branch marks (each branch pushed
|
|
215
|
+
# has its own), so slowdowns too small for any one push to fail add up
|
|
216
|
+
# until they fail one. This job moves the branch to a push that passed
|
|
217
|
+
# (or makes it), but never back: where a newer push's run moved it
|
|
218
|
+
# first, it stays. It checks nothing out and runs none of the code. To
|
|
219
|
+
# accept a regression, move the branch yourself (for main, git push
|
|
220
|
+
# origin main:<%= passed_branch %>/main).
|
|
221
|
+
passed:
|
|
222
|
+
name: Mark the commit passed
|
|
223
|
+
needs: duel
|
|
224
|
+
if: ${{ !cancelled() && github.event_name == 'push' && needs.duel.outputs.passed == 'true' }}
|
|
225
|
+
runs-on: ubuntu-latest
|
|
226
|
+
permissions:
|
|
227
|
+
contents: write # to move the branch
|
|
228
|
+
steps:
|
|
229
|
+
- name: Move the branch to the commit
|
|
230
|
+
env:
|
|
231
|
+
GH_TOKEN: ${{ github.token }}
|
|
232
|
+
BRANCH: <%= passed_branch %>/${{ github.ref_name }}
|
|
233
|
+
run: |
|
|
234
|
+
# (Git can't make a branch where another's name is a folder of its
|
|
235
|
+
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
236
|
+
# this names it.)
|
|
237
|
+
blocked() {
|
|
238
|
+
prefix=$BRANCH
|
|
239
|
+
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
240
|
+
prefix=${prefix%/*}
|
|
241
|
+
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
242
|
+
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."
|
|
243
|
+
fi
|
|
244
|
+
done
|
|
245
|
+
exit 1
|
|
246
|
+
}
|
|
247
|
+
# (Forward: GitHub moves it only where it's behind the push.)
|
|
248
|
+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null 2>&1 && exit 0
|
|
249
|
+
at=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$BRANCH" --jq .object.sha 2>/dev/null) || at=
|
|
250
|
+
if [ -z "$at" ]; then
|
|
251
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null || blocked
|
|
252
|
+
exit 0
|
|
164
253
|
fi
|
|
254
|
+
compared=$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$at" --jq .status)
|
|
255
|
+
case "$compared" in
|
|
256
|
+
# (A newer push's run moved it, or this one's did, run again.)
|
|
257
|
+
ahead | identical) ;;
|
|
258
|
+
# (History rewritten, a force push's, say: moved anyway.)
|
|
259
|
+
diverged | behind) gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null ;;
|
|
260
|
+
*) echo "::error::Couldn't compare $BRANCH with this push: $compared" && exit 1 ;;
|
|
261
|
+
esac
|
|
262
|
+
|
|
263
|
+
# Duel's badge, for the README: green (perf guarded) or red (perf
|
|
264
|
+
# regressed), as the last push to the default branch that Duel compared
|
|
265
|
+
# left it. It's red where the Duel job failed or found a regression,
|
|
266
|
+
# even one that passed (with c.fail_on = :pull_requests in .duel.rb). A
|
|
267
|
+
# push with nothing to compare leaves it as it was, and so does a run
|
|
268
|
+
# for an older push than the badge's. This job writes the badge, alone,
|
|
269
|
+
# to a branch of its own, which the README shows:
|
|
270
|
+
#
|
|
271
|
+
# [](https://github.com/sferik/duel-ruby)
|
|
272
|
+
#
|
|
273
|
+
# It checks nothing out and runs none of the code.
|
|
274
|
+
badge:
|
|
275
|
+
name: Update the badge
|
|
276
|
+
needs: duel
|
|
277
|
+
if: ${{ !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') }}
|
|
278
|
+
runs-on: ubuntu-latest
|
|
279
|
+
permissions:
|
|
280
|
+
contents: write # to move the badge's branch
|
|
281
|
+
steps:
|
|
282
|
+
- name: Update the badge
|
|
283
|
+
env:
|
|
284
|
+
GH_TOKEN: ${{ github.token }}
|
|
285
|
+
BRANCH: <%= badge_branch %>
|
|
286
|
+
RESULT: ${{ needs.duel.result }}
|
|
287
|
+
STATUS: ${{ needs.duel.outputs.status }}
|
|
288
|
+
BADGES: https://raw.githubusercontent.com/sferik/duel-ruby/main/assets
|
|
289
|
+
run: |
|
|
290
|
+
# (Git can't make a branch where another's name is a folder of its
|
|
291
|
+
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
292
|
+
# this names it.)
|
|
293
|
+
blocked() {
|
|
294
|
+
prefix=$BRANCH
|
|
295
|
+
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
296
|
+
prefix=${prefix%/*}
|
|
297
|
+
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
298
|
+
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."
|
|
299
|
+
fi
|
|
300
|
+
done
|
|
301
|
+
exit 1
|
|
302
|
+
}
|
|
303
|
+
# (Where the badge is a newer push's, that push's run has the say.
|
|
304
|
+
# Its commit names the push.)
|
|
305
|
+
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
|
|
306
|
+
if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
|
|
307
|
+
badge="badge.svg"
|
|
308
|
+
if [ "$RESULT" = failure ] || [ "$STATUS" = failed ]; then badge="badge-regressed.svg"; fi
|
|
309
|
+
curl -fsSL "$BADGES/$badge" -o "$RUNNER_TEMP/badge.svg"
|
|
310
|
+
tree=$(jq -n --rawfile svg "$RUNNER_TEMP/badge.svg" '{tree: [{path: "badge.svg", mode: "100644", type: "blob", content: $svg}]}' |
|
|
311
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/trees" --input - --jq .sha)
|
|
312
|
+
commit=$(gh api --method POST "repos/$GITHUB_REPOSITORY/git/commits" -f message="Duel's badge, for $GITHUB_SHA" -f tree="$tree" --jq .sha)
|
|
313
|
+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$commit" -F force=true > /dev/null 2>&1 ||
|
|
314
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$commit" > /dev/null || blocked
|
data/lib/duel/testing.rb
CHANGED
|
@@ -49,11 +49,11 @@ module Duel
|
|
|
49
49
|
|
|
50
50
|
# Runs +config+'s prepare blocks as they'd prepare a worker (+name+,
|
|
51
51
|
# running the version at +root+): its version's (Config#prepare
|
|
52
|
-
# (:version), named for the version: "
|
|
52
|
+
# (:version), named for the version: "head"), then the worker's,
|
|
53
53
|
# with their builds (Resource#cached) in +cache+ (by default, one for
|
|
54
54
|
# every test of this process). Sets the environment they give while
|
|
55
55
|
# the block runs, yields it, and stops what they started after.
|
|
56
|
-
def prepare(config, name: "
|
|
56
|
+
def prepare(config, name: "head-1", root: config.root, cache: CACHE)
|
|
57
57
|
dir = Lane.tmpdir
|
|
58
58
|
started = [] #: Array[Resource]
|
|
59
59
|
begin
|
data/lib/duel/version.rb
CHANGED
data/lib/duel/worker.rb
CHANGED
|
@@ -87,7 +87,7 @@ module Duel
|
|
|
87
87
|
# peak memory and profiles can be measured here, and whether YJIT is on.
|
|
88
88
|
def hello
|
|
89
89
|
{"benchmarks" => @benchmarks.values.map(&:to_h), "metrics" => @specs, "ruby" => RUBY_DESCRIPTION,
|
|
90
|
-
"memory" => !Native::Memory.
|
|
90
|
+
"memory" => !Native::Memory.used.nil?, "profiler" => Worker.profiler?, "yjit" => Worker.yjit?,
|
|
91
91
|
"extensions" => Worker.extensions, "gem_dirs" => Worker.gem_dirs}
|
|
92
92
|
end
|
|
93
93
|
|
data/sig/duel/baseline.rbs
CHANGED
|
@@ -13,9 +13,17 @@ module Duel
|
|
|
13
13
|
|
|
14
14
|
def initialize: (Config config, Settings settings) -> void
|
|
15
15
|
|
|
16
|
-
# The commit, or nil for "last-release" with no release yet
|
|
16
|
+
# The commit, or nil for "last-release" with no release yet, and for
|
|
17
|
+
# a push with no commit before it here.
|
|
17
18
|
def ref: () -> String?
|
|
18
19
|
|
|
20
|
+
# The branch that marks the last commit Duel passed in a push to the
|
|
21
|
+
# branch pushed.
|
|
22
|
+
def passed_branch: () -> String
|
|
23
|
+
|
|
24
|
+
# The last commit Duel passed in a push, as checked out (on origin).
|
|
25
|
+
def passed: () -> String
|
|
26
|
+
|
|
19
27
|
# Whether nothing #watched changed since the baseline.
|
|
20
28
|
def unchanged?: () -> bool
|
|
21
29
|
|
|
@@ -62,6 +70,11 @@ module Duel
|
|
|
62
70
|
# says why there's none.
|
|
63
71
|
def merge_base: () -> String
|
|
64
72
|
|
|
73
|
+
# A push's baseline: the last commit Duel passed, where
|
|
74
|
+
# Config#push_base says and HEAD has it, or else the commit before the
|
|
75
|
+
# push, or nil where that isn't here.
|
|
76
|
+
def pushed: () -> String?
|
|
77
|
+
|
|
65
78
|
# Whether +dir+ is a checkout of this repository.
|
|
66
79
|
def ours?: (String dir) -> bool
|
|
67
80
|
|
data/sig/duel/cli.rbs
CHANGED
|
@@ -28,6 +28,15 @@ module Duel
|
|
|
28
28
|
# A run's status as the comment's marker has it.
|
|
29
29
|
MARKED: Hash[String, String]
|
|
30
30
|
|
|
31
|
+
# The GitHub Actions events of a pull request.
|
|
32
|
+
PULL_REQUESTS: Array[String]
|
|
33
|
+
|
|
34
|
+
# The exit status of a run that was slower, but warned, on GitLab CI.
|
|
35
|
+
WARNED: Integer
|
|
36
|
+
|
|
37
|
+
# Where else to write the step's outputs, as variables.
|
|
38
|
+
OUTPUT: String
|
|
39
|
+
|
|
31
40
|
# The variables that set options, to their options.
|
|
32
41
|
ENV_OPTIONS: Hash[String, String]
|
|
33
42
|
|
|
@@ -43,6 +52,8 @@ module Duel
|
|
|
43
52
|
@json: String?
|
|
44
53
|
@settings: Settings?
|
|
45
54
|
@config: Config?
|
|
55
|
+
@passed: bool?
|
|
56
|
+
@note: String?
|
|
46
57
|
|
|
47
58
|
def initialize: (Array[String] argv, ?env: _Env, ?out: _Output, ?err: _Output) -> void
|
|
48
59
|
|
|
@@ -61,6 +72,13 @@ module Duel
|
|
|
61
72
|
# The mode --comment names, or an invalid argument.
|
|
62
73
|
def self.comment_mode: (String name) -> Config::comment
|
|
63
74
|
|
|
75
|
+
# The runs --fail-on names, or an invalid argument.
|
|
76
|
+
def self.fail_on: (String name) -> Config::fail_on
|
|
77
|
+
|
|
78
|
+
# Which of +values+ an option's argument names, or an invalid
|
|
79
|
+
# argument.
|
|
80
|
+
def self.named: [T < Symbol] (String name, Array[T] values) -> T
|
|
81
|
+
|
|
64
82
|
def parse: () -> Settings
|
|
65
83
|
|
|
66
84
|
private
|
|
@@ -68,14 +86,58 @@ module Duel
|
|
|
68
86
|
# What #run does, holding the project's lock.
|
|
69
87
|
def compare: (Config config, Settings settings) -> Integer
|
|
70
88
|
|
|
89
|
+
# The exit status of a run that was slower: 1, or 0 where only a pull
|
|
90
|
+
# request fails, outside one.
|
|
91
|
+
def slower: (Config config, Settings settings) -> Integer
|
|
92
|
+
|
|
93
|
+
# Passes a run that was slower, with a warning and a note.
|
|
94
|
+
def passing: (String why, String note, ?Integer exit) -> Integer
|
|
95
|
+
|
|
96
|
+
# Whether the pull request's labels have the one that accepts a
|
|
97
|
+
# regression.
|
|
98
|
+
def accepted?: (Config config) -> bool
|
|
99
|
+
|
|
100
|
+
# The pull request's labels, from DUEL_LABELS.
|
|
101
|
+
def labels: () -> Array[untyped]
|
|
102
|
+
|
|
103
|
+
# Whether the workflow marks a push that passed as the last commit
|
|
104
|
+
# Duel passed.
|
|
105
|
+
def marks_passed?: (Config config, Settings settings) -> bool
|
|
106
|
+
|
|
107
|
+
# What a run on CI is for, as GitHub Actions names it, or nil outside
|
|
108
|
+
# CI.
|
|
109
|
+
def event: () -> String?
|
|
110
|
+
|
|
111
|
+
# Whether this is a run on GitLab CI.
|
|
112
|
+
def gitlab?: () -> bool
|
|
113
|
+
|
|
114
|
+
# The first of the variables +names+ that's set, or nil.
|
|
115
|
+
def variable: (*String names) -> String?
|
|
116
|
+
|
|
117
|
+
# Whether a regression fails only a pull request.
|
|
118
|
+
def pull_requests_only?: (Config config, Settings settings) -> bool
|
|
119
|
+
|
|
120
|
+
# Whether this is a run on GitHub Actions for something other than a
|
|
121
|
+
# pull request.
|
|
122
|
+
def outside_pull_request?: () -> bool
|
|
123
|
+
|
|
124
|
+
# Whether this is a run on GitHub Actions for a pull request.
|
|
125
|
+
def pull_request?: () -> bool
|
|
126
|
+
|
|
127
|
+
# Whether the baseline is a merge queue's base.
|
|
128
|
+
def queued?: (Settings settings) -> bool
|
|
129
|
+
|
|
130
|
+
# Whether this is a run on GitHub Actions for a push.
|
|
131
|
+
def pushed?: () -> bool
|
|
132
|
+
|
|
71
133
|
# Says there's nothing to compare, and why, and passes.
|
|
72
134
|
def nothing: (String title, String why) -> Integer
|
|
73
135
|
|
|
74
136
|
# Reports a run that didn't compare, and why, and returns +exit+.
|
|
75
137
|
def unfinished: (String mark, String title, String status, String why, Integer exit) -> Integer
|
|
76
138
|
|
|
77
|
-
# What the workflow does about its comment on a pull request,
|
|
78
|
-
# run of +status+.
|
|
139
|
+
# What the workflow does about its comment on a pull request, or on a
|
|
140
|
+
# pushed commit, for a run of +status+.
|
|
79
141
|
def commenting: (String status) -> String
|
|
80
142
|
|
|
81
143
|
# Writes the reports where they're asked for, each made only if it's
|
data/sig/duel/config.rbs
CHANGED
|
@@ -13,6 +13,12 @@ module Duel
|
|
|
13
13
|
# When the workflow comments on a pull request (see #comment).
|
|
14
14
|
type comment = :always | :results | :failures | :never
|
|
15
15
|
|
|
16
|
+
# Which runs a regression fails (see #fail_on).
|
|
17
|
+
type fail_on = :every_run | :pull_requests
|
|
18
|
+
|
|
19
|
+
# What a push is compared with (see #push_base).
|
|
20
|
+
type push_base = :before | :last_passed
|
|
21
|
+
|
|
16
22
|
@root: String
|
|
17
23
|
@benchmarks: String
|
|
18
24
|
@watch: Array[String]
|
|
@@ -23,6 +29,9 @@ module Duel
|
|
|
23
29
|
@prepares: Hash[Symbol, Array[prepare]]
|
|
24
30
|
@ruby: ruby
|
|
25
31
|
@comment: comment
|
|
32
|
+
@fail_on: fail_on
|
|
33
|
+
@push_base: push_base
|
|
34
|
+
@accept_label: String?
|
|
26
35
|
@metrics: Array[singleton(Metric)]
|
|
27
36
|
@in_workers: Array[^(Stops stops) -> void]
|
|
28
37
|
@hooks: Hash[Symbol, Array[hook]]
|
|
@@ -33,6 +42,9 @@ module Duel
|
|
|
33
42
|
# Where the project is (and its config file).
|
|
34
43
|
attr_reader root: String
|
|
35
44
|
|
|
45
|
+
# Where Duel keeps what it keeps for the project: tmp/duel.
|
|
46
|
+
def state: () -> String
|
|
47
|
+
|
|
36
48
|
# A glob, from the root, of the files defining benchmarks.
|
|
37
49
|
attr_accessor benchmarks: String
|
|
38
50
|
|
|
@@ -67,6 +79,33 @@ module Duel
|
|
|
67
79
|
# Sets #comment, or fails for a value it doesn't take.
|
|
68
80
|
def comment=: (untyped mode) -> untyped
|
|
69
81
|
|
|
82
|
+
# Which runs a regression fails: :every_run (the default), or
|
|
83
|
+
# :pull_requests.
|
|
84
|
+
attr_reader fail_on: fail_on
|
|
85
|
+
|
|
86
|
+
# The values #fail_on takes.
|
|
87
|
+
FAIL_ON: Array[fail_on]
|
|
88
|
+
|
|
89
|
+
# Sets #fail_on, or fails for a value it doesn't take.
|
|
90
|
+
def fail_on=: (untyped runs) -> untyped
|
|
91
|
+
|
|
92
|
+
# The name of a label that accepts a regression in a pull request, or
|
|
93
|
+
# nil (the default) for none.
|
|
94
|
+
attr_reader accept_label: String?
|
|
95
|
+
|
|
96
|
+
# Sets #accept_label, or fails for what isn't a name or nil.
|
|
97
|
+
def accept_label=: (untyped label) -> untyped
|
|
98
|
+
|
|
99
|
+
# What a push is compared with: :before (the default), the commit
|
|
100
|
+
# before it, or :last_passed, the last commit Duel passed.
|
|
101
|
+
attr_reader push_base: push_base
|
|
102
|
+
|
|
103
|
+
# The values #push_base takes.
|
|
104
|
+
PUSH_BASES: Array[push_base]
|
|
105
|
+
|
|
106
|
+
# Sets #push_base, or fails for a value it doesn't take.
|
|
107
|
+
def push_base=: (untyped base) -> untyped
|
|
108
|
+
|
|
70
109
|
# What #prepare was given, by scope.
|
|
71
110
|
# @api private
|
|
72
111
|
attr_reader prepares: Hash[Symbol, Array[prepare]]
|
data/sig/duel/init.rbs
CHANGED
|
@@ -21,6 +21,7 @@ module Duel
|
|
|
21
21
|
@root: String
|
|
22
22
|
@force: bool?
|
|
23
23
|
@dry_run: bool?
|
|
24
|
+
@gitlab: bool?
|
|
24
25
|
@stackprof: bool?
|
|
25
26
|
|
|
26
27
|
def initialize: (Array[String] argv, ?out: _Output, ?err: _Output, ?root: String) -> void
|
|
@@ -99,5 +100,20 @@ module Duel
|
|
|
99
100
|
|
|
100
101
|
# What marks the workflow's comment on a pull request.
|
|
101
102
|
def marker: () -> String
|
|
103
|
+
|
|
104
|
+
# The branch that marks the last commit Duel passed in a push.
|
|
105
|
+
def passed_branch: () -> String
|
|
106
|
+
|
|
107
|
+
# The branch that holds the workflow's badge.
|
|
108
|
+
def badge_branch: () -> String
|
|
109
|
+
|
|
110
|
+
# Where the GitLab CI jobs are, from the repository's root.
|
|
111
|
+
def gitlab_file: () -> String
|
|
112
|
+
|
|
113
|
+
# The GitLab CI job's name.
|
|
114
|
+
def gitlab_job: () -> String
|
|
115
|
+
|
|
116
|
+
# The Ruby image's tag for GitLab CI.
|
|
117
|
+
def gitlab_ruby: () -> String
|
|
102
118
|
end
|
|
103
119
|
end
|
data/sig/duel/lock.rbs
CHANGED
|
@@ -8,5 +8,16 @@ module Duel
|
|
|
8
8
|
# Runs the block holding +dir+'s lock. Fails, naming the run that
|
|
9
9
|
# holds it, if another does.
|
|
10
10
|
def self.hold: [T] (String dir) { () -> T } -> T
|
|
11
|
+
|
|
12
|
+
# The lock file at +path+, locked: the one there now.
|
|
13
|
+
def self.acquire: (String path, String dir) -> File
|
|
14
|
+
|
|
15
|
+
# The directories, +dir+ and those it's in, that aren't there yet,
|
|
16
|
+
# deepest first.
|
|
17
|
+
def self.missing: (String dir) -> Array[String]
|
|
18
|
+
|
|
19
|
+
# Removes the empty directories in +dir+, then +dir+, then those of
|
|
20
|
+
# +made+ that it's in, while they're empty.
|
|
21
|
+
def self.tidy: (String dir, Array[String] made) -> void
|
|
11
22
|
end
|
|
12
23
|
end
|
data/sig/duel/native.rbs
CHANGED
data/sig/duel/resource.rbs
CHANGED
|
@@ -40,7 +40,16 @@ module Duel
|
|
|
40
40
|
# @api private
|
|
41
41
|
def self.environment: (String name, Hash[String, String?] env, Hash[String, String?] vars) -> Hash[String, String?]
|
|
42
42
|
|
|
43
|
-
# The worker it's for ("
|
|
43
|
+
# The worker it's for ("base-1", say).
|
|
44
|
+
# What a cache key names, without its version and hash.
|
|
45
|
+
NAME: Regexp
|
|
46
|
+
|
|
47
|
+
# The builds this process's runs used, by path.
|
|
48
|
+
USED: Set[String]
|
|
49
|
+
|
|
50
|
+
# Removes the builds that ones this process used replace.
|
|
51
|
+
def self.evict: (String cache) -> void
|
|
52
|
+
|
|
44
53
|
attr_reader name: String
|
|
45
54
|
|
|
46
55
|
# The directory it has of its own.
|