duel-rails 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/CHANGELOG.md +42 -1
- data/README.md +17 -15
- data/lib/duel/rails/database.rb +7 -3
- data/lib/duel/rails/request.rb +2 -2
- data/lib/duel/rails/version.rb +1 -1
- data/lib/duel/rails.rb +9 -10
- data/lib/generators/duel/install/install_generator.rb +10 -20
- data/lib/generators/duel/install/templates/duel.rb.tt +3 -4
- data/lib/generators/duel/install/templates/perf-comment.yml.tt +3 -3
- data/lib/generators/duel/install/templates/perf.yml.tt +66 -199
- data/sig/duel/rails.rbs +6 -7
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cdc36689a08f2f9025dda4a8468492551f32f9c94dd98cf54c51f020a0475a44
|
|
4
|
+
data.tar.gz: eb28d36800d947c8d2c362824ca3cd611594f56a6766fedff6f01e90d68fede2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 04c59a44989d991e235f201caa81ada8ffaea0f7ae238863c4e9e1f375fde2956e06a841498c78a94fa201def654f409ece918a8da3af8fb46138271a041a6b8
|
|
7
|
+
data.tar.gz: b5fa67b532acd0f56f95ecc26733e4115058c86a0d4dc15474f2296aa34e2ea0bf4e2757c65383aec1010c06cb3d4975b824585dd8dbe2205d2cdfd02e2b38e8
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,46 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-11-20
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- The Perf workflows that `bin/rails generate duel:install` writes
|
|
15
|
+
install exactly the release of Duel they were written with, in their
|
|
16
|
+
jobs that write or comment, and name each action they use by its
|
|
17
|
+
commit, as Duel's own do.
|
|
18
|
+
- The badge's Markdown, in a comment of the Perf workflow that
|
|
19
|
+
`bin/rails generate duel:install` writes, links to that workflow's
|
|
20
|
+
runs (`perf.yml`, or for an app in a subdirectory,
|
|
21
|
+
`perf-<its path>.yml`), as Duel's own does.
|
|
22
|
+
- The `.duel.rb` that `bin/rails generate duel:install` writes shows
|
|
23
|
+
`c.accept_label = "duel: accept"` commented out, now that it's Duel's
|
|
24
|
+
default.
|
|
25
|
+
- The Perf workflow that `bin/rails generate duel:install` writes gives
|
|
26
|
+
Duel no `DUEL_BASE`, as Duel finds the baseline from the run's event
|
|
27
|
+
now, and finds the baseline's Ruby from `bundle exec duel base`, once
|
|
28
|
+
the app's Ruby is set up.
|
|
29
|
+
- The Perf workflow that `bin/rails generate duel:install` writes has
|
|
30
|
+
the jobs for pushes whatever `.duel.rb` says, as they run where Duel
|
|
31
|
+
says to, and finds no accepted change on a schedule itself: Duel
|
|
32
|
+
does, from `.duel.rb`.
|
|
33
|
+
- `duel_request` takes `judge:`, as `duel` does now, in place of `only:`
|
|
34
|
+
and `peak_memory:`.
|
|
35
|
+
- The database server's plugin's options are `database_options:`, a
|
|
36
|
+
Hash (`database_options: {sql: File.read("db/structure.sql")}`), not
|
|
37
|
+
every option `c.use :rails` doesn't take, so a misspelled one fails
|
|
38
|
+
rather than going to the plugin, or with `:sqlite`, nowhere. And
|
|
39
|
+
`query_time:` is duel-activerecord's alone: to time queries,
|
|
40
|
+
`c.use :activerecord, query_time: true` before `c.use :rails`.
|
|
41
|
+
- The Perf workflow that `bin/rails generate duel:install` writes
|
|
42
|
+
comments on a pushed commit, marks a push passed, and updates the
|
|
43
|
+
badge with Duel 0.3.0's `duel comment --commit`, `duel mark-passed`
|
|
44
|
+
and `duel badge`, from RubyGems, as Duel's own does, in place of the
|
|
45
|
+
shell they ran.
|
|
46
|
+
- It requires Duel 0.3.0 and duel-activerecord 0.3.0 or later
|
|
47
|
+
(`~> 0.3.0`), the releases it's tested with, as Duel 0.3.0 changes
|
|
48
|
+
what plugins and benchmarks call.
|
|
49
|
+
|
|
10
50
|
## [0.2.0] - 2026-11-16
|
|
11
51
|
|
|
12
52
|
### Changed
|
|
@@ -276,7 +316,8 @@ Rails 7.2 or later, and Ruby 3.4 or later.
|
|
|
276
316
|
CI.
|
|
277
317
|
- RBS signatures in sig/, checked with Steep.
|
|
278
318
|
|
|
279
|
-
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.
|
|
319
|
+
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.3.0...HEAD
|
|
320
|
+
[0.3.0]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.2.0...duel-rails-v0.3.0
|
|
280
321
|
[0.2.0]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.8...duel-rails-v0.2.0
|
|
281
322
|
[0.1.8]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.7...duel-rails-v0.1.8
|
|
282
323
|
[0.1.7]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.6...duel-rails-v0.1.7
|
data/README.md
CHANGED
|
@@ -142,7 +142,7 @@ without the pauses, pass `rollback: false`.
|
|
|
142
142
|
| `headers:` | Request headers, by name, for example `{"Accept" => "text/csv"}`. |
|
|
143
143
|
| `status:` | The status that the response must have: an Integer, or a Range. The default is `200..399`. Any other status fails the benchmark, because it's measuring an error page. |
|
|
144
144
|
| `rollback:` | `false` to keep what the request writes, and to run its iterations without pausing the metrics between them. The default is `true`. To start each sample with the same data anyway, see [Start every sample with the same data](#start-every-sample-with-the-same-data). |
|
|
145
|
-
| `
|
|
145
|
+
| `judge:` | Duel's option for what the benchmark is judged on. See [Choose what a benchmark is judged on](https://github.com/sferik/duel-ruby/blob/main/docs/benchmarks.md#choose-what-a-benchmark-is-judged-on). |
|
|
146
146
|
| `setup:`, `teardown:`, `before_sample:`, `around_iteration:`, `after_iterations:` | The benchmark's own hooks, as `duel` takes them. See [Run code around a benchmark](https://github.com/sferik/duel-ruby/blob/main/docs/benchmarks.md#run-code-around-a-benchmark). An `around_iteration:` hook would replace the rollback, so it raises an `ArgumentError` unless you also pass `rollback: false`. To run a hook around the rollback, give it to the whole file instead. |
|
|
147
147
|
|
|
148
148
|
To change the request before it's sent, pass a block. The block
|
|
@@ -413,21 +413,18 @@ queries that a request's jobs make count as the request's.
|
|
|
413
413
|
| `environment:` | The environment that each version boots in, and its processes run in. The default is `"benchmark"`. |
|
|
414
414
|
| `bundle:` | `false` to run every version with the runner's bundle. |
|
|
415
415
|
| `active_record:` | `false` to leave out Active Record's metrics, for an app without Active Record. |
|
|
416
|
-
| `
|
|
416
|
+
| `database_options:` | Options for the database server's plugin, for example `{sql: File.read("db/structure.sql")}` for duel-mysql or duel-postgresql. |
|
|
417
417
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
with `c.use`. To give one of them options of its own, use it yourself,
|
|
423
|
-
before `c.use :rails`. duel-rails then uses the plugin that you
|
|
424
|
-
configured:
|
|
418
|
+
duel-rails uses duel-activerecord with `c.use`. To give it options of
|
|
419
|
+
its own, such as `query_time: true`, to also judge how long queries
|
|
420
|
+
took, use it yourself, before `c.use :rails`. duel-rails then uses the
|
|
421
|
+
plugin that you configured:
|
|
425
422
|
|
|
426
423
|
```ruby
|
|
427
424
|
# .duel.rb
|
|
428
425
|
Duel.configure do |c|
|
|
429
|
-
c.use :activerecord, ignore: ->(payload) { payload[:sql].include?("pg_catalog") }
|
|
430
|
-
c.use :rails, database: :postgresql, fixtures: :all
|
|
426
|
+
c.use :activerecord, query_time: true, ignore: ->(payload) { payload[:sql].include?("pg_catalog") }
|
|
427
|
+
c.use :rails, database: :postgresql, fixtures: :all, database_options: {sql: File.read("db/structure.sql")}
|
|
431
428
|
end
|
|
432
429
|
```
|
|
433
430
|
|
|
@@ -450,11 +447,16 @@ directory, such as `.github/workflows/perf-apps-blog.yml`, so that
|
|
|
450
447
|
each app can have its own. The workflow runs Duel, and sets up Ruby
|
|
451
448
|
and the bundle, in the app's directory (`working-directory`).
|
|
452
449
|
|
|
453
|
-
## YJIT
|
|
450
|
+
## YJIT and ZJIT
|
|
454
451
|
|
|
455
|
-
Rails 7.2 and later turn YJIT on as the app boots.
|
|
456
|
-
|
|
457
|
-
|
|
452
|
+
Rails 7.2 and later turn YJIT on as the app boots. To measure your app
|
|
453
|
+
on ZJIT instead, on Ruby 4.0 or later, set `RUBY_ZJIT_ENABLE=1` (or
|
|
454
|
+
`jit: zjit` in Duel's reusable workflow): Rails's call to turn YJIT on
|
|
455
|
+
then warns that only one JIT can be on, and ZJIT stays on. When either
|
|
456
|
+
is on, Duel warms each benchmark up until it's steady, for up to ten
|
|
457
|
+
seconds, before it measures it, so that the JIT has compiled your app's
|
|
458
|
+
code first. Where a variable turns a JIT on that the Ruby doesn't have,
|
|
459
|
+
Duel fails the run rather than measure without it.
|
|
458
460
|
|
|
459
461
|
## Requirements
|
|
460
462
|
|
data/lib/duel/rails/database.rb
CHANGED
|
@@ -15,9 +15,13 @@ module Duel
|
|
|
15
15
|
|
|
16
16
|
# Gives each worker its own +database+: a file for :sqlite, or a
|
|
17
17
|
# server for :postgresql, :mysql2 or :trilogy, from its Duel plugin
|
|
18
|
-
# (used with +options
|
|
19
|
-
def self.configure(config, database,
|
|
20
|
-
|
|
18
|
+
# (used with +options+, which a file takes none of).
|
|
19
|
+
def self.configure(config, database, options = {})
|
|
20
|
+
if database == :sqlite
|
|
21
|
+
raise ArgumentError, "database_options: #{options.keys.join(", ")}: :sqlite is a file, which takes none" unless options.empty?
|
|
22
|
+
|
|
23
|
+
return config.prepare(:worker) { |w| {"DATABASE_URL" => "sqlite3:#{w.path("db.sqlite3")}"} }
|
|
24
|
+
end
|
|
21
25
|
|
|
22
26
|
plugin = SERVERS.fetch(database) do
|
|
23
27
|
raise ArgumentError, "database: must be :sqlite, :postgresql, :mysql2 or :trilogy, not #{database.inspect}"
|
data/lib/duel/rails/request.rb
CHANGED
|
@@ -64,7 +64,7 @@ module Duel
|
|
|
64
64
|
# the request: see DSL#duel_request. +hooks+ are its own (as
|
|
65
65
|
# Duel::DSL#duel takes them): an around_iteration one, only for a request not
|
|
66
66
|
# rolled back (it would replace the rollback).
|
|
67
|
-
def self.duel(dsl, name, request,
|
|
67
|
+
def self.duel(dsl, name, request, judge: JUDGE, **options, &prepare)
|
|
68
68
|
hooks = options.slice(*HOOKS)
|
|
69
69
|
sent = new(request, **options.except(*HOOKS))
|
|
70
70
|
if sent.hooks.key?(:around_iteration) && hooks.key?(:around_iteration)
|
|
@@ -72,7 +72,7 @@ module Duel
|
|
|
72
72
|
"or give the hook to the file (around_iteration { |iteration| ... })"
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
dsl.duel(name,
|
|
75
|
+
dsl.duel(name, judge:, **sent.hooks, **hooks) do
|
|
76
76
|
env = sent.env
|
|
77
77
|
instance_exec(env, &prepare) if prepare
|
|
78
78
|
sent.call(env)
|
data/lib/duel/rails/version.rb
CHANGED
data/lib/duel/rails.rb
CHANGED
|
@@ -48,7 +48,8 @@ module Duel
|
|
|
48
48
|
# Configures Duel for the app (c.use :rails):
|
|
49
49
|
#
|
|
50
50
|
# - +database+: the worker's own database (see Database.configure), or
|
|
51
|
-
# nil for none. +database_options+ go to its plugin
|
|
51
|
+
# nil for none. +database_options+ go to its server's plugin
|
|
52
|
+
# (sql:, say).
|
|
52
53
|
# - +environment+: what each version boots in (its workers, and its
|
|
53
54
|
# process benchmarks: RAILS_ENV).
|
|
54
55
|
# - +bundle+: whether each version runs its own bundle (see Bundle).
|
|
@@ -61,30 +62,28 @@ module Duel
|
|
|
61
62
|
# - +jobs+: whether the jobs a benchmark enqueues are performed, and
|
|
62
63
|
# measured with it (see Jobs).
|
|
63
64
|
# - +active_record+: whether Active Record's queries are counted too
|
|
64
|
-
# (c.use :activerecord
|
|
65
|
+
# (c.use :activerecord: to give it options, use it first).
|
|
65
66
|
#
|
|
66
67
|
# Each version's schema is loaded into its workers' databases.
|
|
67
68
|
def self.configure(config, database: :sqlite, environment: ENVIRONMENT, bundle: true, fixtures: [], seeds: false,
|
|
68
|
-
seed: SEED, reset: false, jobs: true, active_record: true,
|
|
69
|
+
seed: SEED, reset: false, jobs: true, active_record: true, database_options: {})
|
|
69
70
|
raise ArgumentError, "reset: needs a database to reset" if reset && !database
|
|
70
71
|
|
|
71
72
|
config.watch = WATCH
|
|
72
|
-
config.
|
|
73
|
+
config.library = ->(root) { boot(root, environment) }
|
|
73
74
|
Bundle.configure(config) if bundle
|
|
74
75
|
config.prepare(:version) { |_version| {"RAILS_ENV" => environment} }
|
|
75
76
|
# (What .reset_data loads again.)
|
|
76
77
|
@data = ({fixtures:, seeds:, seed:} if database)
|
|
77
78
|
if database
|
|
78
|
-
Database.configure(config, database,
|
|
79
|
+
Database.configure(config, database, database_options)
|
|
79
80
|
config.in_worker { load_worker_data(fixtures:, seeds:, seed:) }
|
|
80
81
|
config.before_sample { reset_data } if reset
|
|
81
82
|
end
|
|
82
83
|
Jobs.configure(config) if jobs
|
|
83
|
-
# (
|
|
84
|
-
#
|
|
85
|
-
if active_record
|
|
86
|
-
query_time ? config.use(:activerecord, query_time: true) : config.use(:activerecord)
|
|
87
|
-
end
|
|
84
|
+
# (With no options: an app's own c.use :activerecord, before, gave
|
|
85
|
+
# its own.)
|
|
86
|
+
config.use(:activerecord) if active_record
|
|
88
87
|
Counter.configure(config)
|
|
89
88
|
end
|
|
90
89
|
|
|
@@ -4,6 +4,7 @@ require "erb"
|
|
|
4
4
|
require "open3"
|
|
5
5
|
require "pathname"
|
|
6
6
|
require "rails/generators"
|
|
7
|
+
require "duel/version" # (the templates install exactly this release)
|
|
7
8
|
|
|
8
9
|
module Duel
|
|
9
10
|
module Generators
|
|
@@ -90,8 +91,8 @@ module Duel
|
|
|
90
91
|
def workflows
|
|
91
92
|
dir = working_directory
|
|
92
93
|
name = dir ? "perf-#{dir.tr("/", "-")}" : "perf"
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
github = File.join(repository, ".github", "workflows")
|
|
95
|
+
{"perf.yml.tt" => File.join(github, "#{name}.yml"), "perf-comment.yml.tt" => File.join(github, "#{name}-comment.yml")}
|
|
95
96
|
end
|
|
96
97
|
|
|
97
98
|
# Whether the workflow at +path+ is what the template +source+ makes,
|
|
@@ -126,27 +127,13 @@ module Duel
|
|
|
126
127
|
def load_settings
|
|
127
128
|
Duel.load_config(File.join(destination_root, ".duel.rb"))
|
|
128
129
|
rescue ScriptError, StandardError => e
|
|
129
|
-
say_status :warning, ".duel.rb didn't load (#{e.class}: #{e}), so the
|
|
130
|
+
say_status :warning, ".duel.rb didn't load (#{e.class}: #{e}), so the workflows take Duel's defaults"
|
|
130
131
|
nil
|
|
131
132
|
end
|
|
132
133
|
|
|
133
|
-
# Whether the workflow comments on a pushed commit: where a regression
|
|
134
|
-
# in a push passes (c.fail_on = :pull_requests).
|
|
135
|
-
def comment_on_pushes?
|
|
136
|
-
found = settings
|
|
137
|
-
found.nil? || found.fail_on == :pull_requests
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
# Whether the workflow marks a push passed: where a push is compared
|
|
141
|
-
# with the last commit Duel passed (c.push_base = :last_passed).
|
|
142
|
-
def mark_passed?
|
|
143
|
-
found = settings
|
|
144
|
-
found.nil? || found.push_base == :last_passed
|
|
145
|
-
end
|
|
146
|
-
|
|
147
134
|
# The label that accepts a regression, for the workflows, as for
|
|
148
135
|
# `duel init` (see Duel::Init#accept_label).
|
|
149
|
-
def accept_label = settings
|
|
136
|
+
def accept_label = (settings || ::Duel::Config.new).accept_label
|
|
150
137
|
|
|
151
138
|
# Whether the workflow keeps a badge for the README (--badge), as for
|
|
152
139
|
# `duel init` (see Duel::Init#badge?).
|
|
@@ -193,8 +180,11 @@ module Duel
|
|
|
193
180
|
def ruby_version = (RUBY_VERSION.rpartition(".").first unless version_file?)
|
|
194
181
|
|
|
195
182
|
# The root of the app's git repository: the app's own directory,
|
|
196
|
-
# outside one (or without git).
|
|
197
|
-
|
|
183
|
+
# outside one (or without git). Found once, as every template asks
|
|
184
|
+
# (see #marker).
|
|
185
|
+
def repository = @repository ||= find_repository
|
|
186
|
+
|
|
187
|
+
def find_repository
|
|
198
188
|
top, _, status = Open3.capture3("git", "-C", destination_root, "rev-parse", "--show-toplevel")
|
|
199
189
|
status.success? ? top.chomp : destination_root
|
|
200
190
|
rescue SystemCallError
|
|
@@ -29,17 +29,16 @@ Duel.configure do |c|
|
|
|
29
29
|
# Which runs a regression fails: :every_run, or :pull_requests, for a
|
|
30
30
|
# project where people push to main directly (on GitHub Actions, another
|
|
31
31
|
# run warns and passes, and a pushed commit gets the comment instead,
|
|
32
|
-
# from a workflow job
|
|
32
|
+
# from a workflow job that runs where this is set: see docs/ci.md).
|
|
33
33
|
# c.fail_on = :every_run
|
|
34
34
|
|
|
35
35
|
# A label that accepts a regression in a pull request, for a change
|
|
36
36
|
# that's slower on purpose (nil for none).
|
|
37
|
-
c.accept_label = "duel: accept"
|
|
37
|
+
# c.accept_label = "duel: accept"
|
|
38
38
|
|
|
39
39
|
# What the workflow compares a push with: :before (the commit before it),
|
|
40
40
|
# or :last_passed (the last commit Duel passed, which a branch,
|
|
41
41
|
# duel/passed/main, marks), so small slowdowns add up until they fail.
|
|
42
|
-
# (A workflow job moves the branch
|
|
43
|
-
# docs/ci.md.)
|
|
42
|
+
# (A workflow job moves the branch where this is set: see docs/ci.md.)
|
|
44
43
|
# c.push_base = :before
|
|
45
44
|
end
|
|
@@ -47,13 +47,13 @@ jobs:
|
|
|
47
47
|
- name: Get the report
|
|
48
48
|
id: report
|
|
49
49
|
continue-on-error: true # there's none when the Duel job failed before comparing
|
|
50
|
-
uses: actions/download-artifact@v8
|
|
50
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
51
51
|
with:
|
|
52
52
|
name: duel-report
|
|
53
53
|
path: ${{ runner.temp }}/report
|
|
54
54
|
run-id: ${{ github.event.workflow_run.id }}
|
|
55
55
|
github-token: ${{ github.token }}
|
|
56
|
-
- uses: ruby/setup-ruby@v1
|
|
56
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
57
57
|
if: steps.report.outcome == 'success'
|
|
58
58
|
with:
|
|
59
59
|
ruby-version: ruby
|
|
@@ -65,7 +65,7 @@ jobs:
|
|
|
65
65
|
GH_TOKEN: ${{ github.token }}
|
|
66
66
|
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
67
67
|
run: |
|
|
68
|
-
gem install duel --version '
|
|
68
|
+
gem install duel --version '<%= Duel::VERSION %>' --no-document
|
|
69
69
|
duel comment --report "$RUNNER_TEMP/report" --head "$HEAD_SHA" --marker '<%= marker.gsub("'") { "'\\''" } %>'
|
|
70
70
|
<% if accept_label -%>
|
|
71
71
|
|
|
@@ -29,7 +29,7 @@ jobs:
|
|
|
29
29
|
name: Duel
|
|
30
30
|
runs-on: ubuntu-latest
|
|
31
31
|
# Whether to comment (post, change or none), the run's status (passed,
|
|
32
|
-
# failed or neutral), and
|
|
32
|
+
# failed or neutral), and the branch to mark a push passed on (or
|
|
33
33
|
# nothing), from Duel.
|
|
34
34
|
outputs:
|
|
35
35
|
comment: ${{ steps.compare.outputs.comment }}
|
|
@@ -43,43 +43,25 @@ jobs:
|
|
|
43
43
|
working-directory: <%= working_directory %>
|
|
44
44
|
<% end -%>
|
|
45
45
|
steps:
|
|
46
|
-
- uses: actions/checkout@v7
|
|
46
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
47
47
|
with:
|
|
48
48
|
fetch-depth: 0 # the baseline comes from history, tags included
|
|
49
49
|
persist-credentials: false
|
|
50
50
|
# The labels of the pull request (or for a push, of the one that
|
|
51
51
|
# merged it), for c.accept_label in .duel.rb, as a JSON array. They're
|
|
52
52
|
# read as the job runs, and adding the label (or taking it off) runs
|
|
53
|
-
# the job again: see the Perf comment workflow.
|
|
54
|
-
|
|
55
|
-
#
|
|
56
|
-
# pull request with the label (ACCEPT_LABEL, as .duel.rb names it):
|
|
57
|
-
# what that slowed down was accepted, so it's compared with instead.
|
|
58
|
-
<% end -%>
|
|
53
|
+
# the job again: see the Perf comment workflow. (On a schedule, Duel
|
|
54
|
+
# finds the last change merged with the label since the last
|
|
55
|
+
# release itself.)
|
|
59
56
|
- name: Find the pull request's labels
|
|
60
57
|
id: labels
|
|
61
|
-
if: github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'push'
|
|
58
|
+
if: github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'push'
|
|
62
59
|
continue-on-error: true # (without them, nothing's accepted)
|
|
63
60
|
env:
|
|
64
61
|
GH_TOKEN: ${{ github.token }}
|
|
65
62
|
PR: ${{ github.event.pull_request.number }}
|
|
66
63
|
QUEUED: ${{ github.event.merge_group.head_ref }}
|
|
67
|
-
<% if accept_label -%>
|
|
68
|
-
ACCEPT_LABEL: '<%= accept_label.gsub("'", "''") %>'
|
|
69
|
-
RELEASE_TAGS: "v*"
|
|
70
|
-
<% end -%>
|
|
71
64
|
run: |
|
|
72
|
-
<% if accept_label -%>
|
|
73
|
-
if [ "$GITHUB_EVENT_NAME" = schedule ]; then
|
|
74
|
-
tag=$(git describe --tags --abbrev=0 --match "$RELEASE_TAGS" HEAD^ 2>/dev/null) || exit 0
|
|
75
|
-
since=$(TZ=UTC git log -1 --date=format-local:%Y-%m-%dT%H:%M:%SZ --format=%cd "$tag")
|
|
76
|
-
merged=$(gh pr list --repo "$GITHUB_REPOSITORY" --state merged --label "$ACCEPT_LABEL" --search "merged:>=$since" --limit 1000 \
|
|
77
|
-
--json mergeCommit --jq '.[].mergeCommit.oid')
|
|
78
|
-
accepted=$(git rev-list "$tag..HEAD" | grep -Fx -m 1 -f <(echo "$merged")) || accepted=
|
|
79
|
-
echo "accepted=$accepted" >> "$GITHUB_OUTPUT"
|
|
80
|
-
exit 0
|
|
81
|
-
fi
|
|
82
|
-
<% end -%>
|
|
83
65
|
# (In a merge queue, the last pull request queued, which the queue's
|
|
84
66
|
# branch names: gh-readonly-queue/main/pr-123-<sha>.)
|
|
85
67
|
if [ -n "$QUEUED" ]; then
|
|
@@ -105,48 +87,40 @@ jobs:
|
|
|
105
87
|
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
|
|
106
88
|
fi
|
|
107
89
|
<% end -%>
|
|
90
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
91
|
+
id: ruby
|
|
92
|
+
with:
|
|
93
|
+
<% if working_directory -%>
|
|
94
|
+
working-directory: <%= working_directory %>
|
|
95
|
+
<% end -%>
|
|
96
|
+
<% if ruby_version -%>
|
|
97
|
+
ruby-version: "<%= ruby_version %>"
|
|
98
|
+
<% end -%>
|
|
99
|
+
bundler-cache: true
|
|
108
100
|
<% if version_file? -%>
|
|
109
101
|
# Each version runs on the Ruby its own .ruby-version names (see
|
|
110
102
|
# .duel.rb). When the baseline's names another Ruby than this code's,
|
|
111
|
-
# that one is installed too, and linked where Duel
|
|
112
|
-
# chruby would),
|
|
113
|
-
#
|
|
114
|
-
#
|
|
115
|
-
# base, the commit before a push (or the last commit Duel passed, PASSED, if there is
|
|
116
|
-
# one: see the Mark the commit passed job), or on a schedule the last
|
|
117
|
-
# release, the newest tag before HEAD that RELEASE_TAGS matches<% if accept_label %>
|
|
118
|
-
# (or ACCEPTED, the last change accepted since then)<% end %>. (If
|
|
119
|
-
# .duel.rb sets c.main_branch or c.release_tags, set MAIN_BRANCH or
|
|
120
|
-
# RELEASE_TAGS to match.)
|
|
103
|
+
# that one is installed too, with its bundle, and linked where Duel
|
|
104
|
+
# finds it (as chruby would), and the app's own Ruby, which runs
|
|
105
|
+
# Duel, comes first again. The baseline is the one the Compare step
|
|
106
|
+
# compares with, as Duel finds it (duel base).
|
|
121
107
|
- name: Find the baseline's Ruby
|
|
122
108
|
id: baseline
|
|
123
109
|
env:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
MAIN_BRANCH: origin/${{ github.base_ref || github.event.repository.default_branch }}
|
|
128
|
-
RELEASE_TAGS: "v*"
|
|
129
|
-
<% if accept_label -%>
|
|
130
|
-
ACCEPTED: ${{ steps.labels.outputs.accepted }}
|
|
131
|
-
<% end -%>
|
|
110
|
+
# (On a schedule, for the last change a label accepted since the
|
|
111
|
+
# last release, which Duel finds with gh.)
|
|
112
|
+
GH_TOKEN: ${{ github.event_name == 'schedule' && github.token || '' }}
|
|
132
113
|
run: |
|
|
133
|
-
|
|
134
|
-
push)
|
|
135
|
-
base=$BEFORE
|
|
136
|
-
if git merge-base --is-ancestor "$PASSED" HEAD 2>/dev/null; then base=$PASSED; fi ;;
|
|
137
|
-
merge_group) base=$QUEUE_BASE ;;
|
|
138
|
-
schedule) base=${ACCEPTED:-$(git describe --tags --abbrev=0 --match "$RELEASE_TAGS" HEAD^ 2>/dev/null)} || base= ;;
|
|
139
|
-
*) base=$(git merge-base HEAD "$MAIN_BRANCH" 2>/dev/null) || base= ;;
|
|
140
|
-
esac
|
|
114
|
+
base=$(bundle exec duel base)
|
|
141
115
|
ruby_of() { git show "$1:./.ruby-version" 2>/dev/null | awk 'NF { print $1; exit }'; }
|
|
142
116
|
ruby=
|
|
143
117
|
# (None without a baseline: a branch's first push, or no release yet.)
|
|
144
|
-
if [ -n "$base" ]
|
|
118
|
+
if [ -n "$base" ]; then
|
|
145
119
|
ruby=$(ruby_of "$base")
|
|
146
120
|
[ "$ruby" = "$(ruby_of HEAD)" ] && ruby=
|
|
147
121
|
fi
|
|
148
122
|
echo "ruby=$ruby" >> "$GITHUB_OUTPUT"
|
|
149
|
-
- uses: ruby/setup-ruby@v1
|
|
123
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
150
124
|
id: baseline-ruby
|
|
151
125
|
if: steps.baseline.outputs.ruby != ''
|
|
152
126
|
with:
|
|
@@ -161,37 +135,32 @@ jobs:
|
|
|
161
135
|
if: steps.baseline.outputs.ruby != ''
|
|
162
136
|
env:
|
|
163
137
|
PREFIX: ${{ steps.baseline-ruby.outputs.ruby-prefix }}
|
|
138
|
+
RUBY_PREFIX: ${{ steps.ruby.outputs.ruby-prefix }}
|
|
164
139
|
run: |
|
|
140
|
+
# (The app's own Ruby first again, for the steps after: it runs
|
|
141
|
+
# Duel.)
|
|
142
|
+
echo "$RUBY_PREFIX/bin" >> "$GITHUB_PATH"
|
|
165
143
|
mkdir -p ~/.rubies
|
|
166
144
|
ln -sfn "$PREFIX" ~/.rubies/ruby-"$("$PREFIX/bin/ruby" -e 'print RUBY_VERSION')"
|
|
167
145
|
<% end -%>
|
|
168
|
-
- uses: ruby/setup-ruby@v1
|
|
169
|
-
with:
|
|
170
|
-
<% if working_directory -%>
|
|
171
|
-
working-directory: <%= working_directory %>
|
|
172
|
-
<% end -%>
|
|
173
|
-
<% if ruby_version -%>
|
|
174
|
-
ruby-version: "<%= ruby_version %>"
|
|
175
|
-
<% end -%>
|
|
176
|
-
bundler-cache: true
|
|
177
146
|
# Against the branch it targets for a pull request, the queue's base
|
|
178
147
|
# for a merge queue, what was there before for a push (or as
|
|
179
148
|
# c.push_base in .duel.rb says, the last commit Duel passed), and the
|
|
180
|
-
# last release on a schedule (slow creep)
|
|
149
|
+
# last release on a schedule (slow creep), as Duel finds them, from
|
|
150
|
+
# the run's event. Duel adds its report to
|
|
181
151
|
# the job's summary, writes it to duel.md for the comment, and sets
|
|
182
152
|
# the step's outputs to say whether to comment, as c.comment in
|
|
183
153
|
# .duel.rb says, whatever the outcome.
|
|
184
154
|
- name: Compare
|
|
185
155
|
id: compare
|
|
186
156
|
env:
|
|
187
|
-
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 || '' }}
|
|
188
157
|
# (Run by hand, it compares anyway: with nothing changed, the code
|
|
189
158
|
# with itself, which checks the setup.)
|
|
190
159
|
DUEL_FORCE: ${{ github.event_name == 'workflow_dispatch' && '1' || '' }}
|
|
191
160
|
DUEL_LABELS: ${{ steps.labels.outputs.labels }}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
161
|
+
# (On a schedule, for the last change a label accepted since the
|
|
162
|
+
# last release, which Duel finds with gh.)
|
|
163
|
+
GH_TOKEN: ${{ github.event_name == 'schedule' && github.token || '' }}
|
|
195
164
|
run: bundle exec duel --markdown "$RUNNER_TEMP/duel/duel.md"
|
|
196
165
|
# For a pull request, what Duel said, for the Perf comment workflow,
|
|
197
166
|
# which can't see this job's outputs.
|
|
@@ -207,13 +176,12 @@ jobs:
|
|
|
207
176
|
# The report, for the comments.
|
|
208
177
|
- name: Keep the report
|
|
209
178
|
if: ${{ !cancelled() && (github.event_name == 'pull_request' || github.event_name == 'push') }}
|
|
210
|
-
uses: actions/upload-artifact@v7
|
|
179
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
211
180
|
with:
|
|
212
181
|
name: duel-report
|
|
213
182
|
path: ${{ runner.temp }}/duel/
|
|
214
183
|
if-no-files-found: ignore # none when Duel didn't get to compare
|
|
215
184
|
retention-days: 1
|
|
216
|
-
<% if comment_on_pushes? -%>
|
|
217
185
|
|
|
218
186
|
# The report, as a new comment on a pushed commit, which notifies its
|
|
219
187
|
# author, when Duel says to, as for a pull request (see the Perf comment
|
|
@@ -232,35 +200,33 @@ jobs:
|
|
|
232
200
|
- name: Get the report
|
|
233
201
|
id: report
|
|
234
202
|
continue-on-error: true # there's none when the Duel job failed before comparing
|
|
235
|
-
uses: actions/download-artifact@v8
|
|
203
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
236
204
|
with:
|
|
237
205
|
name: duel-report
|
|
238
206
|
path: ${{ runner.temp }}/report
|
|
207
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
208
|
+
if: steps.report.outcome == 'success'
|
|
209
|
+
with:
|
|
210
|
+
ruby-version: ruby
|
|
211
|
+
# Duel's own code, from RubyGems (none of the push's).
|
|
239
212
|
- name: Comment on the commit
|
|
240
213
|
if: steps.report.outcome == 'success'
|
|
241
214
|
env:
|
|
242
215
|
GH_TOKEN: ${{ github.token }}
|
|
243
|
-
|
|
244
|
-
|
|
216
|
+
DUEL_COMMENT: ${{ needs.duel.outputs.comment }}
|
|
217
|
+
DUEL_STATUS: ${{ needs.duel.outputs.status }}
|
|
245
218
|
run: |
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
--jq ".[] | select(.user.login == \"github-actions[bot]\") | .body | split(\"\n\")[0] | rtrimstr(\"\r\") | select(startswith(\"$marker status=\"))" | tail -n 1)
|
|
249
|
-
if [ "$COMMENT" = post ] || { [ -n "$last" ] && [ "$last" != "$marker status=$STATUS -->" ]; }; then
|
|
250
|
-
{ echo "$marker status=$STATUS -->"; cat "$RUNNER_TEMP/report/duel.md"; } > "$RUNNER_TEMP/comment.md"
|
|
251
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/comments" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
|
|
252
|
-
fi
|
|
253
|
-
<% end -%>
|
|
254
|
-
<% if mark_passed? -%>
|
|
219
|
+
gem install duel --version '<%= Duel::VERSION %>' --no-document
|
|
220
|
+
duel comment --report "$RUNNER_TEMP/report" --commit "$GITHUB_SHA" --marker '<%= marker.gsub("'") { "'\\''" } %>'
|
|
255
221
|
|
|
256
222
|
# With c.push_base = :last_passed in .duel.rb, a push is compared with
|
|
257
223
|
# the last commit Duel passed, which a branch marks (each branch pushed
|
|
258
224
|
# has its own), so slowdowns too small for any one push to fail add up
|
|
259
|
-
# until they fail one. This job moves the branch
|
|
260
|
-
# (or makes it), but never back: where a newer
|
|
261
|
-
# first, it stays. It checks nothing out and runs
|
|
262
|
-
# accept a regression, move the branch yourself
|
|
263
|
-
# origin main:duel/passed<%= "-#{working_directory.tr("/", "-")}" if working_directory %>/main).
|
|
225
|
+
# until they fail one. This job moves the branch (as Duel names it) to
|
|
226
|
+
# a push that passed (or makes it), but never back: where a newer
|
|
227
|
+
# push's run moved it first, it stays. It checks nothing out and runs
|
|
228
|
+
# none of the code. To accept a regression, move the branch yourself
|
|
229
|
+
# (for main, git push origin main:duel/passed<%= "-#{working_directory.tr("/", "-")}" if working_directory %>/main).
|
|
264
230
|
passed:
|
|
265
231
|
name: Mark the commit passed
|
|
266
232
|
needs: duel
|
|
@@ -271,51 +237,22 @@ jobs:
|
|
|
271
237
|
concurrency:
|
|
272
238
|
group: ${{ github.workflow }}-passed-${{ github.ref_name }}
|
|
273
239
|
cancel-in-progress: false
|
|
274
|
-
if: ${{ !cancelled() && github.event_name == 'push' && needs.duel.outputs.passed
|
|
240
|
+
if: ${{ !cancelled() && github.event_name == 'push' && needs.duel.outputs.passed != '' }}
|
|
275
241
|
runs-on: ubuntu-latest
|
|
276
242
|
permissions:
|
|
277
243
|
contents: write # to move the branch
|
|
278
244
|
steps:
|
|
245
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
246
|
+
with:
|
|
247
|
+
ruby-version: ruby
|
|
248
|
+
# Duel's own code, from RubyGems (none of the push's).
|
|
279
249
|
- name: Move the branch to the commit
|
|
280
250
|
env:
|
|
281
251
|
GH_TOKEN: ${{ github.token }}
|
|
282
|
-
BRANCH:
|
|
252
|
+
BRANCH: ${{ needs.duel.outputs.passed }}
|
|
283
253
|
run: |
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
# this names it.)
|
|
287
|
-
blocked() {
|
|
288
|
-
prefix=$BRANCH
|
|
289
|
-
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
290
|
-
prefix=${prefix%/*}
|
|
291
|
-
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
292
|
-
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."
|
|
293
|
-
fi
|
|
294
|
-
done
|
|
295
|
-
exit 1
|
|
296
|
-
}
|
|
297
|
-
# (Forward: GitHub moves it only where it's behind the push. Where
|
|
298
|
-
# there's no branch, and making it fails, it looks once more, as
|
|
299
|
-
# something else may have made it: a push of it, say.)
|
|
300
|
-
for _ in 1 2; do
|
|
301
|
-
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null 2>&1 && exit 0
|
|
302
|
-
at=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$BRANCH" --jq .object.sha 2>/dev/null) || at=
|
|
303
|
-
[ -n "$at" ] && break
|
|
304
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null && exit 0
|
|
305
|
-
done
|
|
306
|
-
[ -n "$at" ] || blocked
|
|
307
|
-
compared=$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$at" --jq .status 2>&1) || case "$compared" in
|
|
308
|
-
# (GitHub can't compare commits with no history in common.)
|
|
309
|
-
*"No common ancestor"*) compared=unrelated ;;
|
|
310
|
-
esac
|
|
311
|
-
case "$compared" in
|
|
312
|
-
# (A newer push's run moved it, or this one's did, run again.)
|
|
313
|
-
ahead | identical) ;;
|
|
314
|
-
# (History rewritten, a force push's, say, or replaced: moved anyway.)
|
|
315
|
-
diverged | behind | unrelated) gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null ;;
|
|
316
|
-
*) echo "::error::Couldn't compare $BRANCH with this push: $compared" && exit 1 ;;
|
|
317
|
-
esac
|
|
318
|
-
<% end -%>
|
|
254
|
+
gem install duel --version '<%= Duel::VERSION %>' --no-document
|
|
255
|
+
duel mark-passed "$BRANCH"
|
|
319
256
|
<% if badge? -%>
|
|
320
257
|
|
|
321
258
|
# Duel's badge, for the README: green (perf guarded), red (perf
|
|
@@ -328,7 +265,7 @@ jobs:
|
|
|
328
265
|
# a run for an older push than the badge's. This job writes the badge,
|
|
329
266
|
# alone, to a branch of its own, which the README shows:
|
|
330
267
|
#
|
|
331
|
-
# [}" if working_directory %>/badge.svg)](https://github.com/
|
|
268
|
+
# [}" if working_directory %>/badge.svg)](https://github.com/OWNER/REPO/actions/workflows/perf<%= "-#{working_directory.tr("/", "-")}" if working_directory %>.yml)
|
|
332
269
|
#
|
|
333
270
|
# It checks nothing out, runs none of the code, and fetches nothing.
|
|
334
271
|
badge:
|
|
@@ -347,86 +284,16 @@ jobs:
|
|
|
347
284
|
permissions:
|
|
348
285
|
contents: write # to move the badge's branch
|
|
349
286
|
steps:
|
|
287
|
+
- uses: ruby/setup-ruby@f9c4492e86def3e644ab32a0ef185eda5b0c20d0 # v1.342.0
|
|
288
|
+
with:
|
|
289
|
+
ruby-version: ruby
|
|
290
|
+
# Duel's own code, from RubyGems (none of the push's).
|
|
350
291
|
- name: Update the badge
|
|
351
292
|
env:
|
|
352
293
|
GH_TOKEN: ${{ github.token }}
|
|
353
|
-
BRANCH: duel/badge<%= "-#{working_directory.tr("/", "-")}" if working_directory %>
|
|
354
294
|
RESULT: ${{ needs.duel.result }}
|
|
355
295
|
STATUS: ${{ needs.duel.outputs.status }}
|
|
356
296
|
run: |
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
# this names it.)
|
|
360
|
-
blocked() {
|
|
361
|
-
prefix=$BRANCH
|
|
362
|
-
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
363
|
-
prefix=${prefix%/*}
|
|
364
|
-
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
365
|
-
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."
|
|
366
|
-
fi
|
|
367
|
-
done
|
|
368
|
-
exit 1
|
|
369
|
-
}
|
|
370
|
-
# (Where the badge is a newer push's, that push's run has the say.
|
|
371
|
-
# Its commit names the push.)
|
|
372
|
-
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
|
|
373
|
-
if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
|
|
374
|
-
# (Its image, written here rather than fetched from anywhere: green,
|
|
375
|
-
# red where Duel failed the push or found a regression, or grey
|
|
376
|
-
# where the Duel job failed before Duel said either.)
|
|
377
|
-
state="perf guarded" width=133 top="#34D058" bottom="#28A745" right="76.939C78.629 0 80 1.343 80"
|
|
378
|
-
if [ "$STATUS" = failed ]; then
|
|
379
|
-
state="perf regressed" width=142 top="#EA4A5A" bottom="#D73A49" right="85.939C87.629 0 89 1.343 89"
|
|
380
|
-
elif [ "$RESULT" = failure ] && [ "$STATUS" != passed ]; then
|
|
381
|
-
state="not measured" width=138 top="#959DA5" bottom="#6A737D" right="81.939C83.629 0 85 1.343 85"
|
|
382
|
-
fi
|
|
383
|
-
cat > "$RUNNER_TEMP/badge.svg" <<SVG
|
|
384
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="$width" height="20">
|
|
385
|
-
<title>Duel - $state</title>
|
|
386
|
-
<defs>
|
|
387
|
-
<linearGradient id="duel-fill" x1="50%" y1="0%" x2="50%" y2="100%">
|
|
388
|
-
<stop stop-color="#444D56" offset="0%"></stop>
|
|
389
|
-
<stop stop-color="#24292E" offset="100%"></stop>
|
|
390
|
-
</linearGradient>
|
|
391
|
-
<linearGradient id="state-fill" x1="50%" y1="0%" x2="50%" y2="100%">
|
|
392
|
-
<stop stop-color="$top" offset="0%"></stop>
|
|
393
|
-
<stop stop-color="$bottom" offset="100%"></stop>
|
|
394
|
-
</linearGradient>
|
|
395
|
-
</defs>
|
|
396
|
-
<g fill="none" fill-rule="evenodd">
|
|
397
|
-
<g font-family="'DejaVu Sans',Verdana,Geneva,sans-serif" font-size="11">
|
|
398
|
-
<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>
|
|
399
|
-
<text fill="#010101" fill-opacity=".3">
|
|
400
|
-
<tspan x="22.1981982" y="15" aria-hidden="true">Duel</tspan>
|
|
401
|
-
</text>
|
|
402
|
-
<text fill="#FFFFFF">
|
|
403
|
-
<tspan x="22.1981982" y="14">Duel</tspan>
|
|
404
|
-
</text>
|
|
405
|
-
</g>
|
|
406
|
-
<g transform="translate(53)" font-family="'DejaVu Sans',Verdana,Geneva,sans-serif" font-size="11">
|
|
407
|
-
<path d="M0 0h$right 3v14c0 1.657-1.37 3-3.061 3H0V0z" fill="url(#state-fill)" fill-rule="nonzero"></path>
|
|
408
|
-
<text fill="#010101" fill-opacity=".3" aria-hidden="true">
|
|
409
|
-
<tspan x="4" y="15">$state</tspan>
|
|
410
|
-
</text>
|
|
411
|
-
<text fill="#FFFFFF">
|
|
412
|
-
<tspan x="4" y="14">$state</tspan>
|
|
413
|
-
</text>
|
|
414
|
-
</g>
|
|
415
|
-
<g fill="#959DA5">
|
|
416
|
-
<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>
|
|
417
|
-
<circle cx="16.6" cy="15.6" r="1.1"></circle>
|
|
418
|
-
<circle cx="5.4" cy="15.6" r="1.1"></circle>
|
|
419
|
-
</g>
|
|
420
|
-
<g stroke="#959DA5" stroke-linecap="round">
|
|
421
|
-
<path d="M12.1 14.5L15.5 11.1 M9.9 14.5L6.5 11.1" stroke-width="1.6"></path>
|
|
422
|
-
<path d="M13.8 12.8L16 15 M8.2 12.8L6 15" stroke-width="1.8"></path>
|
|
423
|
-
</g>
|
|
424
|
-
</g>
|
|
425
|
-
</svg>
|
|
426
|
-
SVG
|
|
427
|
-
tree=$(jq -n --rawfile svg "$RUNNER_TEMP/badge.svg" '{tree: [{path: "badge.svg", mode: "100644", type: "blob", content: $svg}]}' |
|
|
428
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/git/trees" --input - --jq .sha)
|
|
429
|
-
commit=$(gh api --method POST "repos/$GITHUB_REPOSITORY/git/commits" -f message="Duel's badge, for $GITHUB_SHA" -f tree="$tree" --jq .sha)
|
|
430
|
-
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$commit" -F force=true > /dev/null 2>&1 ||
|
|
431
|
-
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$commit" > /dev/null || blocked
|
|
297
|
+
gem install duel --version '<%= Duel::VERSION %>' --no-document
|
|
298
|
+
duel badge duel/badge<%= "-#{working_directory.tr("/", "-")}" if working_directory %> --status "$STATUS" --result "$RESULT"
|
|
432
299
|
<% end -%>
|
data/sig/duel/rails.rbs
CHANGED
|
@@ -24,7 +24,7 @@ module Duel
|
|
|
24
24
|
# options).
|
|
25
25
|
def self.configure: (Config config, ?database: Symbol?, ?environment: String, ?bundle: bool,
|
|
26
26
|
?fixtures: Array[Symbol | String] | :all, ?seeds: bool, ?seed: Integer, ?reset: bool, ?jobs: bool,
|
|
27
|
-
?active_record: bool, ?
|
|
27
|
+
?active_record: bool, ?database_options: Hash[Symbol, untyped]) -> Counter
|
|
28
28
|
|
|
29
29
|
# Boots the version at +root+ in +environment+, from its own tree.
|
|
30
30
|
def self.boot: (String root, String environment) -> bool
|
|
@@ -66,7 +66,7 @@ module Duel
|
|
|
66
66
|
# The URL's scheme, by database, where the plugin's own isn't it.
|
|
67
67
|
SCHEMES: Hash[Symbol, String]
|
|
68
68
|
|
|
69
|
-
def self.configure: (Config config, Symbol database,
|
|
69
|
+
def self.configure: (Config config, Symbol database, ?Hash[Symbol, untyped] options) -> untyped
|
|
70
70
|
|
|
71
71
|
# Loads the version's schema into the worker's database.
|
|
72
72
|
def self.load_schema: () -> void
|
|
@@ -105,7 +105,7 @@ module Duel
|
|
|
105
105
|
def hooks: () -> Hash[Symbol, untyped]
|
|
106
106
|
|
|
107
107
|
# Defines a benchmark of the request, on a file of benchmarks' DSL.
|
|
108
|
-
def self.duel: (::Duel::DSL dsl, String name, String request, ?
|
|
108
|
+
def self.duel: (::Duel::DSL dsl, String name, String request, ?judge: ::Duel::judged | Array[::Duel::judged], **untyped options) ?{ (Hash[String, untyped] env) [self: untyped] -> void } -> void
|
|
109
109
|
|
|
110
110
|
private
|
|
111
111
|
|
|
@@ -231,6 +231,8 @@ module Duel
|
|
|
231
231
|
# where one does.
|
|
232
232
|
def check_workflows: () -> void
|
|
233
233
|
|
|
234
|
+
@repository: String?
|
|
235
|
+
|
|
234
236
|
private
|
|
235
237
|
|
|
236
238
|
def checking?: () -> bool
|
|
@@ -251,11 +253,7 @@ module Duel
|
|
|
251
253
|
def settings: () -> Config?
|
|
252
254
|
def load_settings: () -> Config?
|
|
253
255
|
|
|
254
|
-
# Whether the workflow comments on a pushed commit.
|
|
255
|
-
def comment_on_pushes?: () -> bool
|
|
256
256
|
|
|
257
|
-
# Whether the workflow marks a push passed.
|
|
258
|
-
def mark_passed?: () -> bool
|
|
259
257
|
|
|
260
258
|
# The label that accepts a regression, for the workflows, or nil.
|
|
261
259
|
def accept_label: () -> String?
|
|
@@ -273,6 +271,7 @@ module Duel
|
|
|
273
271
|
def version_file?: () -> bool
|
|
274
272
|
def ruby_version: () -> String?
|
|
275
273
|
def repository: () -> String
|
|
274
|
+
def find_repository: () -> String
|
|
276
275
|
def working_directory: () -> String?
|
|
277
276
|
|
|
278
277
|
# What marks the workflow's comment on a pull request.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: duel-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Erik Berlin
|
|
@@ -16,7 +16,7 @@ dependencies:
|
|
|
16
16
|
-
|
|
17
17
|
- ~>
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.3.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -24,7 +24,7 @@ dependencies:
|
|
|
24
24
|
-
|
|
25
25
|
- ~>
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version:
|
|
27
|
+
version: 0.3.0
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: duel-activerecord
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -32,7 +32,7 @@ dependencies:
|
|
|
32
32
|
-
|
|
33
33
|
- ~>
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
|
-
version:
|
|
35
|
+
version: 0.3.0
|
|
36
36
|
type: :runtime
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -40,7 +40,7 @@ dependencies:
|
|
|
40
40
|
-
|
|
41
41
|
- ~>
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version:
|
|
43
|
+
version: 0.3.0
|
|
44
44
|
- !ruby/object:Gem::Dependency
|
|
45
45
|
name: railties
|
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|