kettle-jem 7.1.42 → 7.1.44

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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +129 -7
  4. data/README.md +30 -3
  5. data/lib/kettle/jem/ci/harden_macos_ca_bundle.sh +75 -0
  6. data/lib/kettle/jem/maintenance_changelog.rb +1 -1
  7. data/lib/kettle/jem/tasks/install_task.rb +98 -5
  8. data/lib/kettle/jem/templates/.duel.rb.example +10 -0
  9. data/lib/kettle/jem/templates/.git-hooks/commit-msg.example +6 -6
  10. data/lib/kettle/jem/templates/.git-hooks/commit-subjects-goalie.txt.example +7 -1
  11. data/lib/kettle/jem/templates/.github/workflows/coverage.yml.example +1 -1
  12. data/lib/kettle/jem/templates/.github/workflows/current.yml.example +2 -2
  13. data/lib/kettle/jem/templates/.github/workflows/dep-heads.yml.example +3 -3
  14. data/lib/kettle/jem/templates/.github/workflows/dependency-review.yml.example +1 -1
  15. data/lib/kettle/jem/templates/.github/workflows/discord-notifier.yml.example +1 -1
  16. data/lib/kettle/jem/templates/.github/workflows/framework-ci.yml.example +1 -1
  17. data/lib/kettle/jem/templates/.github/workflows/heads.yml.example +2 -2
  18. data/lib/kettle/jem/templates/.github/workflows/jruby-10.0.yml.example +1 -1
  19. data/lib/kettle/jem/templates/.github/workflows/jruby-9.1.yml.example +1 -1
  20. data/lib/kettle/jem/templates/.github/workflows/jruby-9.2.yml.example +1 -1
  21. data/lib/kettle/jem/templates/.github/workflows/jruby-9.3.yml.example +1 -1
  22. data/lib/kettle/jem/templates/.github/workflows/jruby-9.4.yml.example +1 -1
  23. data/lib/kettle/jem/templates/.github/workflows/jruby.yml.example +1 -1
  24. data/lib/kettle/jem/templates/.github/workflows/locked_deps.yml.example +1 -1
  25. data/lib/kettle/jem/templates/.github/workflows/opencollective.yml.example +1 -1
  26. data/lib/kettle/jem/templates/.github/workflows/perf-comment.yml.example +92 -0
  27. data/lib/kettle/jem/templates/.github/workflows/perf.yml.example +152 -69
  28. data/lib/kettle/jem/templates/.github/workflows/ruby-2.3.yml.example +1 -1
  29. data/lib/kettle/jem/templates/.github/workflows/ruby-2.4.yml.example +1 -1
  30. data/lib/kettle/jem/templates/.github/workflows/ruby-2.5.yml.example +1 -1
  31. data/lib/kettle/jem/templates/.github/workflows/ruby-2.6.yml.example +1 -1
  32. data/lib/kettle/jem/templates/.github/workflows/ruby-2.7.yml.example +1 -1
  33. data/lib/kettle/jem/templates/.github/workflows/ruby-3.0.yml.example +1 -1
  34. data/lib/kettle/jem/templates/.github/workflows/ruby-3.1.yml.example +1 -1
  35. data/lib/kettle/jem/templates/.github/workflows/ruby-3.2.yml.example +1 -1
  36. data/lib/kettle/jem/templates/.github/workflows/ruby-3.3.yml.example +1 -1
  37. data/lib/kettle/jem/templates/.github/workflows/ruby-3.4.yml.example +1 -1
  38. data/lib/kettle/jem/templates/.github/workflows/style.yml.example +1 -1
  39. data/lib/kettle/jem/templates/.github/workflows/templating.yml.example +1 -1
  40. data/lib/kettle/jem/templates/.github/workflows/truffle.yml.example +1 -1
  41. data/lib/kettle/jem/templates/.github/workflows/truffleruby-22.3.yml.example +1 -1
  42. data/lib/kettle/jem/templates/.github/workflows/truffleruby-23.1.yml.example +1 -1
  43. data/lib/kettle/jem/templates/.github/workflows/truffleruby-24.2.yml.example +1 -1
  44. data/lib/kettle/jem/templates/.github/workflows/truffleruby-25.0.yml.example +1 -1
  45. data/lib/kettle/jem/templates/.github/workflows/truffleruby-33.0.yml.example +1 -1
  46. data/lib/kettle/jem/templates/.github/workflows/unlocked_deps.yml.example +1 -1
  47. data/lib/kettle/jem/templates/.structuredmerge/kettle-jem.yml.example +2 -2
  48. data/lib/kettle/jem/templates/Appraisals.example +12 -0
  49. data/lib/kettle/jem/templates/CONTRIBUTING.md.example +5 -1
  50. data/lib/kettle/jem/templates/Gemfile.example +3 -1
  51. data/lib/kettle/jem/templates/gem.gemspec.example +10 -6
  52. data/lib/kettle/jem/templates/gemfiles/modular/coverage.gemfile.example +1 -1
  53. data/lib/kettle/jem/templates/gemfiles/modular/debug.gemfile.example +1 -1
  54. data/lib/kettle/jem/templates/gemfiles/modular/documentation.gemfile.example +5 -5
  55. data/lib/kettle/jem/templates/gemfiles/modular/duel.gemfile.example +1 -1
  56. data/lib/kettle/jem/templates/gemfiles/modular/optional.gemfile.example +1 -1
  57. data/lib/kettle/jem/templates/gemfiles/modular/ostruct/r4/v0.6.gemfile.example +1 -1
  58. data/lib/kettle/jem/templates/gemfiles/modular/rspec.gemfile.example +12 -4
  59. data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r2/v0.6.gemfile.example +7 -0
  60. data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r3/v0.8.gemfile.example +2 -0
  61. data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r3.2/v0.6.gemfile.example +7 -0
  62. data/lib/kettle/jem/templates/gemfiles/modular/rspec_junit_formatter/r4/v0.8.gemfile.example +2 -0
  63. data/lib/kettle/jem/templates/gemfiles/modular/style_local.gemfile.example +1 -1
  64. data/lib/kettle/jem/templates/gemfiles/modular/templating.gemfile.example +2 -1
  65. data/lib/kettle/jem/templates/gemfiles/modular/templating_local.gemfile.example +34 -18
  66. data/lib/kettle/jem/templates/gemfiles/modular/x_std_libs.gemfile.example +10 -2
  67. data/lib/kettle/jem/templates/readme/partials/configuration.md.example +3 -0
  68. data/lib/kettle/jem/templates/shim/Gemfile.example +1 -1
  69. data/lib/kettle/jem/templates/shim/gem.gemspec.example +3 -3
  70. data/lib/kettle/jem/version.rb +1 -1
  71. data/lib/kettle/jem.rb +729 -104
  72. data.tar.gz.sig +0 -0
  73. metadata +1187 -1037
  74. metadata.gz.sig +0 -0
  75. data/lib/kettle/jem/templates/.idea/.gitignore.example +0 -44
@@ -31,7 +31,7 @@ jobs:
31
31
  # Steps represent a sequence of tasks that will be executed as part of the job
32
32
  steps:
33
33
  - name: Actions Status Discord
34
- uses: sarisia/actions-status-discord@eb045afee445dc055c18d3d90bd0f244fd062708 # v1.16.0
34
+ uses: sarisia/actions-status-discord@74e2ad0c4e57ca8b9ba6aee75d5a7841497bbb87 # v1.16.1
35
35
  if: always()
36
36
  with:
37
37
  webhook: ${{ secrets.DISCORD_WEBHOOK }}
@@ -61,7 +61,7 @@ jobs:
61
61
  persist-credentials: false
62
62
 
63
63
  - name: Setup Ruby & RubyGems
64
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
64
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
65
65
  with:
66
66
  ruby-version: "${{ matrix.ruby }}"
67
67
  rubygems: "${{ matrix.rubygems }}"
@@ -57,7 +57,7 @@ jobs:
57
57
 
58
58
  - name: Setup Ruby & RubyGems
59
59
  if: ${{ !env.ACT }}
60
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
60
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
61
61
  with:
62
62
  ruby-version: ${{ matrix.ruby }}
63
63
  rubygems: ${{ matrix.rubygems }}
@@ -123,7 +123,7 @@ jobs:
123
123
 
124
124
  - name: Setup Ruby & RubyGems
125
125
  if: ${{ !env.ACT }}
126
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
126
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
127
127
  with:
128
128
  ruby-version: ${{ matrix.ruby }}
129
129
  rubygems: ${{ matrix.rubygems }}
@@ -63,7 +63,7 @@ jobs:
63
63
 
64
64
  - name: Setup Ruby & RubyGems
65
65
  if: ${{ !env.ACT }}
66
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
66
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
67
67
  with:
68
68
  ruby-version: ${{ matrix.ruby }}
69
69
  rubygems: ${{ matrix.rubygems }}
@@ -62,7 +62,7 @@ jobs:
62
62
 
63
63
  - name: Setup Ruby & RubyGems
64
64
  if: ${{ !env.ACT }}
65
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
65
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
66
66
  with:
67
67
  ruby-version: ${{ matrix.ruby }}
68
68
  rubygems: ${{ matrix.rubygems }}
@@ -62,7 +62,7 @@ jobs:
62
62
 
63
63
  - name: Setup Ruby & RubyGems
64
64
  if: ${{ !env.ACT }}
65
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
65
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
66
66
  with:
67
67
  ruby-version: ${{ matrix.ruby }}
68
68
  rubygems: ${{ matrix.rubygems }}
@@ -62,7 +62,7 @@ jobs:
62
62
 
63
63
  - name: Setup Ruby & RubyGems
64
64
  if: ${{ !env.ACT }}
65
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
65
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
66
66
  with:
67
67
  ruby-version: ${{ matrix.ruby }}
68
68
  rubygems: ${{ matrix.rubygems }}
@@ -62,7 +62,7 @@ jobs:
62
62
 
63
63
  - name: Setup Ruby & RubyGems
64
64
  if: ${{ !env.ACT }}
65
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
65
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
66
66
  with:
67
67
  ruby-version: ${{ matrix.ruby }}
68
68
  rubygems: ${{ matrix.rubygems }}
@@ -63,7 +63,7 @@ jobs:
63
63
 
64
64
  - name: Setup Ruby & RubyGems
65
65
  if: ${{ !env.ACT }}
66
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
66
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
67
67
  with:
68
68
  ruby-version: ${{ matrix.ruby }}
69
69
  rubygems: ${{ matrix.rubygems }}
@@ -77,7 +77,7 @@ jobs:
77
77
  persist-credentials: false
78
78
 
79
79
  - name: Setup Ruby & RubyGems
80
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
80
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
81
81
  with:
82
82
  ruby-version: ${{ matrix.ruby }}
83
83
  rubygems: ${{ matrix.rubygems }}
@@ -20,7 +20,7 @@ jobs:
20
20
  with:
21
21
  persist-credentials: false
22
22
  - name: Setup Ruby & RubyGems
23
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
23
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
24
24
  with:
25
25
  ruby-version: ruby
26
26
  rubygems: default
@@ -0,0 +1,92 @@
1
+ name: Perf comment
2
+
3
+ # Duel's report, as a new comment on the pull request, when Duel says to:
4
+ # always (post), or only when its last comment's status differs from the
5
+ # run's (change), so the latest comment is never stale. It never edits or
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.
15
+ #
16
+ # And when the label that accepts a regression (c.accept_label in
17
+ # .duel.rb) is added to a pull request, or taken off, it runs the Duel
18
+ # job again, which reads the labels as it runs: a run that failed, once
19
+ # the label's added, or one that passed, once it's taken off.
20
+ #
21
+ # (The workflow must be on the default branch before it runs at all.)
22
+ on:
23
+ workflow_run:
24
+ workflows: ["Perf"]
25
+ types: [completed]
26
+ # (This repository's own workflow, as for the comment, with a token
27
+ # that can run a workflow again: it checks nothing out, and runs none
28
+ # of the pull request's code.)
29
+ pull_request_target:
30
+ types: [labeled, unlabeled]
31
+
32
+ permissions: {}
33
+
34
+ jobs:
35
+ comment:
36
+ name: Comment
37
+ if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion != 'cancelled' }}
38
+ runs-on: ubuntu-latest
39
+ permissions:
40
+ actions: read # to get the report from the Perf run
41
+ pull-requests: write # to comment on the pull request with the report
42
+ steps:
43
+ - name: Get the report
44
+ id: report
45
+ continue-on-error: true # there's none when the Duel job failed before comparing
46
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
47
+ with:
48
+ name: duel-report
49
+ path: ${{ runner.temp }}/report
50
+ run-id: ${{ github.event.workflow_run.id }}
51
+ github-token: ${{ github.token }}
52
+ - uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
53
+ if: steps.report.outcome == 'success'
54
+ with:
55
+ ruby-version: ruby
56
+ # Duel's own code, from RubyGems (none of the pull request's), so a
57
+ # fix to how it comments comes with a release of Duel.
58
+ - name: Comment on the pull request
59
+ if: steps.report.outcome == 'success'
60
+ env:
61
+ GH_TOKEN: ${{ github.token }}
62
+ HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
63
+ run: |
64
+ gem install duel --version '~> 0.1.8' --no-document
65
+ duel comment --report "$RUNNER_TEMP/report" --head "$HEAD_SHA" --marker 'duel'
66
+
67
+ again:
68
+ name: Run Duel again
69
+ if: >-
70
+ github.event_name == 'pull_request_target' && github.event.label.name == 'duel: accept'
71
+ runs-on: ubuntu-latest
72
+ permissions:
73
+ actions: write # to run the Perf workflow's jobs again
74
+ steps:
75
+ - name: Run Duel again
76
+ env:
77
+ GH_TOKEN: ${{ github.token }}
78
+ GH_REPO: ${{ github.repository }}
79
+ HEAD_SHA: ${{ github.event.pull_request.head.sha }}
80
+ ACTION: ${{ github.event.action }}
81
+ run: |
82
+ # The newest Perf run of the pull request's head commit, once it's
83
+ # done (one that's running may have read the labels already).
84
+ id=$(gh run list --workflow "Perf" --event pull_request --commit "$HEAD_SHA" --limit 1 \
85
+ --json databaseId --jq '.[0].databaseId // empty')
86
+ [ -n "$id" ] || exit 0
87
+ gh run watch "$id" --interval 30 > /dev/null || true
88
+ conclusion=$(gh run view "$id" --json conclusion --jq .conclusion)
89
+ case "$ACTION:$conclusion" in
90
+ labeled:failure) gh run rerun "$id" --failed ;;
91
+ unlabeled:success) gh run rerun "$id" ;;
92
+ esac
@@ -4,39 +4,43 @@ name: Perf
4
4
  # baseline and on this code side by side, and fails if this code is slower.
5
5
  # See .duel.rb and https://github.com/sferik/duel-ruby
6
6
 
7
- # The Duel job runs this branch's code, so it only reads. Commenting is a
8
- # job of its own, which runs none of it.
7
+ # The Duel job runs this branch's code, so it only reads. Marking a push
8
+ # passed is a job of its own, which runs none of it, and commenting on a
9
+ # pull request is the Perf comment workflow's.
9
10
  permissions:
10
11
  contents: read
12
+ pull-requests: read # for the pull request's labels (see c.accept_label)
11
13
 
12
14
  on:
13
15
  pull_request:
16
+ merge_group: # (a merge queue's)
14
17
  push:
15
18
  branches:
16
- - 'main'
19
+ - 'main' # (and any other branch to guard, a stable one, say)
17
20
  schedule:
18
21
  - cron: "0 4 * * *"
19
22
  # Allow manually triggering the workflow.
20
23
  workflow_dispatch:
21
24
 
22
- # Cancels a pull request's previous runs that have not yet completed. Every
23
- # other run is a group of its own, so none is cancelled: each push to main
24
- # is compared with the commit before it, and a cancelled run would skip
25
- # that comparison.
25
+ # A pull request's newer push cancels its run, if that's still going, as
26
+ # only its newest commit's result counts. Every other run (a push's, say)
27
+ # runs to the end, so that each push is compared.
26
28
  concurrency:
27
- group: "${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}"
28
- cancel-in-progress: true
29
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.run_id }}
30
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
29
31
 
30
32
  jobs:
31
33
  duel:
32
34
  if: "github.event_name != 'push' || (!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]'))"
33
35
  name: Duel
34
36
  runs-on: ubuntu-latest
35
- # Whether the Comment job comments (post, change or none), and the
36
- # run's status (passed, failed or neutral), from Duel.
37
+ # Whether to comment (post, change or none), the run's status (passed,
38
+ # failed or neutral), and whether to mark a push passed (true, or
39
+ # nothing), from Duel.
37
40
  outputs:
38
41
  comment: ${{ steps.compare.outputs.comment }}
39
42
  status: ${{ steps.compare.outputs.status }}
43
+ passed: ${{ steps.compare.outputs.passed }}
40
44
  env: # $BUNDLE_GEMFILE must be set at job level, so it is set for all steps
41
45
  # The perf appraisal: the gemspec's dependencies and Duel (Ruby 3.4 or later)
42
46
  BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/perf.gemfile
@@ -47,25 +51,73 @@ jobs:
47
51
  fetch-depth: 0 # the baseline comes from history, tags included
48
52
  persist-credentials: false
49
53
 
54
+ # The labels of the pull request (or for a push, of the one that
55
+ # merged it), for c.accept_label in .duel.rb, as a JSON array. They're
56
+ # read as the job runs, and adding the label (or taking it off) runs
57
+ # the job again: see the Perf comment workflow.
58
+ # On a schedule, the last commit since the last release that merged a
59
+ # pull request with the label (ACCEPT_LABEL, as .duel.rb names it):
60
+ # what that slowed down was accepted, so it's compared with instead.
61
+ - name: Find the pull request's labels
62
+ id: labels
63
+ if: github.event_name == 'pull_request' || github.event_name == 'merge_group' || github.event_name == 'push' || github.event_name == 'schedule'
64
+ continue-on-error: true # (without them, nothing's accepted)
65
+ env:
66
+ GH_TOKEN: ${{ github.token }}
67
+ PR: ${{ github.event.pull_request.number }}
68
+ QUEUED: ${{ github.event.merge_group.head_ref }}
69
+ ACCEPT_LABEL: 'duel: accept'
70
+ RELEASE_TAGS: "v*"
71
+ run: |
72
+ if [ "$GITHUB_EVENT_NAME" = schedule ]; then
73
+ tag=$(git describe --tags --abbrev=0 --match "$RELEASE_TAGS" HEAD^ 2>/dev/null) || exit 0
74
+ since=$(TZ=UTC git log -1 --date=format-local:%Y-%m-%dT%H:%M:%SZ --format=%cd "$tag")
75
+ merged=$(gh pr list --repo "$GITHUB_REPOSITORY" --state merged --label "$ACCEPT_LABEL" --search "merged:>=$since" --limit 1000 \
76
+ --json mergeCommit --jq '.[].mergeCommit.oid')
77
+ accepted=$(git rev-list "$tag..HEAD" | grep -Fx -m 1 -f <(echo "$merged")) || accepted=
78
+ echo "accepted=$accepted" >> "$GITHUB_OUTPUT"
79
+ exit 0
80
+ fi
81
+ # (In a merge queue, the last pull request queued, which the queue's
82
+ # branch names: gh-readonly-queue/main/pr-123-<sha>.)
83
+ if [ -n "$QUEUED" ]; then
84
+ PR=${QUEUED##*/pr-}
85
+ PR=${PR%%-*}
86
+ fi
87
+ if [ -n "$PR" ]; then
88
+ labels=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR/labels" --jq '[.[].name]')
89
+ else
90
+ labels=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/pulls" --jq '[.[0].labels[]?.name]')
91
+ fi
92
+ echo "labels=$labels" >> "$GITHUB_OUTPUT"
93
+
50
94
  # .duel.rb sets c.ruby = :version_file, so each version runs on the Ruby
51
95
  # that its own version file names (.ruby-version, .tool-versions, or
52
96
  # mise.toml, the first that names one, as Duel reads them). When the
53
97
  # baseline's names another Ruby than this one's, install that Ruby too,
54
98
  # and link it where Duel finds it. The baseline is the one the Compare
55
- # step uses: the main branch for a pull request, the commit before a
56
- # push, the last release on a schedule (the newest v* tag before HEAD,
57
- # as Duel finds it), and where HEAD left the default branch when run by
58
- # hand.
99
+ # step uses: the branch it targets for a pull request, a merge queue's
100
+ # base, the commit before a push (or the last commit Duel passed, if
101
+ # there is one: see the Mark the commit passed job), the last release
102
+ # on a schedule (the newest v* tag before HEAD, as Duel finds it, or
103
+ # ACCEPTED, the last change accepted since then), and where HEAD left
104
+ # the default branch when run by hand.
59
105
  - name: Find the baseline's Ruby
60
106
  id: baseline
61
107
  env:
62
108
  BEFORE: ${{ github.event.before }}
109
+ QUEUE_BASE: ${{ github.event.merge_group.base_sha }}
110
+ PASSED: origin/duel/passed/${{ github.ref_name }}
63
111
  DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
112
+ ACCEPTED: ${{ steps.labels.outputs.accepted }}
64
113
  run: |
65
114
  case "$GITHUB_EVENT_NAME" in
66
115
  pull_request) base="origin/$GITHUB_BASE_REF" ;;
67
- push) base="$BEFORE" ;;
68
- schedule) base=$(git describe --tags --abbrev=0 --match 'v*' HEAD^ 2>/dev/null) || base= ;;
116
+ push)
117
+ base=$BEFORE
118
+ if git merge-base --is-ancestor "$PASSED" HEAD 2>/dev/null; then base=$PASSED; fi ;;
119
+ merge_group) base=$QUEUE_BASE ;;
120
+ schedule) base=${ACCEPTED:-$(git describe --tags --abbrev=0 --match 'v*' HEAD^ 2>/dev/null)} || base= ;;
69
121
  *) base=$(git merge-base HEAD "origin/$DEFAULT_BRANCH" 2>/dev/null) || base= ;;
70
122
  esac
71
123
  ruby_of() {
@@ -92,7 +144,7 @@ jobs:
92
144
  - name: Setup the baseline's Ruby
93
145
  id: baseline-ruby
94
146
  if: steps.baseline.outputs.ruby != ''
95
- uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
147
+ uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
96
148
  with:
97
149
  ruby-version: ${{ steps.baseline.outputs.ruby }}
98
150
  # The bundle for this Ruby too, which the baseline's workers load.
@@ -109,78 +161,109 @@ jobs:
109
161
 
110
162
  # The candidate's Ruby, from its version file (the same one Duel reads)
111
163
  - name: Setup Ruby & RubyGems
112
- uses: ruby/setup-ruby@de492cf36cbab201753d720ce4f4e336cd688c94 # v1.336.0
164
+ uses: ruby/setup-ruby@145243922b4465b78e04dd66294782c7de45901f # v1.345.0
113
165
  with:
114
166
  bundler-cache: true
115
167
 
116
- # Against the main branch for a pull request, what was there before
117
- # for a push, and the last release on a schedule (slow creep). Duel
118
- # adds its report to the job's summary, writes it to duel.md for the
119
- # comment, and sets the step's outputs to say whether to comment, as
120
- # c.comment in .duel.rb says, whatever the outcome.
168
+ # Against the branch it targets for a pull request, the queue's base
169
+ # for a merge queue, what was there before for a push (or as
170
+ # c.push_base in .duel.rb says, the last commit Duel passed), and the
171
+ # last release on a schedule (slow creep). Duel adds its report to
172
+ # the job's summary, writes it to duel.md for the comment, and sets
173
+ # the step's outputs to say whether to comment, as c.comment in
174
+ # .duel.rb says, whatever the outcome.
121
175
  - name: Compare
122
176
  id: compare
123
177
  env:
124
- DUEL_BASE: ${{ github.event_name == 'schedule' && 'last-release' || github.event_name == 'push' && github.event.before || '' }}
178
+ 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 || '' }}
125
179
  # (Run by hand, it compares anyway: with nothing changed, the code
126
180
  # with itself, which checks the setup.)
127
181
  DUEL_FORCE: ${{ github.event_name == 'workflow_dispatch' && '1' || '' }}
182
+ DUEL_LABELS: ${{ steps.labels.outputs.labels }}
183
+ DUEL_ACCEPTED: ${{ steps.labels.outputs.accepted }}
184
+ run: bundle exec duel --markdown "$RUNNER_TEMP/duel/duel.md"
185
+
186
+ # For a pull request, what Duel said, for the Perf comment workflow,
187
+ # which can't see this job's outputs.
188
+ - name: Say whether to comment
189
+ if: ${{ !cancelled() && github.event_name == 'pull_request' }}
190
+ env:
191
+ PR: ${{ github.event.pull_request.number }}
192
+ COMMENT: ${{ steps.compare.outputs.comment }}
193
+ STATUS: ${{ steps.compare.outputs.status }}
128
194
  run: |
129
- # (A branch's first push, or one that rewrote history, has no
130
- # commit before it here to compare against.)
131
- if [ "$GITHUB_EVENT_NAME" = push ] && ! git cat-file -e "$DUEL_BASE^{commit}" 2>/dev/null; then
132
- echo "::notice::No commit before this push to compare against"
133
- exit 0
134
- fi
135
- bundle exec duel --markdown "$RUNNER_TEMP/duel.md"
195
+ mkdir -p "$RUNNER_TEMP/duel"
196
+ printf 'pr=%s\ncomment=%s\nstatus=%s\n' "$PR" "$COMMENT" "$STATUS" > "$RUNNER_TEMP/duel/comment.env"
136
197
 
137
- # The report, for the Comment job
198
+ # The report, for the comments
138
199
  - name: Keep the report
139
- if: ${{ !cancelled() && github.event_name == 'pull_request' }}
200
+ if: ${{ !cancelled() && (github.event_name == 'pull_request' || github.event_name == 'push') }}
140
201
  uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
141
202
  with:
142
203
  name: duel-report
143
- path: ${{ runner.temp }}/duel.md
144
- if-no-files-found: ignore # none when the comparison didn't run
204
+ path: ${{ runner.temp }}/duel/
205
+ if-no-files-found: ignore # none when Duel didn't get to compare
145
206
  retention-days: 1
146
207
 
147
- # The report, as a new comment on the pull request, when Duel says to:
148
- # always (post), or only when its last comment's status differs from
149
- # this run's (change), so the latest comment is never stale. It never
150
- # edits or deletes a comment. This job checks nothing out and runs none
151
- # of the branch's code, so it alone can write. (A pull request from a
152
- # fork gets no comment, as its token can't write one: the Duel job's
153
- # summary has the report.)
154
- comment:
155
- name: Comment
208
+ # With c.push_base = :last_passed in .duel.rb, a push is compared with
209
+ # the last commit Duel passed, which a branch marks (each branch pushed
210
+ # has its own), so slowdowns too small for any one push to fail add up
211
+ # until they fail one. This job moves the branch to a push that passed
212
+ # (or makes it), but never back: where a newer push's run moved it
213
+ # first, it stays. It checks nothing out and runs none of the code. To
214
+ # accept a regression, move the branch yourself (for main, git push
215
+ # origin main:duel/passed/main).
216
+ passed:
217
+ name: Mark the commit passed
156
218
  needs: duel
157
- if: ${{ !cancelled() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && (needs.duel.outputs.comment == 'post' || needs.duel.outputs.comment == 'change') }}
219
+ # One at a time for each branch, so that two runs can't both find no
220
+ # branch and race to make it (a push's run doesn't wait for the one
221
+ # before it). One that's running is never cancelled, and one that's
222
+ # waiting gives way to a newer push's, which moves it further anyway.
223
+ concurrency:
224
+ group: ${{ github.workflow }}-passed-${{ github.ref_name }}
225
+ cancel-in-progress: false
226
+ if: ${{ !cancelled() && github.event_name == 'push' && needs.duel.outputs.passed == 'true' }}
158
227
  runs-on: ubuntu-latest
159
228
  permissions:
160
- pull-requests: write # to comment on the pull request with the report
229
+ contents: write # to move the branch
161
230
  steps:
162
- - name: Get the report
163
- id: report
164
- continue-on-error: true # the Duel job keeps no report when it fails before comparing
165
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
166
- with:
167
- name: duel-report
168
- path: ${{ runner.temp }}/report
169
-
170
- - name: Comment on the pull request
171
- if: steps.report.outcome == 'success'
231
+ - name: Move the branch to the commit
172
232
  env:
173
233
  GH_TOKEN: ${{ github.token }}
174
- PR: ${{ github.event.pull_request.number }}
175
- COMMENT: ${{ needs.duel.outputs.comment }}
176
- STATUS: ${{ needs.duel.outputs.status }}
234
+ BRANCH: duel/passed/${{ github.ref_name }}
177
235
  run: |
178
- marker="<!-- duel"
179
- # The first line of the last comment Duel posted here: its marker,
180
- # with its status (none in Duel 0.1.0's, which counts as another).
181
- last=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR/comments" \
182
- --jq ".[] | select(.user.login == \"github-actions[bot]\") | .body | split(\"\n\")[0] | rtrimstr(\"\r\") | select(startswith(\"$marker status=\") or . == \"$marker -->\")" | tail -n 1)
183
- if [ "$COMMENT" = post ] || { [ -n "$last" ] && [ "$last" != "$marker status=$STATUS -->" ]; }; then
184
- { echo "$marker status=$STATUS -->"; cat "$RUNNER_TEMP/report/duel.md"; } > "$RUNNER_TEMP/comment.md"
185
- gh api --method POST "repos/$GITHUB_REPOSITORY/issues/$PR/comments" -F body=@"$RUNNER_TEMP/comment.md" > /dev/null
186
- fi
236
+ # (Git can't make a branch where another's name is a folder of its
237
+ # name: a branch named duel blocks duel/passed/main. If one does,
238
+ # this names it.)
239
+ blocked() {
240
+ prefix=$BRANCH
241
+ while [ "${prefix%/*}" != "$prefix" ]; do
242
+ prefix=${prefix%/*}
243
+ if gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$prefix" > /dev/null 2>&1; then
244
+ 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."
245
+ fi
246
+ done
247
+ exit 1
248
+ }
249
+ # (Forward: GitHub moves it only where it's behind the push. Where
250
+ # there's no branch, and making it fails, it looks once more, as
251
+ # something else may have made it: a push of it, say.)
252
+ for _ in 1 2; do
253
+ gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null 2>&1 && exit 0
254
+ at=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/$BRANCH" --jq .object.sha 2>/dev/null) || at=
255
+ [ -n "$at" ] && break
256
+ gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/heads/$BRANCH" -f sha="$GITHUB_SHA" > /dev/null && exit 0
257
+ done
258
+ [ -n "$at" ] || blocked
259
+ compared=$(gh api "repos/$GITHUB_REPOSITORY/compare/$GITHUB_SHA...$at" --jq .status 2>&1) || case "$compared" in
260
+ # (GitHub can't compare commits with no history in common.)
261
+ *"No common ancestor"*) compared=unrelated ;;
262
+ esac
263
+ case "$compared" in
264
+ # (A newer push's run moved it, or this one's did, run again.)
265
+ ahead | identical) ;;
266
+ # (History rewritten, a force push's, say, or replaced: moved anyway.)
267
+ diverged | behind | unrelated) gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/$BRANCH" -f sha="$GITHUB_SHA" -F force=true > /dev/null ;;
268
+ *) echo "::error::Couldn't compare $BRANCH with this push: $compared" && exit 1 ;;
269
+ esac
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}
@@ -53,7 +53,7 @@ jobs:
53
53
  persist-credentials: false
54
54
 
55
55
  - name: Setup Ruby & RubyGems
56
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
56
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
57
57
  with:
58
58
  ruby-version: ${{ matrix.ruby }}
59
59
  rubygems: ${{ matrix.rubygems }}
@@ -53,7 +53,7 @@ jobs:
53
53
  persist-credentials: false
54
54
 
55
55
  - name: Setup Ruby & RubyGems
56
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
56
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
57
57
  with:
58
58
  ruby-version: ${{ matrix.ruby }}
59
59
  rubygems: ${{ matrix.rubygems }}
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}
@@ -50,7 +50,7 @@ jobs:
50
50
  persist-credentials: false
51
51
 
52
52
  - name: Setup Ruby & RubyGems
53
- uses: appraisal-rb/setup-ruby-flash@6f8ad36ba7488db591541483afb5464d01e8861b # v2.14 compatibility bundle installation
53
+ uses: appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15 compatibility bundle installation
54
54
  with:
55
55
  ruby-version: ${{ matrix.ruby }}
56
56
  rubygems: ${{ matrix.rubygems }}