duel-rails 0.1.2 → 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 +18 -1
- data/README.md +1 -1
- data/lib/duel/rails/version.rb +1 -1
- data/lib/generators/duel/install/templates/perf.yml.tt +83 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8db301599243e791675a6b559317ba8b34750acad2cc3161291688be6a0041cc
|
|
4
|
+
data.tar.gz: c4176c74c66f891ca02a02050ffe58bdc37d518a1c27a46f6793a49ad51b5de2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8983e62eeca17ea30e8f81ce14de3ceead0ea651d0dd4fc859dacb1893603be8b2901695052a9e76be408aeaf5e7b263de3167d588bdd9a59a20291e9653c8ea
|
|
7
|
+
data.tar.gz: 70ab9159e0028e47101153a7096d3496f3e55b2a48c59fa399eb3f4602676a52028b0f3526547b8a36342093656cf2ade4513a09d0ccee34612cc4e5f46e34c4
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.3] - 2026-11-04
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- The workflow that `rails generate duel:install` writes keeps Duel's
|
|
15
|
+
badge, which turns red when Duel fails a push to the default branch,
|
|
16
|
+
as the workflow that `duel init` writes does.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- The workflow that `rails generate duel:install` writes no longer
|
|
21
|
+
moves the branch that marks the last commit Duel passed backward,
|
|
22
|
+
when two pushes run at once and the older one finishes last.
|
|
23
|
+
- Where a branch named `duel` keeps that workflow from making its
|
|
24
|
+
branches, as Git can't have both, the job's error names it.
|
|
25
|
+
|
|
10
26
|
## [0.1.2] - 2026-11-02
|
|
11
27
|
|
|
12
28
|
### Added
|
|
@@ -178,7 +194,8 @@ Rails 7.2 or later, and Ruby 3.4 or later.
|
|
|
178
194
|
CI.
|
|
179
195
|
- RBS signatures in sig/, checked with Steep.
|
|
180
196
|
|
|
181
|
-
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.
|
|
197
|
+
[Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.3...HEAD
|
|
198
|
+
[0.1.3]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.2...duel-rails-v0.1.3
|
|
182
199
|
[0.1.2]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.1...duel-rails-v0.1.2
|
|
183
200
|
[0.1.1]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.0...duel-rails-v0.1.1
|
|
184
201
|
[0.1.0]: https://github.com/sferik/duel-ruby/releases/tag/duel-rails-v0.1.0
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# duel-rails
|
|
2
2
|
|
|
3
|
-
[](https://github.com/sferik/duel-ruby/actions/workflows/plugin-rails.yml)
|
|
4
4
|
[](https://github.com/sferik/duel-ruby/actions/workflows/plugin-rails.yml)
|
|
5
5
|
[](https://rubygems.org/gems/duel-rails)
|
|
6
6
|
|
data/lib/duel/rails/version.rb
CHANGED
|
@@ -226,7 +226,8 @@ jobs:
|
|
|
226
226
|
# the last commit Duel passed, which a branch marks (each branch pushed
|
|
227
227
|
# has its own), so slowdowns too small for any one push to fail add up
|
|
228
228
|
# until they fail one. This job moves the branch to a push that passed
|
|
229
|
-
# (or makes it)
|
|
229
|
+
# (or makes it), but never back: where a newer push's run moved it
|
|
230
|
+
# first, it stays. It checks nothing out and runs none of the code. To
|
|
230
231
|
# accept a regression, move the branch yourself (for main, git push
|
|
231
232
|
# origin main:duel/passed<%= "-#{working_directory.tr("/", "-")}" if working_directory %>/main).
|
|
232
233
|
passed:
|
|
@@ -242,5 +243,84 @@ jobs:
|
|
|
242
243
|
GH_TOKEN: ${{ github.token }}
|
|
243
244
|
BRANCH: duel/passed<%= "-#{working_directory.tr("/", "-")}" if working_directory %>/${{ github.ref_name }}
|
|
244
245
|
run: |
|
|
245
|
-
|
|
246
|
-
|
|
246
|
+
# (Git can't make a branch where another's name is a folder of its
|
|
247
|
+
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
248
|
+
# this names it.)
|
|
249
|
+
blocked() {
|
|
250
|
+
prefix=$BRANCH
|
|
251
|
+
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
252
|
+
prefix=${prefix%/*}
|
|
253
|
+
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
254
|
+
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."
|
|
255
|
+
fi
|
|
256
|
+
done
|
|
257
|
+
exit 1
|
|
258
|
+
}
|
|
259
|
+
# (Forward: GitHub moves it only where it's behind the push.)
|
|
260
|
+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null 2>&1 && exit 0
|
|
261
|
+
at=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$BRANCH" --jq .object.sha 2>/dev/null) || at=
|
|
262
|
+
if [ -z "$at" ]; then
|
|
263
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null || blocked
|
|
264
|
+
exit 0
|
|
265
|
+
fi
|
|
266
|
+
compared=$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$at" --jq .status)
|
|
267
|
+
case "$compared" in
|
|
268
|
+
# (A newer push's run moved it, or this one's did, run again.)
|
|
269
|
+
ahead | identical) ;;
|
|
270
|
+
# (History rewritten, a force push's, say: moved anyway.)
|
|
271
|
+
diverged | behind) gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null ;;
|
|
272
|
+
*) echo "::error::Couldn't compare $BRANCH with this push: $compared" && exit 1 ;;
|
|
273
|
+
esac
|
|
274
|
+
|
|
275
|
+
# Duel's badge, for the README: green (perf guarded) or red (perf
|
|
276
|
+
# regressed), as the last push to the default branch that Duel compared
|
|
277
|
+
# left it. It's red where the Duel job failed or found a regression,
|
|
278
|
+
# even one that passed (with c.fail_on = :pull_requests in .duel.rb). A
|
|
279
|
+
# push with nothing to compare leaves it as it was, and so does a run
|
|
280
|
+
# for an older push than the badge's. This job writes the badge, alone,
|
|
281
|
+
# to a branch of its own, which the README shows:
|
|
282
|
+
#
|
|
283
|
+
# [}" if working_directory %>/badge.svg)](https://github.com/sferik/duel-ruby)
|
|
284
|
+
#
|
|
285
|
+
# It checks nothing out and runs none of the code.
|
|
286
|
+
badge:
|
|
287
|
+
name: Update the badge
|
|
288
|
+
needs: duel
|
|
289
|
+
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') }}
|
|
290
|
+
runs-on: ubuntu-latest
|
|
291
|
+
permissions:
|
|
292
|
+
contents: write # to move the badge's branch
|
|
293
|
+
steps:
|
|
294
|
+
- name: Update the badge
|
|
295
|
+
env:
|
|
296
|
+
GH_TOKEN: ${{ github.token }}
|
|
297
|
+
BRANCH: duel/badge<%= "-#{working_directory.tr("/", "-")}" if working_directory %>
|
|
298
|
+
RESULT: ${{ needs.duel.result }}
|
|
299
|
+
STATUS: ${{ needs.duel.outputs.status }}
|
|
300
|
+
BADGES: https://raw.githubusercontent.com/sferik/duel-ruby/main/assets
|
|
301
|
+
run: |
|
|
302
|
+
# (Git can't make a branch where another's name is a folder of its
|
|
303
|
+
# name: a branch named duel blocks duel/passed/main. If one does,
|
|
304
|
+
# this names it.)
|
|
305
|
+
blocked() {
|
|
306
|
+
prefix=$BRANCH
|
|
307
|
+
while [ "${prefix%/*}" != "$prefix" ]; do
|
|
308
|
+
prefix=${prefix%/*}
|
|
309
|
+
if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
|
|
310
|
+
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."
|
|
311
|
+
fi
|
|
312
|
+
done
|
|
313
|
+
exit 1
|
|
314
|
+
}
|
|
315
|
+
# (Where the badge is a newer push's, that push's run has the say.
|
|
316
|
+
# Its commit names the push.)
|
|
317
|
+
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
|
|
318
|
+
if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
|
|
319
|
+
badge="badge.svg"
|
|
320
|
+
if [ "$RESULT" = failure ] || [ "$STATUS" = failed ]; then badge="badge-regressed.svg"; fi
|
|
321
|
+
curl -fsSL "$BADGES/$badge" -o "$RUNNER_TEMP/badge.svg"
|
|
322
|
+
tree=$(jq -n --rawfile svg "$RUNNER_TEMP/badge.svg" '{tree: [{path: "badge.svg", mode: "100644", type: "blob", content: $svg}]}' |
|
|
323
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/trees" --input - --jq .sha)
|
|
324
|
+
commit=$(gh api --method POST "repos/$GITHUB_REPOSITORY/git/commits" -f message="Duel's badge, for $GITHUB_SHA" -f tree="$tree" --jq .sha)
|
|
325
|
+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$commit" -F force=true > /dev/null 2>&1 ||
|
|
326
|
+
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$commit" > /dev/null || blocked
|