patches 3.6.2 → 3.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ef48f4cd04fd29602ab012fab6414c16cece6fa3ecd687f9deac3ff9244bf7b
4
- data.tar.gz: f89c55aa18e9f84e77e5a26872896df6b5b0819842e940976b262a5b20e55dda
3
+ metadata.gz: 7eea93b86dd926979c0b3cf0fcf292711d7ce1cb6256950458eed354a4783749
4
+ data.tar.gz: f3305c8346f6d2b5d657de8c25b69ed820ff8149dca2fb5724204d77a9cda5f4
5
5
  SHA512:
6
- metadata.gz: 5899f3e9202d2227efd661d38771eef7534ac48414903b1fbd66820631ccf8dd90dcb20b2bc9f8bfbca81375388fe531acacab6dc294c92a621804083fd0b93b
7
- data.tar.gz: 59707c3bb9d64ad45971fa7ef2287c346aa72fe6bcb393ed027ddd47ca6202feff2034b5ec30c1a32e5d39041ba4fe2bb2d1ee6ca625aabc58d87978f7e9e7c6
6
+ metadata.gz: 52fa0f3c8458a92cc8e4fa9e8ec65856943ab06148bec02c706175699dcb2d5042b71699039c14461e272fe0e8bfcdf2cda4eb68639f3100fd75fb9cd8539224
7
+ data.tar.gz: c4548f2c1d92fd32648062443e5c156838c9b02c3b4e02d755b376a9583adc59bf8c3df3bb707494b4d1605660403ed00b56e2835eef0996f9275fc54d28183a
@@ -0,0 +1,35 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: write # rake release (via rubygems/release-gem) pushes the tag; no-op here since it's already pushed
9
+ id-token: write # RubyGems.org OIDC trusted publishing
10
+ packages: write # GitHub Packages push
11
+
12
+ jobs:
13
+ release:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v5
17
+ with:
18
+ fetch-depth: 0
19
+ persist-credentials: false
20
+
21
+ - name: Verify tag is reachable from develop
22
+ run: |
23
+ if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/develop; then
24
+ echo "::error::$GITHUB_REF_NAME is not reachable from develop. Refusing to publish."
25
+ exit 1
26
+ fi
27
+
28
+ - name: Set up Ruby
29
+ uses: ruby/setup-ruby@v1
30
+ with:
31
+ bundler-cache: true
32
+ ruby-version: "3.4"
33
+
34
+ - name: Publish to RubyGems.org
35
+ uses: rubygems/release-gem@v1
@@ -0,0 +1,113 @@
1
+ name: Run specs
2
+ on:
3
+ workflow_dispatch:
4
+ pull_request:
5
+ branches:
6
+ - develop
7
+ push:
8
+ branches:
9
+ - develop
10
+
11
+ jobs:
12
+ # This patch release changes no version constraint, so the matrix records the
13
+ # range the gem is verified against rather than narrowing what it allows -
14
+ # older Ruby and Rails remain permitted, just untested. Rails 6.1/7.0 and
15
+ # Ruby 2.7 are left out deliberately: they are long past upstream support,
16
+ # and they were the cells that needed harness pins (Rails <= 7.0 pins its
17
+ # sqlite3 adapter to `~> 1.4`, Rails < 7.1 predates concurrent-ruby 1.3.5
18
+ # dropping a Logger constant) or a pinned runner image. The Gemfile still
19
+ # accepts those overrides for reproducing an old combination locally.
20
+ specs:
21
+ name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }}
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ fail-fast: false
25
+ matrix:
26
+ include:
27
+ - { ruby: '3.0', rails: '~> 7.1.0' }
28
+ - { ruby: '3.1', rails: '~> 7.1.0' }
29
+ - { ruby: '3.1', rails: '~> 7.2.0' }
30
+ - { ruby: '3.2', rails: '~> 7.1.0' }
31
+ - { ruby: '3.2', rails: '~> 7.2.0' }
32
+ - { ruby: '3.2', rails: '~> 8.0.0' }
33
+ - { ruby: '3.2', rails: '~> 8.1.0' }
34
+ - { ruby: '3.3', rails: '~> 7.1.0' }
35
+ - { ruby: '3.3', rails: '~> 7.2.0' }
36
+ - { ruby: '3.3', rails: '~> 8.0.0' }
37
+ - { ruby: '3.3', rails: '~> 8.1.0' }
38
+ - { ruby: '3.4', rails: '~> 7.2.0' }
39
+ - { ruby: '3.4', rails: '~> 8.0.0' }
40
+ - { ruby: '3.4', rails: '~> 8.1.0' }
41
+ - { ruby: '4.0', rails: '~> 7.2.0' }
42
+ - { ruby: '4.0', rails: '~> 8.0.0' }
43
+ - { ruby: '4.0', rails: '~> 8.1.0' }
44
+ env:
45
+ RAILS_VERSION: ${{ matrix.rails }}
46
+ steps:
47
+ - uses: actions/checkout@v4
48
+ - uses: ruby/setup-ruby@v1
49
+ with:
50
+ ruby-version: ${{ matrix.ruby }}
51
+ bundler-cache: true
52
+ - name: Run specs
53
+ run: bundle exec rspec
54
+
55
+ # Sidekiq is optional, so it gets its own axis rather than multiplying the
56
+ # matrix above. All three states a consumer can be in are covered: absent,
57
+ # present with strict argument checking (the Sidekiq 7+ default), and present
58
+ # with it disabled. The 6.5 leg covers the Sidekiq::Worker-era fallback path.
59
+ sidekiq:
60
+ name: Sidekiq ${{ matrix.sidekiq }} (strict args ${{ matrix.strict_args || 'absent' }})
61
+ runs-on: ubuntu-latest
62
+ strategy:
63
+ fail-fast: false
64
+ matrix:
65
+ include:
66
+ - { sidekiq: '~> 6.5' }
67
+ - { sidekiq: '~> 7.0', strict_args: 'raise' }
68
+ - { sidekiq: '~> 7.0', strict_args: 'false' }
69
+ - { sidekiq: '~> 8.0', strict_args: 'raise' }
70
+ - { sidekiq: '~> 8.0', strict_args: 'false' }
71
+ - { sidekiq: 'none' }
72
+ env:
73
+ SIDEKIQ_VERSION: ${{ matrix.sidekiq }}
74
+ SIDEKIQ_STRICT_ARGS: ${{ matrix.strict_args }}
75
+ steps:
76
+ - uses: actions/checkout@v4
77
+ - uses: ruby/setup-ruby@v1
78
+ with:
79
+ ruby-version: '3.4'
80
+ bundler-cache: true
81
+ - name: Run specs
82
+ run: |
83
+ if [ "$SIDEKIQ_VERSION" = "none" ]; then
84
+ bundle exec rspec --exclude-pattern "sidekiq/**/*_spec.rb"
85
+ else
86
+ bundle exec rspec
87
+ fi
88
+
89
+ sonarqube:
90
+ name: SonarQube
91
+ runs-on: ubuntu-latest
92
+ steps:
93
+ - uses: actions/checkout@v4
94
+ - uses: ruby/setup-ruby@v1
95
+ with:
96
+ ruby-version: '3.2'
97
+ bundler-cache: true
98
+ - name: Run specs
99
+ run: bundle exec rspec
100
+
101
+ - name: SonarQube Scan
102
+ uses: sonarsource/sonarqube-scan-action@master
103
+ with:
104
+ args: >
105
+ -Dsonar.projectKey=rdytech_patches_4fe7fcf4-bbfc-4b19-be78-87e73d1f301e
106
+ -Dsonar.host.url=https://sonarqube.readytech.io
107
+ -Dsonar.sources=lib/
108
+ -Dsonar.inclusions=**/*.rb
109
+ -Dsonar.tests=spec/
110
+ -Dsonar.ruby.coverage.reportPaths=coverage/.resultset.json
111
+ -Dsonar.plugins.downloadOnlyRequired=true
112
+ env:
113
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
data/CHANGELOG.md CHANGED
@@ -6,6 +6,79 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ Converted to GitHub Actions for CI
10
+
11
+ ## [3.6.3] - 2026-09-09
12
+
13
+ Bug fixes only. No version constraint changes, no API changes and nothing
14
+ removed from the public interface, so anything that installed 3.6.2 installs
15
+ this. First step of a staged modernisation: declaring dependencies and adding
16
+ deprecations comes in 3.7.0, raising minimums in 4.0.0.
17
+
18
+ ### Fixed
19
+ - Sidekiq 7 and 8 compatibility. Strict argument checking, enabled by default
20
+ from Sidekiq 7, rejected the job arguments the workers enqueued:
21
+ `patches:run` passed the runner class object itself and `application_version`
22
+ used a symbol key, so enqueueing raised `ArgumentError: Job arguments to
23
+ Patches::Worker must be native JSON types`. The task now enqueues the runner
24
+ class name and the key is a string. The serialised payload is byte-identical
25
+ to 3.6.2's - the class already reached Redis as `"Patches::Runner"` and the
26
+ symbol key as `"application_version"` - so in-flight jobs and rolling deploys
27
+ that mix old and new workers are unaffected
28
+ - The install migration inherited from a bare `ActiveRecord::Migration`, which
29
+ Rails has refused since 5.0 with "Directly inheriting from
30
+ ActiveRecord::Migration is not supported", so
31
+ `rake patches:install:migrations && rake db:migrate` failed on every Rails
32
+ since. It now declares `ActiveRecord::Migration[5.0]`, which Rails still
33
+ supports through 8.1, so no minimum moves
34
+ - `Patches.default_path` guarded on `defined?(:Rails)`, which tests a symbol
35
+ literal and is always true; outside Rails it raised `NameError` instead of
36
+ returning nil
37
+
38
+ ### Added
39
+ - Specs for the install migration, which shipped with no coverage at all, and
40
+ for `Patches.sidekiq_job_module`, including its `Sidekiq::Worker` fallback
41
+ - A release workflow and `RELEASING.md`, both matching rdytech/superset-client:
42
+ pushing a `v`-prefixed tag publishes to RubyGems through trusted publishing,
43
+ and a tag not reachable from `develop` is refused. It also waits for the
44
+ version to appear on RubyGems, so a release that does not land fails loudly -
45
+ `3.6.1` was tagged and released on GitHub but never published, and nothing
46
+ reported it
47
+ - CI now runs 17 Ruby/Rails combinations (Ruby 3.0-4.0 against Rails 7.1-8.1)
48
+ in place of a single Ruby 2.7 cell, plus a leg for each Sidekiq state:
49
+ absent, 6.5, and 7.x/8.x with strict arguments both on and off. Ruby 2.7 and
50
+ Rails 6.1/7.0 are not exercised, being well past upstream support; they are
51
+ untested rather than blocked, since no constraint changed. README.md records
52
+ the verified range and how to check an older combination locally
53
+
54
+ ### Changed
55
+ - The workers resolve their mixin through `Patches.sidekiq_job_module`, which
56
+ prefers `Sidekiq::Job` (Sidekiq 6.3+) and falls back to `Sidekiq::Worker`, so
57
+ no Sidekiq version loses support
58
+ - Development dependencies pruned to those actually used: `capybara`,
59
+ `factory_girl`, `timecop`, `generator_spec`, `byebug` and `database_cleaner`
60
+ were referenced by no spec, and `rspec-rails` was never required, so plain
61
+ `rspec` replaces it. `rails`, `sqlite3`, `sidekiq` and `concurrent-ruby` moved
62
+ to the Gemfile so CI can vary them; the stale `sidekiq ~> 3.4.1` pin is what
63
+ hid the strict argument incompatibility, and it also held `json` at `~> 1.0`
64
+ - Sidekiq-dependent specs moved under `spec/sidekiq/` so the suite runs with the
65
+ gem absent
66
+
67
+ ### Known issues
68
+ - The install migration now declares `ActiveRecord::Migration[5.0]`, and
69
+ `ActiveRecord::Migration.[]` does not exist before Rails 5.0. A *fresh*
70
+ install on Rails 4.2 or earlier therefore needs `patches_patches` created by
71
+ hand - the table it wants is a `path` string, timestamps, and a unique index
72
+ on `path`. Existing installs are unaffected, having already copied the
73
+ migration into the host application. Those versions are far outside the range
74
+ CI verifies, and the previous file could not be loaded by any Rails from 5.0
75
+ on, so this trades an impossible install for an unlikely one
76
+
77
+ ### Removed
78
+ - `lib/generators/patches.rb`, a dead duplicate of the patch generator that
79
+ wrote to `app/db/` from a template (`patch.erb`) that does not exist. Not
80
+ reachable through Rails' generator lookup, so not part of the public interface
81
+
9
82
  ## [3.6.2] - 2022-08-10
10
83
 
11
84
  Fixes incorrect release - tag and published gem back in sync
data/Gemfile CHANGED
@@ -2,4 +2,38 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "~> 4.1"
5
+ # rails, sqlite3, concurrent-ruby and sidekiq are declared here rather than in
6
+ # the gemspec so that CI can vary them across the support matrix in README.md.
7
+ # Reproduce any CI cell locally by setting the same variables:
8
+ #
9
+ # RAILS_VERSION="~> 7.0.0" SQLITE3_VERSION="~> 1.4" bundle install
10
+ # bundle exec rspec
11
+ #
12
+ # An unset *or empty* value falls back to the default, because GitHub Actions
13
+ # passes an empty string for matrix keys a given cell doesn't define.
14
+ def version_requirement(name, default = nil)
15
+ value = ENV.fetch(name, '').strip
16
+ value.empty? ? default : value
17
+ end
18
+
19
+ # Unset, this resolves to the newest Rails the running Ruby allows. The gemspec
20
+ # floor stays at railties >= 3.2; see Compatibility in README.md for the range
21
+ # CI verifies.
22
+ gem 'rails', version_requirement('RAILS_VERSION', '>= 7.1')
23
+
24
+ # Rails pins its sqlite3 adapter: <= 7.0 needs `~> 1.4`, 7.1 accepts either,
25
+ # 8.0+ needs `>= 2.1`. Unset, bundler picks the newest 2.x.
26
+ gem 'sqlite3', version_requirement('SQLITE3_VERSION', '>= 1.4')
27
+
28
+ # Rails < 7.1 predates concurrent-ruby 1.3.5 removing the Logger constant that
29
+ # ActiveSupport::LoggerThreadSafeLevel expects.
30
+ concurrent_ruby = version_requirement('CONCURRENT_RUBY_VERSION')
31
+ gem 'concurrent-ruby', concurrent_ruby if concurrent_ruby
32
+
33
+ # Sidekiq is an optional integration, not a runtime dependency. SIDEKIQ_VERSION
34
+ # =none leaves it out entirely so the `defined?(Sidekiq)` guards get exercised.
35
+ # The library itself still supports older Sidekiq through
36
+ # Patches.sidekiq_job_module; this default only picks what the suite runs
37
+ # against by default.
38
+ sidekiq = version_requirement('SIDEKIQ_VERSION')
39
+ gem 'sidekiq', *[sidekiq].compact unless sidekiq == 'none'
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 JobReady
1
+ Copyright (c) 2015 ReadyTech
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Patches
2
- [![Build status](https://badge.buildkite.com/4f3df3f3458bcc933dc44cab6c136af5c3bbdd9f761f1a99ff.svg)](https://buildkite.com/jobready/patches)
2
+ [![Run specs](https://github.com/rdytech/patches/actions/workflows/specs.yml/badge.svg)](https://github.com/rdytech/patches/actions/workflows/specs.yml)
3
3
  [![Maintainability](https://api.codeclimate.com/v1/badges/39d142050017ffeb2564/maintainability)](https://codeclimate.com/repos/557f93b76956807f81000001/maintainability)
4
4
  [![Test Coverage](https://api.codeclimate.com/v1/badges/39d142050017ffeb2564/test_coverage)](https://codeclimate.com/repos/557f93b76956807f81000001/test_coverage)
5
5
  [![Gem Version](https://badge.fury.io/rb/patches.svg)](https://badge.fury.io/rb/patches)
@@ -15,6 +15,98 @@ Please note the breaking change release around deployment. See [docs/usage.md](d
15
15
 
16
16
  TL;DR You need to manually declare the patches task to run in your deploy.rb
17
17
 
18
+ ## Compatibility
19
+
20
+ This release changes no version constraint: the gemspec still requires only
21
+ `railties >= 3.2` and sets no Ruby floor, so anything that installed 3.6.2
22
+ installs 3.6.3. The table is what CI verifies, which is narrower than what the
23
+ gem permits - older Ruby and Rails are untested here, not blocked.
24
+
25
+ | | Rails 7.1 | Rails 7.2 | Rails 8.0 | Rails 8.1 |
26
+ |---|---|---|---|---|
27
+ | **Ruby 3.0** | ✅ | | | |
28
+ | **Ruby 3.1** | ✅ | ✅ | | |
29
+ | **Ruby 3.2** | ✅ | ✅ | ✅ | ✅ |
30
+ | **Ruby 3.3** | ✅ | ✅ | ✅ | ✅ |
31
+ | **Ruby 3.4** | | ✅ | ✅ | ✅ |
32
+ | **Ruby 4.0** | | ✅ | ✅ | ✅ |
33
+
34
+ A blank cell is a pairing Rails itself does not support. Ruby 2.7 and Rails
35
+ 6.1/7.0 are deliberately not exercised - they are well past upstream support -
36
+ though the gem still installs and, as of this release, passes on them.
37
+
38
+ Ruby 4.0 is newer than all of these Rails releases, so those cells record that
39
+ Patches is verified on it, not that Rails claims support for it.
40
+
41
+ ### Sidekiq
42
+
43
+ Sidekiq is an **optional** integration, not a runtime dependency: Patches runs
44
+ each patch inline when Sidekiq is absent. Set `config.use_sidekiq = true` to run
45
+ them in the background - see [docs/usage.md](docs/usage.md).
46
+
47
+ The workers resolve their mixin at load time via `Patches.sidekiq_job_module`,
48
+ preferring `Sidekiq::Job` (the name Sidekiq has used since 6.3) and falling back
49
+ to `Sidekiq::Worker`, so older Sidekiq keeps working. CI covers each state a
50
+ consumer can be in:
51
+
52
+ | State | Covered by |
53
+ |---|---|
54
+ | Sidekiq not installed | A leg omitting the gem entirely, exercising the `defined?(Sidekiq)` guards |
55
+ | Installed, strict arguments on | Sidekiq 7.x and 8.x at their default (`:raise`) |
56
+ | Installed, strict arguments off | Sidekiq 7.x and 8.x with `Sidekiq.strict_args!(false)` |
57
+ | Older Sidekiq | A 6.5 leg, plus a spec covering the `Sidekiq::Worker` fallback |
58
+
59
+ ### Running one combination locally
60
+
61
+ The Gemfile reads the same variables CI sets, so any cell above is reproducible.
62
+ Bundler re-evaluates the Gemfile on every invocation, so **export** them rather
63
+ than prefixing a single command — otherwise `bundle exec` silently resolves the
64
+ defaults and you test something other than what you intended:
65
+
66
+ ```
67
+ export RAILS_VERSION="~> 8.0.0"
68
+
69
+ bundle install
70
+ bundle exec rspec
71
+ ```
72
+
73
+ Without Sidekiq at all, which is what a consumer that does not use it gets:
74
+
75
+ ```
76
+ export SIDEKIQ_VERSION=none
77
+
78
+ bundle install
79
+ bundle exec rspec --exclude-pattern "sidekiq/**/*_spec.rb"
80
+ ```
81
+
82
+ With Sidekiq 7 and strict argument checking turned off:
83
+
84
+ ```
85
+ export SIDEKIQ_VERSION="~> 7.0" SIDEKIQ_STRICT_ARGS=false
86
+
87
+ bundle install
88
+ bundle exec rspec
89
+ ```
90
+
91
+ Rails 6.1 and 7.0 need two extra pins if you do want to check them, neither
92
+ caused by Patches — Rails <= 7.0 pins its sqlite3 adapter to `~> 1.4`, and Rails
93
+ < 7.1 predates `concurrent-ruby` 1.3.5 removing a `Logger` constant it relies
94
+ on:
95
+
96
+ ```
97
+ export RAILS_VERSION="~> 6.1.0" \
98
+ SQLITE3_VERSION="~> 1.4" \
99
+ CONCURRENT_RUBY_VERSION="< 1.3.5"
100
+
101
+ bundle install
102
+ bundle exec rspec
103
+ ```
104
+
105
+ `unset` the variables (or use a fresh shell) before running the default
106
+ combination again, and delete `test.db` when switching between them: the suite
107
+ creates `patches_patches` only when it is missing, so a database left by an
108
+ earlier run can mask ordering problems.
109
+
18
110
  ## Installation
19
111
 
20
112
  Add this line to your application's Gemfile:
@@ -41,11 +133,16 @@ docker-compose build
41
133
  docker-compose run app bundle exec rspec
42
134
  ```
43
135
 
44
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/patches).
136
+ To install this gem onto your local machine, run `bundle exec rake install`.
137
+
138
+ ## Releasing
139
+
140
+ Releases are published by GitHub Actions from a `vX.Y.Z` tag — see
141
+ [RELEASING.md](RELEASING.md).
45
142
 
46
143
  ## Contributing
47
144
 
48
- 1. Fork it ( https://github.com/jobready/patches/fork )
145
+ 1. Fork it ( https://github.com/rdytech/patches/fork )
49
146
  2. Create your feature branch (`git checkout -b feature/my-feature-name`)
50
147
  3. Commit your changes (`git commit -am 'Add some feature'`)
51
148
  4. Push to the branch (`git push origin feature/my-new-feature`)
data/RELEASING.md ADDED
@@ -0,0 +1,50 @@
1
+ # Releasing patches
2
+
3
+ Publishing is only ever done by GitHub Actions (`.github/workflows/release.yml`), triggered by
4
+ a `vX.Y.Z` tag whose commit is reachable from `develop`. Tags on any other branch are rejected by
5
+ the workflow before anything is built. No one needs local publishing credentials — the workflow
6
+ authenticates to RubyGems.org via OIDC trusted publishing.
7
+
8
+ The `v` prefix is required: the workflow triggers on `v*`, and it is the tag `rake release`
9
+ creates. RubyGems.org strips it, so `v3.6.3` publishes version `3.6.3` — which is why the
10
+ versions listed on rubygems.org never carry the prefix.
11
+
12
+ ## Cutting a release
13
+
14
+ 1. Bump `MAJOR` / `MINOR` / `PATCH` in `lib/patches/version.rb`.
15
+ 2. Add a new `## [X.Y.Z] - YYYY-MM-DD` entry to the top of `CHANGELOG.md` describing the changes.
16
+ 3. Commit both changes and get them onto `develop` (PR + merge, as normal).
17
+ 4. From an up-to-date `develop`, tag the commit and push the tag:
18
+
19
+ ```bash
20
+ git tag vX.Y.Z
21
+ git push origin vX.Y.Z
22
+ ```
23
+
24
+ 5. Watch the "Release" workflow run in the Actions tab.
25
+ 6. Confirm the new version shows up on [rubygems.org](https://rubygems.org/gems/patches).
26
+
27
+ Do **not** run `bundle exec rake release` from a workstation. It would push the gem under your own
28
+ credentials *and* push the tag, and the workflow's own `rake release` would then fail because the
29
+ version already exists.
30
+
31
+ ## One-time setup
32
+
33
+ - **RubyGems.org**: an existing owner of the `patches` gem must add a Trusted Publisher for
34
+ `rdytech/patches`, workflow `release.yml` (no environment). See
35
+ [Trusted Publishing: adding a publisher](https://guides.rubygems.org/trusted-publishing/adding-a-publisher/).
36
+ Until this is done, the release will fail while configuring credentials. The gem currently lists
37
+ a single owner, handle `jr`.
38
+ - **GitHub Packages**: the workflow carries a `packages: write` permission, inherited from the
39
+ shared workflow, but no step publishes there and nothing is pushed to it.
40
+
41
+ ## Why this exists
42
+
43
+ Six tagged versions never reached RubyGems.org — `2.0.1`, `2.1.0`, `2.2.0`, `2.3.0`, `3.0.0` and
44
+ `3.6.1` — and nothing reported the gap. The `3.6.2` entry in `CHANGELOG.md` ("Fixes incorrect
45
+ release - tag and published gem back in sync") is the visible trace of the most recent one:
46
+ `3.6.1` was tagged and released on GitHub but never published, because
47
+ `.github/workflows/publish.yml` was added the same day and has never run.
48
+
49
+ `rubygems/release-gem` waits for the new version to appear on RubyGems.org before the job
50
+ succeeds, so a release that does not land now fails loudly instead of passing unnoticed.
@@ -1,4 +1,4 @@
1
- class CreatePatch < ActiveRecord::Migration
1
+ class CreatePatch < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :patches_patches do |t|
4
4
  t.string :path, null: false
@@ -0,0 +1,11 @@
1
+ require 'sidekiq'
2
+
3
+ module Patches
4
+ # Sidekiq renamed Sidekiq::Worker to Sidekiq::Job in 6.3 and still ships the
5
+ # old name as a deprecated alias. Resolving it at include time keeps the
6
+ # workers working on every Sidekiq this gem has ever supported, so the change
7
+ # needs no version bump from consumers.
8
+ def self.sidekiq_job_module
9
+ defined?(::Sidekiq::Job) ? ::Sidekiq::Job : ::Sidekiq::Worker
10
+ end
11
+ end
@@ -13,8 +13,10 @@ class Patches::TenantRunner
13
13
  if parallel?
14
14
  Patches::TenantWorker.perform_async(
15
15
  tenant,
16
- path,
17
- application_version: Patches::Config.configuration.application_version
16
+ # Sidekiq 7+ rejects anything that is not a native JSON type, and a
17
+ # path is commonly a Pathname (Patches.default_path returns one).
18
+ path && path.to_s,
19
+ 'application_version' => Patches::Config.configuration.application_version
18
20
  )
19
21
  else
20
22
  run(tenant, path)
@@ -1,13 +1,15 @@
1
- require 'sidekiq'
1
+ require 'active_support/core_ext/hash/keys'
2
+ require 'patches/sidekiq_job'
2
3
 
3
4
  class Patches::TenantWorker
4
- include Sidekiq::Worker
5
+ include Patches.sidekiq_job_module
5
6
  include Patches::TenantRunConcern
6
7
  include Patches::ApplicationVersionValidation
7
8
 
8
9
  sidekiq_options Patches::Config.configuration.sidekiq_options
9
10
 
10
11
  def perform(tenant_name, path, params = {})
12
+ params = (params || {}).stringify_keys
11
13
  if valid_application_version?(params['application_version'])
12
14
  run(tenant_name, path)
13
15
  else
@@ -1,6 +1,6 @@
1
1
  module Patches
2
2
  MAJOR = 3
3
3
  MINOR = 6
4
- PATCH = 2
4
+ PATCH = 3
5
5
  VERSION = [MAJOR, MINOR, PATCH].compact.join(".").freeze
6
6
  end
@@ -1,12 +1,14 @@
1
- require 'sidekiq'
1
+ require 'active_support/core_ext/hash/keys'
2
+ require 'patches/sidekiq_job'
2
3
 
3
4
  class Patches::Worker
4
- include Sidekiq::Worker
5
+ include Patches.sidekiq_job_module
5
6
  include Patches::ApplicationVersionValidation
6
7
 
7
8
  sidekiq_options Patches::Config.configuration.sidekiq_options
8
9
 
9
10
  def perform(runner, params = {})
11
+ params = (params || {}).stringify_keys
10
12
  if valid_application_version?(params['application_version'])
11
13
  runner.constantize.new.perform
12
14
  else
data/lib/patches.rb CHANGED
@@ -2,7 +2,7 @@ require "patches/version"
2
2
 
3
3
  module Patches
4
4
  def self.default_path
5
- Rails.root.join('db/patches/') if defined?(:Rails)
5
+ Rails.root.join('db/patches/') if defined?(Rails)
6
6
  end
7
7
 
8
8
  def self.class_name(path)
@@ -23,6 +23,7 @@ require "patches/base"
23
23
  require "patches/config"
24
24
  require "patches/tenant_run_concern"
25
25
  require "patches/application_version_validation"
26
+ require "patches/sidekiq_job" if defined?(Sidekiq)
26
27
  require "patches/tenant_worker" if defined?(Sidekiq)
27
28
  require "patches/engine" if defined?(Rails)
28
29
  require "patches/patch"
@@ -9,8 +9,8 @@ namespace :patches do
9
9
 
10
10
  if defined?(Sidekiq) && Patches::Config.configuration.use_sidekiq
11
11
  Patches::Worker.perform_async(
12
- runner,
13
- application_version: Patches::Config.configuration.application_version
12
+ runner.name,
13
+ 'application_version' => Patches::Config.configuration.application_version
14
14
  )
15
15
  else
16
16
  runner.new.perform
data/patches.gemspec CHANGED
@@ -6,34 +6,38 @@ require 'patches/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "patches"
8
8
  spec.version = Patches::VERSION
9
- spec.authors = ["JobReady"]
10
- spec.email = ["ruby_gems@jobready.com.au"]
9
+ spec.authors = ["ReadyTech"]
10
+ spec.email = ["ruby_gems@readytech.io"]
11
11
 
12
12
  spec.licenses = ['MIT']
13
13
  spec.summary = %q{A simple gem for one off tasks}
14
14
  spec.description = %q{A simple gem for one off tasks for example database patches}
15
- spec.homepage = "http://github.com/jobready/patches"
15
+ spec.homepage = "https://github.com/rdytech/patches"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
18
  spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
+ # Runtime constraints are deliberately unchanged here: raising a minimum can
23
+ # block an install that works today, which is a major-version change.
24
+ # README.md records the range CI actually verifies. Declaring activerecord
25
+ # (Patches::Patch subclasses ActiveRecord::Base) and bounding slack-notifier
26
+ # are queued for the next minor.
22
27
  spec.add_dependency "railties", ">= 3.2"
23
28
  spec.add_dependency "slack-notifier"
24
29
 
25
- spec.add_development_dependency "bundler", "~> 1.8"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "sqlite3", "~> 1.3.5"
28
- spec.add_development_dependency "rspec-rails", "~> 4.0.0"
29
- spec.add_development_dependency "capybara", "~> 2.3.0"
30
- spec.add_development_dependency "generator_spec", "~> 0.9.0"
31
- spec.add_development_dependency "simplecov", "~> 0.10"
32
- spec.add_development_dependency "factory_girl", "~> 4.5.0"
33
- spec.add_development_dependency "timecop", "~> 0.7.0"
34
- spec.add_development_dependency "database_cleaner", "~> 1.3.0"
30
+ spec.add_development_dependency "bundler", "> 1.8"
31
+ spec.add_development_dependency "rake", "> 10.0"
32
+ spec.add_development_dependency "rspec", "~> 3.13"
33
+ spec.add_development_dependency "simplecov", "~> 0.17", '< 0.18' # sonarscanner requires < 0.18
35
34
  spec.add_development_dependency "pry"
36
- spec.add_development_dependency "sidekiq", "~> 3.4.1"
37
35
  spec.add_development_dependency "webmock"
38
- spec.add_development_dependency "byebug"
36
+
37
+ # rails, sqlite3, sidekiq and concurrent-ruby live in the Gemfile so CI can
38
+ # vary them across the range documented in README.md. capybara, factory_girl,
39
+ # timecop, generator_spec, byebug and database_cleaner were referenced by no
40
+ # spec, and rspec-rails was never required, so plain rspec replaces it.
41
+ # Sidekiq is an optional integration, not a runtime dependency, and the suite
42
+ # is expected to pass without it installed.
39
43
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patches
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.2
4
+ version: 3.6.3
5
5
  platform: ruby
6
6
  authors:
7
- - JobReady
8
- autorequire:
7
+ - ReadyTech
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: railties
@@ -42,142 +41,64 @@ dependencies:
42
41
  name: bundler
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
- - - "~>"
44
+ - - ">"
46
45
  - !ruby/object:Gem::Version
47
46
  version: '1.8'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
- - - "~>"
51
+ - - ">"
53
52
  - !ruby/object:Gem::Version
54
53
  version: '1.8'
55
54
  - !ruby/object:Gem::Dependency
56
55
  name: rake
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
- - - "~>"
58
+ - - ">"
60
59
  - !ruby/object:Gem::Version
61
60
  version: '10.0'
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
- - - "~>"
65
+ - - ">"
67
66
  - !ruby/object:Gem::Version
68
67
  version: '10.0'
69
68
  - !ruby/object:Gem::Dependency
70
- name: sqlite3
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 1.3.5
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 1.3.5
83
- - !ruby/object:Gem::Dependency
84
- name: rspec-rails
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 4.0.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 4.0.0
97
- - !ruby/object:Gem::Dependency
98
- name: capybara
69
+ name: rspec
99
70
  requirement: !ruby/object:Gem::Requirement
100
71
  requirements:
101
72
  - - "~>"
102
73
  - !ruby/object:Gem::Version
103
- version: 2.3.0
74
+ version: '3.13'
104
75
  type: :development
105
76
  prerelease: false
106
77
  version_requirements: !ruby/object:Gem::Requirement
107
78
  requirements:
108
79
  - - "~>"
109
80
  - !ruby/object:Gem::Version
110
- version: 2.3.0
111
- - !ruby/object:Gem::Dependency
112
- name: generator_spec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.9.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.9.0
81
+ version: '3.13'
125
82
  - !ruby/object:Gem::Dependency
126
83
  name: simplecov
127
84
  requirement: !ruby/object:Gem::Requirement
128
85
  requirements:
129
86
  - - "~>"
130
87
  - !ruby/object:Gem::Version
131
- version: '0.10'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.10'
139
- - !ruby/object:Gem::Dependency
140
- name: factory_girl
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 4.5.0
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 4.5.0
153
- - !ruby/object:Gem::Dependency
154
- name: timecop
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
88
+ version: '0.17'
89
+ - - "<"
158
90
  - !ruby/object:Gem::Version
159
- version: 0.7.0
91
+ version: '0.18'
160
92
  type: :development
161
93
  prerelease: false
162
94
  version_requirements: !ruby/object:Gem::Requirement
163
95
  requirements:
164
96
  - - "~>"
165
97
  - !ruby/object:Gem::Version
166
- version: 0.7.0
167
- - !ruby/object:Gem::Dependency
168
- name: database_cleaner
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - "~>"
98
+ version: '0.17'
99
+ - - "<"
172
100
  - !ruby/object:Gem::Version
173
- version: 1.3.0
174
- type: :development
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - "~>"
179
- - !ruby/object:Gem::Version
180
- version: 1.3.0
101
+ version: '0.18'
181
102
  - !ruby/object:Gem::Dependency
182
103
  name: pry
183
104
  requirement: !ruby/object:Gem::Requirement
@@ -192,20 +113,6 @@ dependencies:
192
113
  - - ">="
193
114
  - !ruby/object:Gem::Version
194
115
  version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: sidekiq
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: 3.4.1
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: 3.4.1
209
116
  - !ruby/object:Gem::Dependency
210
117
  name: webmock
211
118
  requirement: !ruby/object:Gem::Requirement
@@ -220,29 +127,16 @@ dependencies:
220
127
  - - ">="
221
128
  - !ruby/object:Gem::Version
222
129
  version: '0'
223
- - !ruby/object:Gem::Dependency
224
- name: byebug
225
- requirement: !ruby/object:Gem::Requirement
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- version: '0'
230
- type: :development
231
- prerelease: false
232
- version_requirements: !ruby/object:Gem::Requirement
233
- requirements:
234
- - - ">="
235
- - !ruby/object:Gem::Version
236
- version: '0'
237
130
  description: A simple gem for one off tasks for example database patches
238
131
  email:
239
- - ruby_gems@jobready.com.au
132
+ - ruby_gems@readytech.io
240
133
  executables: []
241
134
  extensions: []
242
135
  extra_rdoc_files: []
243
136
  files:
244
- - ".buildkite/pipeline.yml"
245
137
  - ".github/workflows/publish.yml"
138
+ - ".github/workflows/release.yml"
139
+ - ".github/workflows/specs.yml"
246
140
  - ".gitignore"
247
141
  - ".rspec"
248
142
  - CHANGELOG.md
@@ -250,6 +144,7 @@ files:
250
144
  - Gemfile
251
145
  - LICENSE.md
252
146
  - README.md
147
+ - RELEASING.md
253
148
  - Rakefile
254
149
  - bin/console
255
150
  - bin/setup
@@ -257,7 +152,6 @@ files:
257
152
  - docker-compose.yml
258
153
  - docs/patches.jpg
259
154
  - docs/usage.md
260
- - lib/generators/patches.rb
261
155
  - lib/generators/patches/patch_generator.rb
262
156
  - lib/generators/patches/templates/patch.rb.erb
263
157
  - lib/generators/patches/templates/patch_spec.rb.erb
@@ -272,6 +166,7 @@ files:
272
166
  - lib/patches/patch.rb
273
167
  - lib/patches/pending.rb
274
168
  - lib/patches/runner.rb
169
+ - lib/patches/sidekiq_job.rb
275
170
  - lib/patches/tenant_run_concern.rb
276
171
  - lib/patches/tenant_runner.rb
277
172
  - lib/patches/tenant_worker.rb
@@ -279,11 +174,10 @@ files:
279
174
  - lib/patches/worker.rb
280
175
  - lib/tasks/patches.rake
281
176
  - patches.gemspec
282
- homepage: http://github.com/jobready/patches
177
+ homepage: https://github.com/rdytech/patches
283
178
  licenses:
284
179
  - MIT
285
180
  metadata: {}
286
- post_install_message:
287
181
  rdoc_options: []
288
182
  require_paths:
289
183
  - lib
@@ -298,8 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
298
192
  - !ruby/object:Gem::Version
299
193
  version: '0'
300
194
  requirements: []
301
- rubygems_version: 3.1.6
302
- signing_key:
195
+ rubygems_version: 3.6.9
303
196
  specification_version: 4
304
197
  summary: A simple gem for one off tasks
305
198
  test_files: []
@@ -1,24 +0,0 @@
1
- steps:
2
- - label: ':hammer: Tests'
3
- plugins:
4
- docker-compose:
5
- run: app
6
- command: 'bundle exec rspec'
7
- agents:
8
- queue: docker-heavy
9
- artifact_paths: 'coverage/.resultset.json'
10
-
11
- - wait
12
-
13
- - command: "Report CodeClimate Coverage"
14
- label: ":codeclimate: Report coverage"
15
- plugins:
16
- jobready/codeclimate-test-reporter#v2.0:
17
- prefix: /app
18
- artifact: "coverage/.resultset*.json"
19
- input_type: simplecov
20
- parts: 1
21
- env:
22
- CC_TEST_REPORTER_ID:
23
- agents:
24
- queue: docker-heavy
@@ -1,22 +0,0 @@
1
- module Patches
2
- module Generators
3
- class PatchGenerator < Rails::Generators::NamedBase
4
- desc 'Adds an empty patch'
5
- source_root File.expand_path('../templates', __FILE__)
6
-
7
- def generate_patch
8
- template "patch.erb", "app/db/#{file_name}.rb"
9
- end
10
-
11
- private
12
-
13
- def class_name
14
- name.camelize
15
- end
16
-
17
- def file_name
18
- name.underscore
19
- end
20
- end
21
- end
22
- end