duel-rails 0.1.2 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 071eed2da6a655fb491f21479c313937875acddc148f87a9c194798492f9f998
4
- data.tar.gz: fc054a813446a26d4bdc9a4d8206900bb159f29f77da64e9194b5c30e89b69ef
3
+ metadata.gz: 021457e88a614ab2d707bbaa4e5b0492ad8ce632288b9a2050e12c22e03b4426
4
+ data.tar.gz: 4123646895aa5f9988ec93e043247e14acab50c796158ee3c74c102ae6f524a5
5
5
  SHA512:
6
- metadata.gz: 616d941adc922119cc512a5616e7a45a7ca9aa1138215112404d112f4829c45d28d0bb26452c4beb8310d9d789a62d86546b4443eab9076602a4252af710ae22
7
- data.tar.gz: 48e2327b9da27b1b34f1ce6eacd4a19abf237a7ee9f893b82e5b6cb361d21c7e3644fdb709411c90988c28b3add7a8c12b62f2797346960fcb166db816a451e6
6
+ metadata.gz: ebc28766c172ebb6b905784a20503f6a7c11afe5a4f92845adef9228761d19bc8040fefdf195c28d4ee904e5d07a09780c6a6416da9233b26b68e460eeeae0b8
7
+ data.tar.gz: 79c3f8e04acd75e7510bfef3f700ee03ce5f8aa8310da48c1c90c32dfd5fd2b9be0dbaaaa38a2209d38b14e7455efaeaabd895021febb6625a033fa4ef87046e
data/CHANGELOG.md CHANGED
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.4] - 2026-11-06
11
+
12
+ ### Fixed
13
+
14
+ - Where a repository's history was replaced, so the commit that
15
+ `duel/passed/BRANCH` marks has no history in common with a push, the
16
+ Mark the commit passed job in the workflow that
17
+ `rails generate duel:install` writes failed, as GitHub can't compare
18
+ the two. It now moves the branch to the push, as it does where
19
+ history was rewritten. Update the job in
20
+ `.github/workflows/perf.yml` to pick this up.
21
+
22
+ ## [0.1.3] - 2026-11-04
23
+
24
+ ### Added
25
+
26
+ - The workflow that `rails generate duel:install` writes keeps Duel's
27
+ badge, which turns red when Duel fails a push to the default branch,
28
+ as the workflow that `duel init` writes does.
29
+
30
+ ### Fixed
31
+
32
+ - The workflow that `rails generate duel:install` writes no longer
33
+ moves the branch that marks the last commit Duel passed backward,
34
+ when two pushes run at once and the older one finishes last.
35
+ - Where a branch named `duel` keeps that workflow from making its
36
+ branches, as Git can't have both, the job's error names it.
37
+
10
38
  ## [0.1.2] - 2026-11-02
11
39
 
12
40
  ### Added
@@ -178,7 +206,9 @@ Rails 7.2 or later, and Ruby 3.4 or later.
178
206
  CI.
179
207
  - RBS signatures in sig/, checked with Steep.
180
208
 
181
- [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.2...HEAD
209
+ [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.4...HEAD
210
+ [0.1.4]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.3...duel-rails-v0.1.4
211
+ [0.1.3]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.2...duel-rails-v0.1.3
182
212
  [0.1.2]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.1...duel-rails-v0.1.2
183
213
  [0.1.1]: https://github.com/sferik/duel-ruby/compare/duel-rails-v0.1.0...duel-rails-v0.1.1
184
214
  [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
- [![Duel](https://raw.githubusercontent.com/sferik/duel-ruby/main/assets/badge.svg)](https://github.com/sferik/duel-ruby)
3
+ [![Duel](https://raw.githubusercontent.com/sferik/duel-ruby/duel/badge-plugins-rails/badge.svg)](https://github.com/sferik/duel-ruby/actions/workflows/plugin-rails.yml)
4
4
  [![duel-rails](https://github.com/sferik/duel-ruby/actions/workflows/plugin-rails.yml/badge.svg)](https://github.com/sferik/duel-ruby/actions/workflows/plugin-rails.yml)
5
5
  [![Gem Version](https://badge.fury.io/rb/duel-rails.svg)](https://rubygems.org/gems/duel-rails)
6
6
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Duel
4
4
  module Rails
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
@@ -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). It checks nothing out and runs none of the code. To
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,87 @@ 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
- gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null 2>&1 ||
246
- gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null
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 2>&1) || case "$compared" in
267
+ # (GitHub can't compare commits with no history in common.)
268
+ *"No common ancestor"*) compared=unrelated ;;
269
+ esac
270
+ case "$compared" in
271
+ # (A newer push's run moved it, or this one's did, run again.)
272
+ ahead | identical) ;;
273
+ # (History rewritten, a force push's, say, or replaced: moved anyway.)
274
+ diverged | behind | unrelated) gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null ;;
275
+ *) echo "::error::Couldn't compare $BRANCH with this push: $compared" && exit 1 ;;
276
+ esac
277
+
278
+ # Duel's badge, for the README: green (perf guarded) or red (perf
279
+ # regressed), as the last push to the default branch that Duel compared
280
+ # left it. It's red where the Duel job failed or found a regression,
281
+ # even one that passed (with c.fail_on = :pull_requests in .duel.rb). A
282
+ # push with nothing to compare leaves it as it was, and so does a run
283
+ # for an older push than the badge's. This job writes the badge, alone,
284
+ # to a branch of its own, which the README shows:
285
+ #
286
+ # [![Duel](https://raw.githubusercontent.com/OWNER/REPO/duel/badge<%= "-#{working_directory.tr("/", "-")}" if working_directory %>/badge.svg)](https://github.com/sferik/duel-ruby)
287
+ #
288
+ # It checks nothing out and runs none of the code.
289
+ badge:
290
+ name: Update the badge
291
+ needs: duel
292
+ 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') }}
293
+ runs-on: ubuntu-latest
294
+ permissions:
295
+ contents: write # to move the badge's branch
296
+ steps:
297
+ - name: Update the badge
298
+ env:
299
+ GH_TOKEN: ${{ github.token }}
300
+ BRANCH: duel/badge<%= "-#{working_directory.tr("/", "-")}" if working_directory %>
301
+ RESULT: ${{ needs.duel.result }}
302
+ STATUS: ${{ needs.duel.outputs.status }}
303
+ BADGES: https://raw.githubusercontent.com/sferik/duel-ruby/main/assets
304
+ run: |
305
+ # (Git can't make a branch where another's name is a folder of its
306
+ # name: a branch named duel blocks duel/passed/main. If one does,
307
+ # this names it.)
308
+ blocked() {
309
+ prefix=$BRANCH
310
+ while [ "${prefix%/*}" != "$prefix" ]; do
311
+ prefix=${prefix%/*}
312
+ if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
313
+ 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."
314
+ fi
315
+ done
316
+ exit 1
317
+ }
318
+ # (Where the badge is a newer push's, that push's run has the say.
319
+ # Its commit names the push.)
320
+ 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
321
+ if [ -n "$last" ] && [ "$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$last" --jq .status 2>/dev/null)" = ahead ]; then exit 0; fi
322
+ badge="badge.svg"
323
+ if [ "$RESULT" = failure ] || [ "$STATUS" = failed ]; then badge="badge-regressed.svg"; fi
324
+ curl -fsSL "$BADGES/$badge" -o "$RUNNER_TEMP/badge.svg"
325
+ tree=$(jq -n --rawfile svg "$RUNNER_TEMP/badge.svg" '{tree: [{path: "badge.svg", mode: "100644", type: "blob", content: $svg}]}' |
326
+ gh api --method POST "repos/$GITHUB_REPOSITORY/git/trees" --input - --jq .sha)
327
+ commit=$(gh api --method POST "repos/$GITHUB_REPOSITORY/git/commits" -f message="Duel's badge, for $GITHUB_SHA" -f tree="$tree" --jq .sha)
328
+ gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$commit" -F force=true > /dev/null 2>&1 ||
329
+ gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$commit" > /dev/null || blocked
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.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Berlin
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 4.0.23
104
+ rubygems_version: 4.0.24
105
105
  specification_version: 4
106
106
  summary: Performance regression guards for Rails apps, with Duel
107
107
  test_files: []