patches 3.6.3 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -1
- data/README.md +86 -19
- data/docs/usage.md +9 -0
- data/lib/patches/capistrano.rb +4 -0
- data/lib/patches/config.rb +14 -0
- data/lib/patches/deprecation.rb +48 -0
- data/lib/patches/engine.rb +9 -0
- data/lib/patches/sidekiq_job.rb +8 -1
- data/lib/patches/version.rb +2 -2
- data/lib/patches.rb +1 -0
- metadata +21 -16
- data/.github/workflows/publish.yml +0 -26
- data/.github/workflows/release.yml +0 -35
- data/.github/workflows/specs.yml +0 -113
- data/.gitignore +0 -13
- data/.rspec +0 -2
- data/Dockerfile +0 -9
- data/Gemfile +0 -39
- data/RELEASING.md +0 -50
- data/Rakefile +0 -2
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/docker-compose.yml +0 -11
- data/docs/patches.jpg +0 -0
- data/patches.gemspec +0 -43
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 895215b6ac8fa6eb09aea79add6efebcead371d5b50579d983b70eff79c58682
|
|
4
|
+
data.tar.gz: aa05b38f701c0c525364d16f0f22dc7fde9b33c2a34aac240751e78b02d1c3d6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e454bd2d14b1cf02eca6fc4bd18d3732c83627032c0a6a2fb76dbf6c43d07da7ee6786f542c8f689290b75deedc48ea8fb1b8eeb0581363fd48e9719a3478e38
|
|
7
|
+
data.tar.gz: a286831eb61b05d4fbdee99989247671307d3881433e293eacda3afc533b262d0d82d1cb6e098a0c3f4153b01891bd0e4ecece47f235ed36d09715ebb81e3c64
|
data/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,55 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## [3.7.0] - 2026-09-10
|
|
10
|
+
|
|
11
|
+
Declares dependencies the gem always relied on, and announces what 4.0 is
|
|
12
|
+
expected to require. No public API changes and no version constraint moves, so
|
|
13
|
+
anything that installed 3.6.x installs this.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- Gem metadata (`source_code_uri`, `changelog_uri`, `bug_tracker_uri`,
|
|
17
|
+
`documentation_uri`). None were declared, so rubygems.org kept showing values
|
|
18
|
+
carried over from older releases - 3.6.3 still lists `source_code_uri` as
|
|
19
|
+
`http://github.com/jobready/patches`, from before the org was renamed
|
|
20
|
+
- `activerecord` as an explicit runtime dependency, at the same `>= 3.2` floor
|
|
21
|
+
as `railties` so nothing currently installable is excluded. `Patches::Patch`
|
|
22
|
+
subclasses `ActiveRecord::Base` and `Patches::Base#execute` calls
|
|
23
|
+
`ActiveRecord::Base.connection`, but only `railties` had been declared
|
|
24
|
+
- `Patches.deprecator`, a gem-owned `ActiveSupport::Deprecation` instance rather
|
|
25
|
+
than the singleton Rails 7.1 deprecated and 8.0 removed. Host applications can
|
|
26
|
+
silence or redirect it with `Patches.deprecator.behavior = :silence`
|
|
27
|
+
- A deprecation warning when `config.use_slack` is set: from 4.0 Patches will
|
|
28
|
+
not depend on `slack-notifier`, so only applications using Slack carry it.
|
|
29
|
+
Add `gem 'slack-notifier'` to your Gemfile to keep notifications working
|
|
30
|
+
- A deprecation warning on `require 'patches/capistrano'`. The Capistrano task
|
|
31
|
+
is removed in 4.0; invoke `rake patches:run` from your deployment process
|
|
32
|
+
instead. It remains opt-in and loads nothing unless a Capfile requires it
|
|
33
|
+
- Deprecation warnings for the two other things 4.0 is expected to require:
|
|
34
|
+
Sidekiq 6.3 or newer, which is where `Sidekiq::Job` arrives, and Ruby 3.2 /
|
|
35
|
+
Rails 7.2. Those floors are higher than the range CI verifies - Ruby 3.0 and
|
|
36
|
+
Rails 7.1 still pass - so anyone below them hears about it a release ahead.
|
|
37
|
+
The Ruby and Rails notice runs from a Rails initializer, after the
|
|
38
|
+
application's own, so `Patches.deprecator.behavior` can silence it
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
- The published gem carries only what a consumer needs - 27 files rather than
|
|
42
|
+
42. `Dockerfile`, `docker-compose.yml`, `.devcontainer/`, `.github/`, `bin/`,
|
|
43
|
+
`Rakefile`, `RELEASING.md` and a decorative image were being packaged. `lib`,
|
|
44
|
+
the install migration, `docs/usage.md` and the top-level docs remain
|
|
45
|
+
- The development container works again. It was pinned to `ruby:2.3`, which
|
|
46
|
+
cannot satisfy the current Gemfile, and had not been touched since 2018. The
|
|
47
|
+
Ruby version is now a build argument and the gem versions are passed through
|
|
48
|
+
from the shell, so any cell of the matrix in README.md is reproducible in it.
|
|
49
|
+
A `.devcontainer/` referencing the same compose service comes with it, for
|
|
50
|
+
VS Code and Codespaces
|
|
51
|
+
|
|
52
|
+
### Removed
|
|
53
|
+
- `.github/workflows/publish.yml`. It published on `release: published` using a
|
|
54
|
+
`GEM_HOST_API_KEY`, had never run in the four years since it was added, and
|
|
55
|
+
would now attempt a duplicate push if a GitHub Release were created after a
|
|
56
|
+
tag. Releases come from `.github/workflows/release.yml` - see
|
|
57
|
+
[RELEASING.md](RELEASING.md)
|
|
10
58
|
|
|
11
59
|
## [3.6.3] - 2026-09-09
|
|
12
60
|
|
data/README.md
CHANGED
|
@@ -1,19 +1,58 @@
|
|
|
1
1
|
# Patches
|
|
2
2
|
[](https://github.com/rdytech/patches/actions/workflows/specs.yml)
|
|
3
|
-
[](https://codeclimate.com/repos/557f93b76956807f81000001/maintainability)
|
|
4
|
-
[](https://codeclimate.com/repos/557f93b76956807f81000001/test_coverage)
|
|
5
3
|
[](https://badge.fury.io/rb/patches)
|
|
6
4
|
|
|
7
5
|

|
|
8
6
|
|
|
7
|
+
A simple gem for one off tasks - the things that do not belong in a schema
|
|
8
|
+
migration. Back-filling a column, correcting bad data, kicking off a one-time
|
|
9
|
+
import: write it as a class, deploy it, and Patches runs it once and records
|
|
10
|
+
that it ran.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Add the gem to your application's Gemfile:
|
|
15
|
+
|
|
16
|
+
```ruby
|
|
17
|
+
gem 'patches'
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Then install the migration that records which patches have run:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
bundle exec rake patches:install:migrations
|
|
24
|
+
bundle exec rake db:migrate
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
Generate a patch:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
bundle exec rails g patches:patch PreferenceUpdate
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Fill in `run`:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
class PreferenceUpdate < Patches::Base
|
|
39
|
+
def run
|
|
40
|
+
User.where(preference: nil).update_all(preference: 'default')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
```
|
|
11
44
|
|
|
12
|
-
|
|
45
|
+
Run the pending ones - each patch runs once, and is recorded in
|
|
46
|
+
`patches_patches`:
|
|
13
47
|
|
|
14
|
-
|
|
48
|
+
```
|
|
49
|
+
bundle exec rake patches:run
|
|
50
|
+
```
|
|
15
51
|
|
|
16
|
-
|
|
52
|
+
`rake patches:pending` lists what has not run yet. Patches can run inline or in
|
|
53
|
+
the background via Sidekiq, across all tenants when you use Apartment, and
|
|
54
|
+
report to Slack. See [docs/usage.md](docs/usage.md) for configuration, tenants,
|
|
55
|
+
deployment and the Capistrano task.
|
|
17
56
|
|
|
18
57
|
## Compatibility
|
|
19
58
|
|
|
@@ -107,30 +146,58 @@ combination again, and delete `test.db` when switching between them: the suite
|
|
|
107
146
|
creates `patches_patches` only when it is missing, so a database left by an
|
|
108
147
|
earlier run can mask ordering problems.
|
|
109
148
|
|
|
110
|
-
##
|
|
149
|
+
## Deprecations
|
|
111
150
|
|
|
112
|
-
|
|
151
|
+
3.7.0 introduces no breaking changes. It announces what 4.0 is expected to
|
|
152
|
+
require, so the upgrade is uneventful. Each warning names its replacement and
|
|
153
|
+
goes through the gem's own deprecator, which a host application can silence or
|
|
154
|
+
redirect:
|
|
113
155
|
|
|
114
156
|
```ruby
|
|
115
|
-
|
|
157
|
+
Patches.deprecator.behavior = :silence # or :raise, :log, a lambda...
|
|
116
158
|
```
|
|
117
|
-
And then execute:
|
|
118
159
|
|
|
119
|
-
|
|
160
|
+
| Deprecated | Replacement |
|
|
161
|
+
|---|---|
|
|
162
|
+
| Relying on Patches to install `slack-notifier` | Add `gem 'slack-notifier'` to your Gemfile if you use `config.use_slack`. From 4.0 only applications that want it carry it |
|
|
163
|
+
| `require 'patches/capistrano'` | Invoke `rake patches:run` from your deployment process. The Capistrano task is removed in 4.0 |
|
|
164
|
+
| Sidekiq older than 6.3 | Any supported Sidekiq (7.x or 8.x). 4.0 is expected to include `Sidekiq::Job` directly instead of falling back to `Sidekiq::Worker` |
|
|
165
|
+
| Ruby older than 3.2, Rails older than 7.2 | Ruby 3.2+ and Rails 7.2+. 4.0 is expected to raise the gemspec floors to these, which are higher than the range CI verifies today |
|
|
120
166
|
|
|
121
|
-
|
|
167
|
+
Nothing is removed in this release, and the gemspec floors are unchanged, so
|
|
168
|
+
anything that installed 3.6.x installs 3.7.0.
|
|
122
169
|
|
|
123
|
-
|
|
170
|
+
## Development
|
|
124
171
|
|
|
125
|
-
|
|
172
|
+
In VS Code or Codespaces, open the repository in the dev container - it reuses
|
|
173
|
+
the `app` service from `docker-compose.yml`, so there is one definition of the
|
|
174
|
+
environment rather than two. Otherwise, from a shell:
|
|
126
175
|
|
|
127
|
-
|
|
176
|
+
```
|
|
177
|
+
docker compose build
|
|
178
|
+
docker compose run --rm app
|
|
179
|
+
```
|
|
128
180
|
|
|
129
|
-
|
|
181
|
+
The container's default command runs the specs. Any cell of the matrix above is
|
|
182
|
+
reproducible in it: the Ruby version is a build argument, and the gem versions
|
|
183
|
+
are passed through from your shell. The image is built with the default
|
|
184
|
+
versions, so a non-default cell has to install them first:
|
|
130
185
|
|
|
131
186
|
```
|
|
132
|
-
docker
|
|
133
|
-
|
|
187
|
+
docker compose build --build-arg RUBY_VERSION=3.1
|
|
188
|
+
|
|
189
|
+
RAILS_VERSION="~> 7.1.0" docker compose run --rm app \
|
|
190
|
+
sh -c 'bundle install && bundle exec rspec'
|
|
191
|
+
|
|
192
|
+
SIDEKIQ_VERSION=none docker compose run --rm app \
|
|
193
|
+
sh -c 'bundle install && bundle exec rspec --exclude-pattern "sidekiq/**/*_spec.rb"'
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Or without Docker, if you have the Ruby you want on your path:
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
bundle install
|
|
200
|
+
bundle exec rspec
|
|
134
201
|
```
|
|
135
202
|
|
|
136
203
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
@@ -146,4 +213,4 @@ Releases are published by GitHub Actions from a `vX.Y.Z` tag — see
|
|
|
146
213
|
2. Create your feature branch (`git checkout -b feature/my-feature-name`)
|
|
147
214
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
148
215
|
4. Push to the branch (`git push origin feature/my-new-feature`)
|
|
149
|
-
5. Create a new Pull Request
|
|
216
|
+
5. Create a new Pull Request against `develop`
|
data/docs/usage.md
CHANGED
|
@@ -22,6 +22,10 @@ bundle exec rake db:migrate
|
|
|
22
22
|
|
|
23
23
|
## Configuration
|
|
24
24
|
|
|
25
|
+
> **Note.** From 4.0 Patches will not depend on `slack-notifier`, so only
|
|
26
|
+
> applications using Slack carry it. If you set `config.use_slack`, add
|
|
27
|
+
> `gem 'slack-notifier'` to your Gemfile.
|
|
28
|
+
|
|
25
29
|
If you would like to run the patches asynchronously, or would like them to notify
|
|
26
30
|
your Slack channel when they fail or succeed, you need to set up
|
|
27
31
|
an initializer to set those options.
|
|
@@ -113,6 +117,11 @@ bundle exec rake patches:run
|
|
|
113
117
|
|
|
114
118
|
Patches will only ever run once, patches will run in order of creation date.
|
|
115
119
|
|
|
120
|
+
### Capistrano
|
|
121
|
+
|
|
122
|
+
> **Deprecated.** `patches/capistrano` is removed in 4.0. Invoke
|
|
123
|
+
> `rake patches:run` from your deployment process instead.
|
|
124
|
+
|
|
116
125
|
To run patches on deployment using Capistrano, edit your Capfile and add
|
|
117
126
|
|
|
118
127
|
```ruby
|
data/lib/patches/capistrano.rb
CHANGED
data/lib/patches/config.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'patches/deprecation'
|
|
2
|
+
|
|
1
3
|
module Patches
|
|
2
4
|
class Config
|
|
3
5
|
class << self
|
|
@@ -30,6 +32,18 @@ module Patches
|
|
|
30
32
|
@sidekiq_queue = 'default'
|
|
31
33
|
end
|
|
32
34
|
|
|
35
|
+
# Warns only for applications that enable Slack, and only the first time
|
|
36
|
+
# - an initializer that reloads, or configures twice, should not repeat
|
|
37
|
+
# the notice.
|
|
38
|
+
def use_slack=(enabled)
|
|
39
|
+
if enabled && !@warned_about_slack_notifier
|
|
40
|
+
@warned_about_slack_notifier = true
|
|
41
|
+
Patches.warn_slack_notifier_dependency_removed_in_4_0
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
@use_slack = enabled
|
|
45
|
+
end
|
|
46
|
+
|
|
33
47
|
def sidekiq_options
|
|
34
48
|
@sidekiq_options ||= { retry: false, queue: sidekiq_queue }
|
|
35
49
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require 'active_support/deprecation'
|
|
2
|
+
|
|
3
|
+
module Patches
|
|
4
|
+
# A gem-owned deprecator rather than ActiveSupport::Deprecation's singleton,
|
|
5
|
+
# which Rails 7.1 deprecated and 8.0 removed. Host applications can silence or
|
|
6
|
+
# redirect it: Patches.deprecator.behavior = :silence.
|
|
7
|
+
def self.deprecator
|
|
8
|
+
@deprecator ||= ActiveSupport::Deprecation.new('4.0', 'patches')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# The floors 4.0 is expected to set. Deliberately higher than what CI verifies
|
|
12
|
+
# today - Ruby 3.0 and Rails 7.1 still pass - so consumers on those versions
|
|
13
|
+
# hear about it a release ahead rather than at upgrade time.
|
|
14
|
+
MINIMUM_RUBY_IN_4_0 = '3.2'.freeze
|
|
15
|
+
MINIMUM_RAILS_IN_4_0 = '7.2'.freeze
|
|
16
|
+
|
|
17
|
+
def self.warn_slack_notifier_dependency_removed_in_4_0
|
|
18
|
+
deprecator.warn(
|
|
19
|
+
'patches will stop depending on slack-notifier in 4.0, so that only ' \
|
|
20
|
+
"applications using Slack carry it. Add gem 'slack-notifier' to your " \
|
|
21
|
+
'Gemfile to keep notifications working.'
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.warn_capistrano_support_removed_in_4_0
|
|
26
|
+
deprecator.warn(
|
|
27
|
+
'patches/capistrano is deprecated and will be removed in 4.0. Invoke ' \
|
|
28
|
+
'`rake patches:run` from your deployment process instead.'
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.warn_about_versions_dropped_in_4_0
|
|
33
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(MINIMUM_RUBY_IN_4_0)
|
|
34
|
+
deprecator.warn(
|
|
35
|
+
"Ruby #{RUBY_VERSION} will not be supported by patches 4.0, which is " \
|
|
36
|
+
"expected to require Ruby >= #{MINIMUM_RUBY_IN_4_0}."
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
return unless defined?(::Rails::VERSION::STRING)
|
|
41
|
+
return if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new(MINIMUM_RAILS_IN_4_0)
|
|
42
|
+
|
|
43
|
+
deprecator.warn(
|
|
44
|
+
"Rails #{::Rails::VERSION::STRING} will not be supported by patches 4.0, " \
|
|
45
|
+
"which is expected to require Rails >= #{MINIMUM_RAILS_IN_4_0}."
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/patches/engine.rb
CHANGED
|
@@ -3,5 +3,14 @@ require 'rails/engine'
|
|
|
3
3
|
module Patches
|
|
4
4
|
class Engine < Rails::Engine
|
|
5
5
|
isolate_namespace Patches
|
|
6
|
+
|
|
7
|
+
# After the application's own initializers, so that a host which sets
|
|
8
|
+
# Patches.deprecator.behavior in config/initializers can actually silence
|
|
9
|
+
# this. Warning at require time - which happens during Bundler.require,
|
|
10
|
+
# before any initializer - meant the documented mechanism could not work.
|
|
11
|
+
# It also means Rails::VERSION is always loaded by the time we look.
|
|
12
|
+
initializer 'patches.version_deprecations', after: :load_config_initializers do
|
|
13
|
+
Patches.warn_about_versions_dropped_in_4_0
|
|
14
|
+
end
|
|
6
15
|
end
|
|
7
16
|
end
|
data/lib/patches/sidekiq_job.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'sidekiq'
|
|
2
|
+
require 'patches/deprecation'
|
|
2
3
|
|
|
3
4
|
module Patches
|
|
4
5
|
# Sidekiq renamed Sidekiq::Worker to Sidekiq::Job in 6.3 and still ships the
|
|
@@ -6,6 +7,12 @@ module Patches
|
|
|
6
7
|
# workers working on every Sidekiq this gem has ever supported, so the change
|
|
7
8
|
# needs no version bump from consumers.
|
|
8
9
|
def self.sidekiq_job_module
|
|
9
|
-
|
|
10
|
+
return ::Sidekiq::Job if defined?(::Sidekiq::Job)
|
|
11
|
+
|
|
12
|
+
deprecator.warn(
|
|
13
|
+
'Sidekiq older than 6.3 does not provide Sidekiq::Job; patches 4.0 is ' \
|
|
14
|
+
'expected to require it. Upgrade Sidekiq, which supports 7.x and 8.x.'
|
|
15
|
+
)
|
|
16
|
+
::Sidekiq::Worker
|
|
10
17
|
end
|
|
11
18
|
end
|
data/lib/patches/version.rb
CHANGED
data/lib/patches.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: patches
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ReadyTech
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '3.2'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: activerecord
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.2'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.2'
|
|
26
40
|
- !ruby/object:Gem::Dependency
|
|
27
41
|
name: slack-notifier
|
|
28
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -134,23 +148,10 @@ executables: []
|
|
|
134
148
|
extensions: []
|
|
135
149
|
extra_rdoc_files: []
|
|
136
150
|
files:
|
|
137
|
-
- ".github/workflows/publish.yml"
|
|
138
|
-
- ".github/workflows/release.yml"
|
|
139
|
-
- ".github/workflows/specs.yml"
|
|
140
|
-
- ".gitignore"
|
|
141
|
-
- ".rspec"
|
|
142
151
|
- CHANGELOG.md
|
|
143
|
-
- Dockerfile
|
|
144
|
-
- Gemfile
|
|
145
152
|
- LICENSE.md
|
|
146
153
|
- README.md
|
|
147
|
-
- RELEASING.md
|
|
148
|
-
- Rakefile
|
|
149
|
-
- bin/console
|
|
150
|
-
- bin/setup
|
|
151
154
|
- db/migrate/201506011700_create_patch.rb
|
|
152
|
-
- docker-compose.yml
|
|
153
|
-
- docs/patches.jpg
|
|
154
155
|
- docs/usage.md
|
|
155
156
|
- lib/generators/patches/patch_generator.rb
|
|
156
157
|
- lib/generators/patches/templates/patch.rb.erb
|
|
@@ -161,6 +162,7 @@ files:
|
|
|
161
162
|
- lib/patches/capistrano.rb
|
|
162
163
|
- lib/patches/capistrano/tasks.rake
|
|
163
164
|
- lib/patches/config.rb
|
|
165
|
+
- lib/patches/deprecation.rb
|
|
164
166
|
- lib/patches/engine.rb
|
|
165
167
|
- lib/patches/notifier.rb
|
|
166
168
|
- lib/patches/patch.rb
|
|
@@ -173,11 +175,14 @@ files:
|
|
|
173
175
|
- lib/patches/version.rb
|
|
174
176
|
- lib/patches/worker.rb
|
|
175
177
|
- lib/tasks/patches.rake
|
|
176
|
-
- patches.gemspec
|
|
177
178
|
homepage: https://github.com/rdytech/patches
|
|
178
179
|
licenses:
|
|
179
180
|
- MIT
|
|
180
|
-
metadata:
|
|
181
|
+
metadata:
|
|
182
|
+
source_code_uri: https://github.com/rdytech/patches
|
|
183
|
+
changelog_uri: https://github.com/rdytech/patches/blob/v3.7.0/CHANGELOG.md
|
|
184
|
+
bug_tracker_uri: https://github.com/rdytech/patches/issues
|
|
185
|
+
documentation_uri: https://github.com/rdytech/patches/blob/v3.7.0/docs/usage.md
|
|
181
186
|
rdoc_options: []
|
|
182
187
|
require_paths:
|
|
183
188
|
- lib
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Publish
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
release:
|
|
5
|
-
types: [published]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
build:
|
|
9
|
-
name: Build + Publish
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
permissions:
|
|
12
|
-
contents: read
|
|
13
|
-
packages: write
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v3
|
|
17
|
-
- uses: ruby/setup-ruby@v1
|
|
18
|
-
with:
|
|
19
|
-
ruby-version: '2.7'
|
|
20
|
-
|
|
21
|
-
- name: Publish to RubyGems
|
|
22
|
-
run: |
|
|
23
|
-
gem build *.gemspec
|
|
24
|
-
gem push *.gem
|
|
25
|
-
env:
|
|
26
|
-
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
data/.github/workflows/specs.yml
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
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/.gitignore
DELETED
data/.rspec
DELETED
data/Dockerfile
DELETED
data/Gemfile
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
gemspec
|
|
4
|
-
|
|
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/RELEASING.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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.
|
data/Rakefile
DELETED
data/bin/console
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require "bundler/setup"
|
|
4
|
-
require "patches"
|
|
5
|
-
|
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require "irb"
|
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/docker-compose.yml
DELETED
data/docs/patches.jpg
DELETED
|
Binary file
|
data/patches.gemspec
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'patches/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = "patches"
|
|
8
|
-
spec.version = Patches::VERSION
|
|
9
|
-
spec.authors = ["ReadyTech"]
|
|
10
|
-
spec.email = ["ruby_gems@readytech.io"]
|
|
11
|
-
|
|
12
|
-
spec.licenses = ['MIT']
|
|
13
|
-
spec.summary = %q{A simple gem for one off tasks}
|
|
14
|
-
spec.description = %q{A simple gem for one off tasks for example database patches}
|
|
15
|
-
spec.homepage = "https://github.com/rdytech/patches"
|
|
16
|
-
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
-
spec.bindir = "exe"
|
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
|
-
spec.require_paths = ["lib"]
|
|
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.
|
|
27
|
-
spec.add_dependency "railties", ">= 3.2"
|
|
28
|
-
spec.add_dependency "slack-notifier"
|
|
29
|
-
|
|
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
|
|
34
|
-
spec.add_development_dependency "pry"
|
|
35
|
-
spec.add_development_dependency "webmock"
|
|
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.
|
|
43
|
-
end
|