duel 0.1.7 → 0.1.8
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 +2 -2
- data/CHANGELOG.md +58 -1
- data/README.md +6 -1
- data/docs/ci.md +77 -76
- data/docs/configuration.md +3 -1
- data/docs/how-it-works.md +4 -1
- data/docs/plugins.md +7 -0
- data/lib/duel/cli.rb +51 -9
- data/lib/duel/comment.rb +235 -0
- data/lib/duel/config.rb +11 -2
- data/lib/duel/init.rb +116 -5
- data/lib/duel/runner.rb +20 -5
- data/lib/duel/summary.rb +11 -5
- data/lib/duel/templates/duel.gitlab-ci.yml.erb +8 -19
- data/lib/duel/templates/perf-comment.yml.erb +17 -42
- data/lib/duel/version.rb +1 -1
- data/lib/duel.rb +8 -0
- data/sig/duel/cli.rbs +11 -0
- data/sig/duel/comment.rbs +82 -0
- data/sig/duel/config.rbs +5 -0
- data/sig/duel/init.rbs +39 -1
- data/sig/duel/runner.rbs +3 -0
- data/sig/duel/summary.rbs +3 -1
- metadata +3 -1
|
@@ -3,14 +3,15 @@ name: Perf comment<%= " (#{working_directory})" if working_directory %>
|
|
|
3
3
|
# Duel's report, as a new comment on the pull request, when Duel says to:
|
|
4
4
|
# always (post), or only when its last comment's status differs from the
|
|
5
5
|
# run's (change), so the latest comment is never stale. It never edits or
|
|
6
|
-
# deletes a comment
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
#
|
|
6
|
+
# deletes a comment, but hides Duel's earlier ones as outdated, so the
|
|
7
|
+
# newest is the one in view. It runs once the Perf workflow has, with
|
|
8
|
+
# this repository's own workflow and a token that can write, so a pull
|
|
9
|
+
# request from a fork gets a comment too. It checks nothing out and runs
|
|
10
|
+
# none of the pull request's code, only `duel comment` (see Duel's
|
|
11
|
+
# docs/ci.md), which trusts only what the Duel job could have said in
|
|
12
|
+
# what it kept: the pull request's number, if it names the pull request
|
|
13
|
+
# the run compared, and the comment and the status, if they're ones Duel
|
|
14
|
+
# says. Its report, a fork's too, is the comment, as Markdown.
|
|
14
15
|
<% if accept_label -%>
|
|
15
16
|
#
|
|
16
17
|
# And when the label that accepts a regression (c.accept_label in
|
|
@@ -52,46 +53,20 @@ jobs:
|
|
|
52
53
|
path: ${{ runner.temp }}/report
|
|
53
54
|
run-id: ${{ github.event.workflow_run.id }}
|
|
54
55
|
github-token: ${{ github.token }}
|
|
56
|
+
- uses: ruby/setup-ruby@v1
|
|
57
|
+
if: steps.report.outcome == 'success'
|
|
58
|
+
with:
|
|
59
|
+
ruby-version: ruby
|
|
60
|
+
# Duel's own code, from RubyGems (none of the pull request's), so a
|
|
61
|
+
# fix to how it comments comes with a release of Duel.
|
|
55
62
|
- name: Comment on the pull request
|
|
56
63
|
if: steps.report.outcome == 'success'
|
|
57
64
|
env:
|
|
58
65
|
GH_TOKEN: ${{ github.token }}
|
|
59
66
|
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
60
67
|
run: |
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
COMMENT=$(said comment 'post|change')
|
|
64
|
-
STATUS=$(said status 'passed|failed|neutral')
|
|
65
|
-
[ -n "$PR" ] && [ -n "$COMMENT" ] && [ -n "$STATUS" ] || exit 0
|
|
66
|
-
# (The pull request's head commit, and the repository it's from.)
|
|
67
|
-
head=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR" --jq '"\(.head.sha) \(.head.repo.full_name)"')
|
|
68
|
-
[ "${head%% *}" = "$HEAD_SHA" ] || exit 0
|
|
69
|
-
# The report, as Markdown for a branch of this repository (whose
|
|
70
|
-
# author can push here anyway), but for a fork's, as text: its run
|
|
71
|
-
# ran the fork's code, which could have written anything in it. In
|
|
72
|
-
# a code block, fenced with more backticks than any run of them in
|
|
73
|
-
# the report, it can't mention anyone, link anywhere or show an
|
|
74
|
-
# image. It's cut short where a comment couldn't hold it, and loses
|
|
75
|
-
# any NUL bytes, which GitHub wouldn't take, and grep reads it as
|
|
76
|
-
# text whatever's in it, so it finds every run of backticks.
|
|
77
|
-
report() {
|
|
78
|
-
if [ "${head#* }" = "$GITHUB_REPOSITORY" ]; then cat "$RUNNER_TEMP/report/duel.md" && return; fi
|
|
79
|
-
text="$RUNNER_TEMP/report.txt"
|
|
80
|
-
LC_ALL=C tr -d '\000' < "$RUNNER_TEMP/report/duel.md" | head -c 60000 > "$text"
|
|
81
|
-
fence=$(LC_ALL=C grep -ao '``*' "$text" | awk '{ if (length > n) n = length } END { n = (n < 3) ? 3 : n + 1; while (n-- > 0) printf "`" }')
|
|
82
|
-
printf 'From a fork, so shown as text:\n\n%s\n' "$fence"
|
|
83
|
-
cat "$text"
|
|
84
|
-
printf '\n%s\n' "$fence"
|
|
85
|
-
}
|
|
86
|
-
marker="<!-- <%= marker %>"
|
|
87
|
-
# The first line of the last comment Duel posted here: its marker,
|
|
88
|
-
# with its status (none in Duel 0.1.0's, which counts as another).
|
|
89
|
-
last=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR/comments" \
|
|
90
|
-
--jq ".[] | select(.user.login == \"github-actions[bot]\") | .body | split(\"\n\")[0] | rtrimstr(\"\r\") | select(startswith(\"$marker status=\") or . == \"$marker -->\")" | tail -n 1)
|
|
91
|
-
if [ "$COMMENT" = post ] || { [ -n "$last" ] && [ "$last" != "$marker status=$STATUS -->" ]; }; then
|
|
92
|
-
{ echo "$marker status=$STATUS -->"; report; } > "$RUNNER_TEMP/comment.md"
|
|
93
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/comments" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
|
|
94
|
-
fi
|
|
68
|
+
gem install duel --version '~> <%= Duel::Comment::SINCE %>' --no-document
|
|
69
|
+
duel comment --report "$RUNNER_TEMP/report" --head "$HEAD_SHA" --marker '<%= marker.gsub("'") { "'\\''" } %>'
|
|
95
70
|
<% if accept_label -%>
|
|
96
71
|
|
|
97
72
|
again:
|
data/lib/duel/version.rb
CHANGED
data/lib/duel.rb
CHANGED
|
@@ -196,6 +196,14 @@ module Duel
|
|
|
196
196
|
# end
|
|
197
197
|
# end
|
|
198
198
|
#
|
|
199
|
+
# Where what it starts for each worker (a database server, say) takes
|
|
200
|
+
# more memory than Duel can see as it starts, its module says how much
|
|
201
|
+
# at most, in bytes, as +worker_memory+: Runner#fit counts that much
|
|
202
|
+
# for each worker, at least, as it fits the workers in the memory
|
|
203
|
+
# available. (A version of Duel before it asked ignores it.)
|
|
204
|
+
#
|
|
205
|
+
# def self.worker_memory = 450 << 20
|
|
206
|
+
#
|
|
199
207
|
# Its own kinds of benchmark, if it has any, are the methods of its
|
|
200
208
|
# module's DSL module, which files of benchmarks get as .duel.rb uses
|
|
201
209
|
# it (see DSL.add):
|
data/sig/duel/cli.rbs
CHANGED
|
@@ -5,6 +5,10 @@ module Duel
|
|
|
5
5
|
# The environment (ENV, or a Hash in its place).
|
|
6
6
|
interface _Env
|
|
7
7
|
def reject: () { (String name, String value) -> boolish } -> _Variables
|
|
8
|
+
|
|
9
|
+
def fetch: (String name) -> String
|
|
10
|
+
|
|
11
|
+
def []: (String name) -> String?
|
|
8
12
|
end
|
|
9
13
|
|
|
10
14
|
# What's left of it.
|
|
@@ -54,6 +58,7 @@ module Duel
|
|
|
54
58
|
@config: Config?
|
|
55
59
|
@passed: bool?
|
|
56
60
|
@note: String?
|
|
61
|
+
@accepted: bool?
|
|
57
62
|
|
|
58
63
|
def initialize: (Array[String] argv, ?env: _Env, ?out: _Output, ?err: _Output) -> void
|
|
59
64
|
|
|
@@ -153,6 +158,12 @@ module Duel
|
|
|
153
158
|
# The candidate, in Markdown.
|
|
154
159
|
def described_candidate: (Config config, Settings settings) -> String
|
|
155
160
|
|
|
161
|
+
def merged: (String dir) -> String?
|
|
162
|
+
|
|
163
|
+
def merge_request: () -> Hash[String, untyped]
|
|
164
|
+
|
|
165
|
+
def pull_request: () -> Hash[String, untyped]?
|
|
166
|
+
|
|
156
167
|
# What chose a baseline of the last release: the release, or a change
|
|
157
168
|
# since it accepted with the label.
|
|
158
169
|
def last_release: (Config config, Baseline baseline) -> String
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module Duel
|
|
2
|
+
# `duel comment`: what the Perf comment workflow runs, to comment on a
|
|
3
|
+
# pull request with Duel's report.
|
|
4
|
+
# @api private
|
|
5
|
+
class Comment
|
|
6
|
+
USAGE: String
|
|
7
|
+
|
|
8
|
+
# The first release whose `duel comment` the workflow can run.
|
|
9
|
+
SINCE: String
|
|
10
|
+
|
|
11
|
+
# Where GitLab CI has what Duel said.
|
|
12
|
+
GITLAB: Hash[String, String]
|
|
13
|
+
|
|
14
|
+
# What Duel says in comment.env, as each line must have it.
|
|
15
|
+
SAID: Hash[String, Regexp]
|
|
16
|
+
|
|
17
|
+
# The comments on a pull request, a page at a time.
|
|
18
|
+
COMMENTS: String
|
|
19
|
+
|
|
20
|
+
# The jq that picks GitHub Actions' token's comments.
|
|
21
|
+
LISTED: String
|
|
22
|
+
|
|
23
|
+
@argv: Array[String]
|
|
24
|
+
@env: CLI::_Env
|
|
25
|
+
@out: _Output
|
|
26
|
+
@err: _Output
|
|
27
|
+
@marker: String
|
|
28
|
+
@report: String?
|
|
29
|
+
@head: String?
|
|
30
|
+
@gitlab: bool?
|
|
31
|
+
|
|
32
|
+
def initialize: (Array[String] argv, env: CLI::_Env, out: _Output, err: _Output) -> void
|
|
33
|
+
|
|
34
|
+
# Returns the exit status: 0 commented (or had nothing to say), 1
|
|
35
|
+
# GitHub wouldn't take it, 2 a bad option.
|
|
36
|
+
def run: () -> Integer
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def parser: () -> OptionParser
|
|
41
|
+
|
|
42
|
+
# Comments, if Duel said to, and the pull request's head is still the
|
|
43
|
+
# run's.
|
|
44
|
+
def comment: (String report) -> Integer
|
|
45
|
+
|
|
46
|
+
# Posts +body+ as a new comment, or nil.
|
|
47
|
+
def post: (String pr, String body) -> untyped
|
|
48
|
+
|
|
49
|
+
# What Duel said in comment.env, or nil.
|
|
50
|
+
def said: (String name, String report) -> String?
|
|
51
|
+
|
|
52
|
+
# Duel's comments on the pull request, oldest first, or nil.
|
|
53
|
+
def earlier: (String pr) -> Array[Hash[String, untyped]]?
|
|
54
|
+
|
|
55
|
+
# The merge request, as GitLab's API has it, or nil.
|
|
56
|
+
def merge_request: (String pr) -> untyped
|
|
57
|
+
|
|
58
|
+
# The token's notes on the merge request, or nil.
|
|
59
|
+
def notes: (String pr) -> Array[Hash[String, untyped]]?
|
|
60
|
+
|
|
61
|
+
# What GitLab's API says, or nil.
|
|
62
|
+
def gitlab: (Symbol verb, String path, ?Hash[String, String]? body, ?pages: bool) -> untyped
|
|
63
|
+
|
|
64
|
+
# A connection to +uri+'s host, not yet started.
|
|
65
|
+
def connection: (URI::Generic uri) -> Net::HTTP
|
|
66
|
+
|
|
67
|
+
# Hides an earlier comment as outdated.
|
|
68
|
+
def hide: (String id) -> void
|
|
69
|
+
|
|
70
|
+
# What gh api prints, or nil where it fails.
|
|
71
|
+
def gh: (*String args) -> String?
|
|
72
|
+
|
|
73
|
+
# Says why it doesn't comment, and returns 0.
|
|
74
|
+
def quiet: (String why) -> Integer
|
|
75
|
+
|
|
76
|
+
def marker: () -> String
|
|
77
|
+
|
|
78
|
+
def repository: () -> String
|
|
79
|
+
|
|
80
|
+
def project: () -> String
|
|
81
|
+
end
|
|
82
|
+
end
|
data/sig/duel/config.rbs
CHANGED
|
@@ -36,6 +36,7 @@ module Duel
|
|
|
36
36
|
@in_workers: Array[^(Stops stops) -> void]
|
|
37
37
|
@hooks: Hash[Symbol, Array[hook]]
|
|
38
38
|
@used: Hash[Symbol, Used]
|
|
39
|
+
@worker_memory: Integer
|
|
39
40
|
@measures: Hash[String, Hash[Symbol, untyped]]
|
|
40
41
|
@loader: (^(String version_root) -> void)?
|
|
41
42
|
|
|
@@ -125,6 +126,10 @@ module Duel
|
|
|
125
126
|
# @api private
|
|
126
127
|
attr_reader measures: Hash[String, Hash[Symbol, untyped]]
|
|
127
128
|
|
|
129
|
+
# The memory that what the plugins used start for each worker takes at
|
|
130
|
+
# most, as they say, in bytes.
|
|
131
|
+
attr_reader worker_memory: Integer
|
|
132
|
+
|
|
128
133
|
# A configuration of the conventions, for the project at +root+.
|
|
129
134
|
def initialize: (?String root) -> void
|
|
130
135
|
|
data/sig/duel/init.rbs
CHANGED
|
@@ -15,18 +15,31 @@ module Duel
|
|
|
15
15
|
# A Gemfile's development group.
|
|
16
16
|
DEVELOPMENT: Regexp
|
|
17
17
|
|
|
18
|
+
# The color of the label it creates.
|
|
19
|
+
LABEL_COLOR: String
|
|
20
|
+
|
|
21
|
+
# Where it reads an answer.
|
|
22
|
+
interface _Input
|
|
23
|
+
def tty?: () -> bool
|
|
24
|
+
|
|
25
|
+
def gets: () -> String?
|
|
26
|
+
end
|
|
27
|
+
|
|
18
28
|
@argv: Array[String]
|
|
19
29
|
@out: _Output
|
|
20
30
|
@err: _Output
|
|
31
|
+
@input: _Input
|
|
21
32
|
@root: String
|
|
33
|
+
@label: bool?
|
|
22
34
|
@force: bool?
|
|
23
35
|
@dry_run: bool?
|
|
36
|
+
@check: bool?
|
|
24
37
|
@gitlab: bool?
|
|
25
38
|
@badge: bool?
|
|
26
39
|
@settings: Config?
|
|
27
40
|
@stackprof: bool?
|
|
28
41
|
|
|
29
|
-
def initialize: (Array[String] argv, ?out: _Output, ?err: _Output, ?root: String) -> void
|
|
42
|
+
def initialize: (Array[String] argv, ?out: _Output, ?err: _Output, ?input: _Input, ?root: String) -> void
|
|
30
43
|
|
|
31
44
|
# Returns the exit status: 0 set up, 1 a Rails app, 2 a bad option.
|
|
32
45
|
def run: () -> Integer
|
|
@@ -38,6 +51,31 @@ module Duel
|
|
|
38
51
|
|
|
39
52
|
def parser: () -> OptionParser
|
|
40
53
|
|
|
54
|
+
# Says whether each workflow is what it writes, or how it differs.
|
|
55
|
+
def check: () -> Integer
|
|
56
|
+
|
|
57
|
+
# Whether the file at +path+ is +content+, saying so, or how it differs.
|
|
58
|
+
def same?: (String path, String content) -> bool
|
|
59
|
+
|
|
60
|
+
# Creates the label that accepts a regression, with gh, if it's missing
|
|
61
|
+
# and the answer to whether to is yes.
|
|
62
|
+
def create_label: () -> void
|
|
63
|
+
|
|
64
|
+
# The names of the GitHub repository's labels gh finds, or nil.
|
|
65
|
+
def github_labels: (String repo, String label) -> Array[String]?
|
|
66
|
+
|
|
67
|
+
# The project's GitLab project, as glab has it, or nil.
|
|
68
|
+
def gitlab_project: () -> String?
|
|
69
|
+
|
|
70
|
+
# The names of the GitLab project's labels, or nil.
|
|
71
|
+
def gitlab_labels: (String repo) -> Array[String]?
|
|
72
|
+
|
|
73
|
+
# What gh (or glab) prints, run in the project, or nil.
|
|
74
|
+
def cli: (String program, *String args) -> String?
|
|
75
|
+
|
|
76
|
+
# A pull request, or on GitLab, a merge request.
|
|
77
|
+
def request: () -> String
|
|
78
|
+
|
|
41
79
|
# Says to use duel-rails's generator instead.
|
|
42
80
|
def rails: () -> Integer
|
|
43
81
|
|
data/sig/duel/runner.rbs
CHANGED
|
@@ -657,6 +657,9 @@ module Duel
|
|
|
657
657
|
# reckoning.
|
|
658
658
|
HEADROOM: Float
|
|
659
659
|
|
|
660
|
+
# How many times a JIT engine's worker grows as it warms up.
|
|
661
|
+
JIT_GROWTH: Hash[String, Float]
|
|
662
|
+
|
|
660
663
|
# Lowers the jobs, then the processes, that Settings#fit lets it, to
|
|
661
664
|
# fit the memory available.
|
|
662
665
|
def fit: () -> void
|
data/sig/duel/summary.rbs
CHANGED
|
@@ -17,6 +17,7 @@ module Duel
|
|
|
17
17
|
# What the heading starts with.
|
|
18
18
|
PASSED_MARK: String
|
|
19
19
|
FAILED_MARK: String
|
|
20
|
+
ACCEPTED_MARK: String
|
|
20
21
|
NEUTRAL_MARK: String
|
|
21
22
|
|
|
22
23
|
# What an unsettled timing means.
|
|
@@ -26,6 +27,7 @@ module Duel
|
|
|
26
27
|
DECIDES: String
|
|
27
28
|
|
|
28
29
|
@note: String?
|
|
30
|
+
@accepted: bool?
|
|
29
31
|
@runner: Runner
|
|
30
32
|
@results: Array[Result]
|
|
31
33
|
@settings: Settings
|
|
@@ -53,7 +55,7 @@ module Duel
|
|
|
53
55
|
def self.changed_counts: (Result result) -> Hash[String, [Float, Float]]
|
|
54
56
|
|
|
55
57
|
def initialize: (Runner runner, Array[Result] results, settings: Settings, baseline: String, candidate: String,
|
|
56
|
-
?note: String?) -> void
|
|
58
|
+
?note: String?, ?accepted: bool?) -> void
|
|
57
59
|
|
|
58
60
|
# The Markdown.
|
|
59
61
|
def markdown: () -> String
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: duel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Berlin
|
|
@@ -52,6 +52,7 @@ files:
|
|
|
52
52
|
- lib/duel/across.rb
|
|
53
53
|
- lib/duel/baseline.rb
|
|
54
54
|
- lib/duel/cli.rb
|
|
55
|
+
- lib/duel/comment.rb
|
|
55
56
|
- lib/duel/config.rb
|
|
56
57
|
- lib/duel/context.rb
|
|
57
58
|
- lib/duel/init.rb
|
|
@@ -81,6 +82,7 @@ files:
|
|
|
81
82
|
- sig/duel/across.rbs
|
|
82
83
|
- sig/duel/baseline.rbs
|
|
83
84
|
- sig/duel/cli.rbs
|
|
85
|
+
- sig/duel/comment.rbs
|
|
84
86
|
- sig/duel/config.rbs
|
|
85
87
|
- sig/duel/context.rbs
|
|
86
88
|
- sig/duel/init.rbs
|