patches 3.5.0 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00a5a2af4415f00b094e7a41da3c17ddb61d17c9e23987aa16dddf789aec7794
4
- data.tar.gz: 3125f98fb50e54c658a2be70a369f2627c138fb50c1ba8f9c417c5139a144f56
3
+ metadata.gz: c1f8701526a4dd4b0b2f9468a341fda316bde2dd0ba8b9bf0cea5e4236aa9ee5
4
+ data.tar.gz: 6b340c8ab529811f011ba4b984f208f2abb080dfe4b97bcbbd2e7fcccf78e92a
5
5
  SHA512:
6
- metadata.gz: d57ccb9aca3ab7c179dce484a7e2021631ef0c70d86bc00f73c921636184d42e372a85a6ab321e599731c72dfcf40716b52a234d7c33bebb9ba8d102d64ba212
7
- data.tar.gz: ed55b40b2ebb05dc6db25c7ccc07a09f774360816fe39a21e1b79903c306bcdd4a4a5b82b2db262966224e1f712656b8eac7bb423f93db004d59d63af26a6763
6
+ metadata.gz: fa96ce95251d9295cd6544c54d8b2670c1d9f8aab860a50874539662a58e571ae902e400169cf58cfbb0649a980cb29badbb9b0dd65c09c2ecea35bfdd26a823
7
+ data.tar.gz: 5e08319d65bbd8d940ef2fd79091c0d6780e35878c4881fdc491a119eeb6a4fbb640a675e3d38d386d3a69eddb192f916d617aeb2285ca565ce187f2b1a32709
@@ -0,0 +1,26 @@
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}}"
data/CHANGELOG.md CHANGED
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.6.0] - 2022-05-27
10
+ ### Added
11
+ - Added `notification_prefix` and `notification_suffix` to configuration options
12
+ - Linked to docs/usage.md in README
13
+
14
+ ### Changed
15
+ - Refactored `Patches::Notifier`
16
+ - `Patches::Notifier.append_tenant_message` effectively replaced by `tenant_suffix`
17
+
9
18
  ## [3.5.0] - 2020-07-22
10
19
  ### Added
11
20
  - Enable application version constraint support on `Patches::TenantWorker`
data/README.md CHANGED
@@ -11,7 +11,7 @@ A simple gem for one off tasks
11
11
 
12
12
  ## Version 2.0
13
13
 
14
- Please note the breaking change release around deployment. See docs/usage.md for the full change.
14
+ Please note the breaking change release around deployment. See [docs/usage.md](docs/usage.md) for the full change.
15
15
 
16
16
  TL;DR You need to manually declare the patches task to run in your deploy.rb
17
17
 
@@ -32,7 +32,7 @@ Or install it yourself as:
32
32
 
33
33
  ## Usage
34
34
 
35
- see `docs/usage.md`
35
+ see [docs/usage.md](docs/usage.md)
36
36
 
37
37
  ## Development
38
38
 
data/docs/usage.md CHANGED
@@ -39,6 +39,15 @@ Patches::Config.configure do |config|
39
39
  end
40
40
  ```
41
41
 
42
+ Additionally, you can override the default prefix and suffix of the
43
+ notification message in the patches config:
44
+
45
+ ```ruby
46
+ # for example
47
+ config.notification_prefix = "#{Tenant.current.name}-#{Rails.env}" # => [READYTECH-STAGING]
48
+ config.notification_suffix = Tenant.current.name # => ... patches succeeded for Readytech
49
+ ```
50
+
42
51
  ### Running patches in parallel for tenants
43
52
 
44
53
  If you are using the Apartment gem, you can run the patches for each tenant in parallel.
@@ -16,6 +16,8 @@ module Patches
16
16
  class Configuration
17
17
  attr_accessor \
18
18
  :application_version,
19
+ :notification_prefix,
20
+ :notification_suffix,
19
21
  :retry_after_version_mismatch_in,
20
22
  :sidekiq_options,
21
23
  :sidekiq_parallel,
@@ -11,23 +11,32 @@ class Patches::Notifier
11
11
  end
12
12
 
13
13
  def success_message(patches)
14
- message = "#{environment_prefix}#{patches.count} patches succeeded"
15
- append_tenant_message(message)
14
+ message(patches.count, "patches succeeded")
16
15
  end
17
16
 
18
17
  def failure_message(patch_path, error)
19
- details = "#{Pathname.new(patch_path).basename} failed with error: #{error}"
20
- message = "#{environment_prefix}Error applying patch: #{details}"
21
- append_tenant_message(message)
18
+ message("Error applying patch:", Pathname.new(patch_path).basename, "failed with error:", error)
19
+ end
20
+
21
+ def message(*args)
22
+ [notification_prefix, *args, notification_suffix].compact.join(" ")
23
+ end
24
+
25
+ def notification_prefix
26
+ prefix = config.notification_prefix.presence || environment_prefix
27
+ "[#{prefix}]" if prefix.present?
22
28
  end
23
29
 
24
30
  def environment_prefix
25
- "[#{Rails.env.upcase}] " if defined?(Rails)
31
+ Rails.env.upcase if defined?(Rails)
32
+ end
33
+
34
+ def notification_suffix
35
+ config.notification_suffix.presence || tenant_suffix
26
36
  end
27
37
 
28
- def append_tenant_message(message)
29
- message = message + " for tenant: #{Apartment::Tenant.current}" if defined?(Apartment)
30
- message
38
+ def tenant_suffix
39
+ "for tenant: #{Apartment::Tenant.current}" if defined?(Apartment)
31
40
  end
32
41
 
33
42
  def send_slack_message(message, color)
@@ -1,6 +1,6 @@
1
1
  module Patches
2
2
  MAJOR = 3
3
- MINOR = 5
3
+ MINOR = 6
4
4
  PATCH = 0
5
5
  VERSION = [MAJOR, MINOR, PATCH].compact.join(".").freeze
6
6
  end
@@ -22,7 +22,7 @@ namespace :patches do
22
22
  end
23
23
 
24
24
  task :pending => [:environment] do
25
- Patches::Pending.each do |patch|
25
+ Patches::Pending.new.each do |patch|
26
26
  puts patch
27
27
  end
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patches
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JobReady
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-22 00:00:00.000000000 Z
11
+ date: 2022-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -242,6 +242,7 @@ extensions: []
242
242
  extra_rdoc_files: []
243
243
  files:
244
244
  - ".buildkite/pipeline.yml"
245
+ - ".github/workflows/publish.yml"
245
246
  - ".gitignore"
246
247
  - ".rspec"
247
248
  - CHANGELOG.md
@@ -297,7 +298,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
297
298
  - !ruby/object:Gem::Version
298
299
  version: '0'
299
300
  requirements: []
300
- rubygems_version: 3.0.3
301
+ rubygems_version: 3.1.6
301
302
  signing_key:
302
303
  specification_version: 4
303
304
  summary: A simple gem for one off tasks