duel 0.1.0 → 0.1.2

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.
@@ -1,21 +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
+
19
+ # The Duel job runs the branch's code (its benchmarks too), so it only
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.
11
23
  permissions:
12
24
  contents: read
13
- pull-requests: write # to comment on a pull request with the report
25
+ pull-requests: read # for the pull request's labels (see c.accept_label)
14
26
 
15
27
  jobs:
16
28
  duel:
17
29
  name: Duel
18
30
  runs-on: ubuntu-latest
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.
34
+ outputs:
35
+ comment: ${{ steps.compare.outputs.comment }}
36
+ status: ${{ steps.compare.outputs.status }}
37
+ passed: ${{ steps.compare.outputs.passed }}
19
38
  <% if working_directory -%>
20
39
  # The project is in a subdirectory of the repository: Duel runs there,
21
40
  # and checks out the whole repository for the baseline.
@@ -27,27 +46,63 @@ jobs:
27
46
  - uses: actions/checkout@v7
28
47
  with:
29
48
  fetch-depth: 0 # the baseline comes from history, tags included
49
+ persist-credentials: false
30
50
  # (And whatever else your tests need set up: packages, services.)
31
51
  <% if version_file -%>
32
52
  # Each version runs on the Ruby its own .ruby-version names (see
33
- # .duel.rb): for a pull request that upgrades Ruby, the main branch's
34
- # too, linked where Duel finds it (as chruby would). It's set up
35
- # before the project's own Ruby, which runs Duel.
53
+ # .duel.rb). When the baseline's names another Ruby than this code's,
54
+ # that one is installed too, and linked where Duel finds it (as
55
+ # chruby would), before the project's own Ruby, which runs Duel. The
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.)
36
63
  - name: Find the baseline's Ruby
37
64
  id: baseline
38
- if: github.event_name == 'pull_request'
39
- run: echo "ruby=$(git show "origin/$GITHUB_BASE_REF:./.ruby-version" 2>/dev/null)" >> "$GITHUB_OUTPUT"
65
+ env:
66
+ BEFORE: ${{ github.event.before }}
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 }}
70
+ RELEASE_TAGS: "<%= release_tags %>"
71
+ run: |
72
+ case "$GITHUB_EVENT_NAME" in
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 ;;
77
+ schedule) base=$(git describe --tags --abbrev=0 --match "$RELEASE_TAGS" HEAD^ 2>/dev/null) || base= ;;
78
+ *) base=$(git merge-base HEAD "$MAIN_BRANCH" 2>/dev/null) || base= ;;
79
+ esac
80
+ ruby_of() { git show "$1:./.ruby-version" 2>/dev/null | awk 'NF { print $1; exit }'; }
81
+ ruby=
82
+ # (None without a baseline: a branch's first push, or no release yet.)
83
+ if [ -n "$base" ] && git cat-file -e "$base^{commit}" 2>/dev/null; then
84
+ ruby=$(ruby_of "$base")
85
+ [ "$ruby" = "$(ruby_of HEAD)" ] && ruby=
86
+ fi
87
+ echo "ruby=$ruby" >> "$GITHUB_OUTPUT"
40
88
  - uses: ruby/setup-ruby@v1
41
89
  id: baseline-ruby
42
90
  if: steps.baseline.outputs.ruby != ''
43
91
  with:
92
+ <% if working_directory -%>
93
+ working-directory: <%= working_directory %>
94
+ <% end -%>
44
95
  ruby-version: ${{ steps.baseline.outputs.ruby }}
96
+ # The bundle for this Ruby too, which the baseline's workers load.
97
+ # (Gems installed for one Ruby version don't load on another.)
98
+ bundler-cache: true
45
99
  - name: Link the baseline's Ruby where Duel finds it
46
100
  if: steps.baseline.outputs.ruby != ''
101
+ env:
102
+ PREFIX: ${{ steps.baseline-ruby.outputs.ruby-prefix }}
47
103
  run: |
48
- prefix="${{ steps.baseline-ruby.outputs.ruby-prefix }}"
49
104
  mkdir -p ~/.rubies
50
- ln -sfn "$prefix" ~/.rubies/ruby-"$("$prefix/bin/ruby" -e 'print RUBY_VERSION')"
105
+ ln -sfn "$PREFIX" ~/.rubies/ruby-"$("$PREFIX/bin/ruby" -e 'print RUBY_VERSION')"
51
106
  <% end -%>
52
107
  - uses: ruby/setup-ruby@v1
53
108
  with:
@@ -58,40 +113,122 @@ jobs:
58
113
  ruby-version: "<%= ruby_version %>"
59
114
  <% end -%>
60
115
  bundler-cache: true
61
- # Against the main branch for a pull request, what was there before
62
- # for a push, and the last release on a schedule (slow creep). Duel
63
- # adds its report to the job's summary, and writes it to duel.md for
64
- # the comment.
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.
65
147
  - name: Compare
148
+ id: compare
66
149
  env:
67
- 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 || '' }}
68
151
  # (Run by hand, it compares anyway: with nothing changed, the code
69
152
  # with itself, which checks the setup.)
70
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 }}
71
164
  run: |
72
- # (A branch's first push, or one that rewrote history, has no
73
- # commit before it here to compare against.)
74
- if [ "$GITHUB_EVENT_NAME" = push ] && ! git cat-file -e "$DUEL_BASE^{commit}" 2>/dev/null; then
75
- echo "::notice::No commit before this push to compare against"
76
- exit 0
77
- fi
78
- bundle exec duel --markdown "$RUNNER_TEMP/duel.md"
79
- # The report, as a comment on the pull request: one comment, updated
80
- # on every push. (A pull request from a fork gets no comment, as its
81
- # token can't write one: the job's summary has the report.)
82
- - name: Comment on the pull request
83
- if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository }}
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.
168
+ - name: Keep the report
169
+ if: ${{ !cancelled() && (github.event_name == 'pull_request' || github.event_name == 'push') }}
170
+ uses: actions/upload-artifact@v7
171
+ with:
172
+ name: duel-report
173
+ path: ${{ runner.temp }}/duel/
174
+ if-no-files-found: ignore # none when Duel didn't get to compare
175
+ retention-days: 1
176
+
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
185
+ needs: duel
186
+ if: ${{ !cancelled() && github.event_name == 'push' && (needs.duel.outputs.comment == 'post' || needs.duel.outputs.comment == 'change') }}
187
+ runs-on: ubuntu-latest
188
+ permissions:
189
+ contents: write # to comment on the commit with the report
190
+ steps:
191
+ - name: Get the report
192
+ id: report
193
+ continue-on-error: true # there's none when the Duel job failed before comparing
194
+ uses: actions/download-artifact@v8
195
+ with:
196
+ name: duel-report
197
+ path: ${{ runner.temp }}/report
198
+ - name: Comment on the commit
199
+ if: steps.report.outcome == 'success'
84
200
  env:
85
201
  GH_TOKEN: ${{ github.token }}
86
- PR: ${{ github.event.pull_request.number }}
202
+ COMMENT: ${{ needs.duel.outputs.comment }}
203
+ STATUS: ${{ needs.duel.outputs.status }}
87
204
  run: |
88
- [ -f "$RUNNER_TEMP/duel.md" ] || exit 0
89
- marker="<!-- <%= marker %> -->"
90
- { echo "$marker"; cat "$RUNNER_TEMP/duel.md"; } > "$RUNNER_TEMP/comment.md"
91
- ids=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR/comments" \
92
- --jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id")
93
- if [ -n "$ids" ]; then
94
- gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/${ids%%$'\n'*}" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
95
- else
96
- gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/comments" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
205
+ marker="<!-- <%= marker %>"
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)
208
+ if [ "$COMMENT" = post ] || { [ -n "$last" ] && [ "$last" != "$marker status=$STATUS -->" ]; }; then
209
+ { echo "$marker status=$STATUS -->"; cat "$RUNNER_TEMP/report/duel.md"; } > "$RUNNER_TEMP/comment.md"
210
+ gh api --method POST "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
97
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). It checks nothing out and runs none of the code. To
218
+ # accept a regression, move the branch yourself (for main, git push
219
+ # origin main:<%= passed_branch %>/main).
220
+ passed:
221
+ name: Mark the commit passed
222
+ needs: duel
223
+ if: ${{ !cancelled() && github.event_name == 'push' && needs.duel.outputs.passed == 'true' }}
224
+ runs-on: ubuntu-latest
225
+ permissions:
226
+ contents: write # to move the branch
227
+ steps:
228
+ - name: Move the branch to the commit
229
+ env:
230
+ GH_TOKEN: ${{ github.token }}
231
+ BRANCH: <%= passed_branch %>/${{ github.ref_name }}
232
+ run: |
233
+ gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null 2>&1 ||
234
+ gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null
data/lib/duel/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Duel
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -13,12 +13,26 @@ 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
 
19
- # Whether nothing Config#watch names changed since the baseline.
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
+
27
+ # Whether nothing #watched changed since the baseline.
20
28
  def unchanged?: () -> bool
21
29
 
30
+ # What a change must touch to be compared: the code (Config#watch),
31
+ # and what decides how it's measured (the benchmarks, the
32
+ # configuration's file, and with each version on its own Ruby, its
33
+ # version files).
34
+ def watched: () -> Array[String]
35
+
22
36
  # The baseline's tree, checked out and built if it's a commit.
23
37
  def root: () -> String
24
38
 
@@ -43,10 +57,24 @@ module Duel
43
57
 
44
58
  private
45
59
 
60
+ # The benchmarks' directory, or for benchmarks at the root, their glob.
61
+ def benchmarks: () -> String
62
+
63
+ # The configuration's file, from the root.
64
+ def config_file: () -> String
65
+
66
+ # The version files at the root.
67
+ def version_files: () -> Array[String]
68
+
46
69
  # Where HEAD left the main branch: their merge base, or a failure that
47
70
  # says why there's none.
48
71
  def merge_base: () -> String
49
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
+
50
78
  # Whether +dir+ is a checkout of this repository.
51
79
  def ours?: (String dir) -> bool
52
80
 
data/sig/duel/cli.rbs CHANGED
@@ -19,6 +19,24 @@ module Duel
19
19
  # Where GitHub Actions has a step add to its job's summary.
20
20
  STEP_SUMMARY: String
21
21
 
22
+ # Where GitHub Actions has a step set its outputs.
23
+ STEP_OUTPUT: String
24
+
25
+ # The statuses the workflow comments on, by when it does.
26
+ COMMENTED: Hash[Config::comment, Array[String]]
27
+
28
+ # A run's status as the comment's marker has it.
29
+ MARKED: Hash[String, String]
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
+
22
40
  # The variables that set options, to their options.
23
41
  ENV_OPTIONS: Hash[String, String]
24
42
 
@@ -33,6 +51,9 @@ module Duel
33
51
  @markdown: String?
34
52
  @json: String?
35
53
  @settings: Settings?
54
+ @config: Config?
55
+ @passed: bool?
56
+ @note: String?
36
57
 
37
58
  def initialize: (Array[String] argv, ?env: _Env, ?out: _Output, ?err: _Output) -> void
38
59
 
@@ -44,6 +65,20 @@ module Duel
44
65
  # +source+ as a Regexp, or an option's invalid argument.
45
66
  def self.regexp: (String source) -> Regexp
46
67
 
68
+ # Whether the workflow comments on a pull request: "post", "change"
69
+ # or "none".
70
+ def self.comment: (Config::comment mode, String status) -> String
71
+
72
+ # The mode --comment names, or an invalid argument.
73
+ def self.comment_mode: (String name) -> Config::comment
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
+
47
82
  def parse: () -> Settings
48
83
 
49
84
  private
@@ -51,15 +86,63 @@ module Duel
51
86
  # What #run does, holding the project's lock.
52
87
  def compare: (Config config, Settings settings) -> Integer
53
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
+
54
133
  # Says there's nothing to compare, and why, and passes.
55
- def nothing: (String why) -> Integer
134
+ def nothing: (String title, String why) -> Integer
135
+
136
+ # Reports a run that didn't compare, and why, and returns +exit+.
137
+ def unfinished: (String mark, String title, String status, String why, Integer exit) -> Integer
56
138
 
57
- # Reports a run that didn't compare, and returns +exit+.
58
- def unfinished: (String title, String status, String message, Integer exit) -> Integer
139
+ # What the workflow does about its comment on a pull request, or on a
140
+ # pushed commit, for a run of +status+.
141
+ def commenting: (String status) -> String
59
142
 
60
143
  # Writes the reports where they're asked for, each made only if it's
61
- # written.
62
- def publish: (^() -> String markdown, ^() -> JSONReport::report json) -> void
144
+ # written, and on GitHub Actions, the step's outputs.
145
+ def publish: (String status, ^() -> String markdown, ^(String comment) -> JSONReport::report json) -> void
63
146
 
64
147
  # Writes +text+ to +path+, in a directory made for it.
65
148
  def write: (String path, String text) -> void
data/sig/duel/config.rbs CHANGED
@@ -10,6 +10,15 @@ module Duel
10
10
  # version file's, a path, or what a block makes of the version's tree.
11
11
  type ruby = :version_file | String | ^(String root) -> String | nil
12
12
 
13
+ # When the workflow comments on a pull request (see #comment).
14
+ type comment = :always | :results | :failures | :never
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
+
13
22
  @root: String
14
23
  @benchmarks: String
15
24
  @watch: Array[String]
@@ -19,6 +28,10 @@ module Duel
19
28
  @release_tags: String
20
29
  @prepares: Hash[Symbol, Array[prepare]]
21
30
  @ruby: ruby
31
+ @comment: comment
32
+ @fail_on: fail_on
33
+ @push_base: push_base
34
+ @accept_label: String?
22
35
  @metrics: Array[singleton(Metric)]
23
36
  @in_workers: Array[^(Stops stops) -> void]
24
37
  @hooks: Hash[Symbol, Array[hook]]
@@ -32,7 +45,8 @@ module Duel
32
45
  # A glob, from the root, of the files defining benchmarks.
33
46
  attr_accessor benchmarks: String
34
47
 
35
- # Paths, from the root, whose changes a comparison is about.
48
+ # Paths, from the root, of the code whose changes a comparison is
49
+ # about (with what decides how it's measured).
36
50
  attr_accessor watch: Array[String]
37
51
 
38
52
  # The library to require from each version, or nil for none.
@@ -52,6 +66,43 @@ module Duel
52
66
  # given the version's tree.
53
67
  attr_accessor ruby: ruby
54
68
 
69
+ # When the workflow comments on a pull request: :always, :results,
70
+ # :failures (the default) or :never.
71
+ attr_reader comment: comment
72
+
73
+ # The values #comment takes.
74
+ COMMENTS: Array[comment]
75
+
76
+ # Sets #comment, or fails for a value it doesn't take.
77
+ def comment=: (untyped mode) -> untyped
78
+
79
+ # Which runs a regression fails: :every_run (the default), or
80
+ # :pull_requests.
81
+ attr_reader fail_on: fail_on
82
+
83
+ # The values #fail_on takes.
84
+ FAIL_ON: Array[fail_on]
85
+
86
+ # Sets #fail_on, or fails for a value it doesn't take.
87
+ def fail_on=: (untyped runs) -> untyped
88
+
89
+ # The name of a label that accepts a regression in a pull request, or
90
+ # nil (the default) for none.
91
+ attr_reader accept_label: String?
92
+
93
+ # Sets #accept_label, or fails for what isn't a name or nil.
94
+ def accept_label=: (untyped label) -> untyped
95
+
96
+ # What a push is compared with: :before (the default), the commit
97
+ # before it, or :last_passed, the last commit Duel passed.
98
+ attr_reader push_base: push_base
99
+
100
+ # The values #push_base takes.
101
+ PUSH_BASES: Array[push_base]
102
+
103
+ # Sets #push_base, or fails for a value it doesn't take.
104
+ def push_base=: (untyped base) -> untyped
105
+
55
106
  # What #prepare was given, by scope.
56
107
  # @api private
57
108
  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
@@ -63,9 +64,15 @@ module Duel
63
64
 
64
65
  def render: (String name) -> String
65
66
 
67
+ # The project's configuration, as the conventions have it.
68
+ def config: () -> Config
69
+
66
70
  # The library the gemspec names, or nil.
67
71
  def library: () -> String?
68
72
 
73
+ # The glob release tags match, for the workflow.
74
+ def release_tags: () -> String
75
+
69
76
  # The library, without a gemspec: lib/'s only Ruby file, or nil.
70
77
  def guess: () -> String?
71
78
 
@@ -93,5 +100,17 @@ module Duel
93
100
 
94
101
  # What marks the workflow's comment on a pull request.
95
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
+ # Where the GitLab CI jobs are, from the repository's root.
108
+ def gitlab_file: () -> String
109
+
110
+ # The GitLab CI job's name.
111
+ def gitlab_job: () -> String
112
+
113
+ # The Ruby image's tag for GitLab CI.
114
+ def gitlab_ruby: () -> String
96
115
  end
97
116
  end
@@ -15,16 +15,18 @@ module Duel
15
15
  @results: Array[Result]
16
16
  @settings: Settings
17
17
  @exit: Integer
18
+ @comment: String
18
19
  @versions: Hash[String, Hash[String, String | bool | nil]]
19
20
 
20
- # A run that didn't compare: +status+, its +exit+ status, and what it
21
- # said.
22
- def self.note: (String status, Integer exit, String message, Settings settings) -> report
21
+ # A run that didn't compare: +status+, its +exit+ status, what it
22
+ # said, and what the workflow does about its comment.
23
+ def self.note: (String status, Integer exit, String message, Settings settings, String comment) -> report
23
24
 
24
25
  # What every report starts with.
25
- def self.head: (String status, Integer exit, String? message, Settings settings) -> report
26
+ def self.head: (String status, Integer exit, String? message, Settings settings, String comment) -> report
26
27
 
27
- def initialize: (Runner runner, Array[Result] results, settings: Settings, exit: Integer, baseline: Hash[String, String?],
28
+ def initialize: (Runner runner, Array[Result] results, settings: Settings, exit: Integer, comment: String,
29
+ baseline: Hash[String, String?],
28
30
  candidate: Hash[String, String | bool | nil]) -> void
29
31
 
30
32
  def to_h: () -> report
data/sig/duel/runner.rbs CHANGED
@@ -18,7 +18,7 @@ module Duel
18
18
 
19
19
  # How a run is set up (see Duel::CLI for where each comes from).
20
20
  # @api private
21
- class Settings < Struct[String | Regexp | Integer | Float | bool | Config::ruby | nil]
21
+ class Settings < Struct[String | Regexp | Integer | Float | bool | Config::ruby | Config::comment | Config::fail_on | nil]
22
22
  attr_accessor base: String?
23
23
  attr_accessor base_dir: String?
24
24
  attr_accessor candidate_dir: String?
@@ -33,13 +33,28 @@ module Duel
33
33
  attr_accessor timeout: Float
34
34
  # Each version's Ruby (--ruby), over Config#ruby.
35
35
  attr_accessor ruby: Config::ruby
36
+ # When the workflow comments on a pull request (--comment), over
37
+ # Config#comment.
38
+ attr_accessor comment: Config::comment?
39
+ # Which runs a regression fails (--fail-on), over Config#fail_on.
40
+ attr_accessor fail_on: Config::fail_on?
41
+ # The branch pushed, where #base is the push's, the commit before it,
42
+ # on GitHub Actions (DUEL_BASE): see Baseline#ref.
43
+ attr_accessor pushed: String?
44
+ # The branch a pull request targets, on GitHub Actions
45
+ # (GITHUB_BASE_REF), on origin: see Baseline#main_branch.
46
+ attr_accessor target: String?
36
47
 
37
48
  def self.new: (?String? base, ?String? base_dir, ?String? candidate_dir, ?Regexp filter, ?Integer jobs,
38
49
  ?Integer processes, ?Float limit, ?Float confidence, ?Float? warm, ?bool force, ?String? config_path,
39
- ?Float timeout, ?Config::ruby ruby) -> instance
50
+ ?Float timeout, ?Config::ruby ruby, ?Config::comment? comment,
51
+ ?Config::fail_on? fail_on, ?String? pushed,
52
+ ?String? target) -> instance
40
53
  | (?base: String?, ?base_dir: String?, ?candidate_dir: String?, ?filter: Regexp, ?jobs: Integer,
41
54
  ?processes: Integer, ?limit: Float, ?confidence: Float, ?warm: Float?, ?force: bool,
42
- ?config_path: String?, ?timeout: Float, ?ruby: Config::ruby) -> instance
55
+ ?config_path: String?, ?timeout: Float, ?ruby: Config::ruby, ?comment: Config::comment?,
56
+ ?fail_on: Config::fail_on?, ?pushed: String?,
57
+ ?target: String?) -> instance
43
58
 
44
59
  def self.defaults: () -> Settings
45
60
  end