Skip to content

Commit fde6aff

Browse files
committed
Prepare for v2
* Support JWT gem v3 * Drop support for rubies < 3.4 * Update development dependencies * Enforce MFA on gem push * Rely less on auto-inject for private APIs * Use dry-configurable instead of auto-injecting config
1 parent d9aaaf1 commit fde6aff

59 files changed

Lines changed: 3891 additions & 1246 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,34 @@ jobs:
1515
lint:
1616
runs-on: ubuntu-latest
1717
env:
18+
RUBY_VERSION: ruby-4.0.1
19+
RUBOCOP_CACHE_ROOT: tmp/rubocop
1820
APPRAISAL_NAME: rack_3
1921
BUNDLE_GEMFILE: ./gemfiles/rack_3.gemfile
2022
steps:
2123
- uses: actions/checkout@v2
2224
- uses: ruby/setup-ruby@v1
2325
with:
24-
ruby-version: 3.0.0
25-
- uses: actions/cache@v4
26+
ruby-version: ${{ env.RUBY_VERSION }}
27+
bundler-cache: true
28+
- uses: actions/cache@v5
29+
env:
30+
DEPENDENCIES_HASH: ${{ hashFiles('.rubocop.yml', '.rubocop_todo.yml', format('{0}.lock', env.BUNDLE_GEMFILE)) }}
2631
with:
27-
path: vendor/bundle
28-
key: bundle-use-ruby-ubuntu-latest-3.0.0-rack_3-${{ hashFiles(format('{0}.lock', env.BUNDLE_GEMFILE)) }}
32+
path: ${{ env.RUBOCOP_CACHE_ROOT }}
33+
key: rubocop-${{ runner.os }}-${{ env.RUBY_VERSION }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }}
2934
restore-keys: |
30-
bundle-use-ruby-ubuntu-latest-3.0.0-rack_3
31-
- name: bundle install
32-
run: |
33-
bundle config deployment true
34-
bundle config path vendor/bundle
35-
bundle install --jobs 4
35+
rubocop-${{ runner.os }}-${{ env.RUBY_VERSION }}-${{ env.DEPENDENCIES_HASH }}-
3636
- name: "Run rubocop"
3737
run: |
38-
bin/rubocop
38+
bin/rubocop -f github
3939
rspec:
4040
runs-on: ubuntu-latest
4141
strategy:
4242
fail-fast: false
4343
matrix:
44-
appraisal_name: [rack_2, rack_3, rails_6_0, rails_6_1]
45-
ruby: [3.0.0]
44+
appraisal_name: [jwt_2, jwt_3, rack_2, rack_3, rails_7_1, rails_7_2, rails_8_0, rails_8_1]
45+
ruby: [3.4.7, 4.0.1]
4646
env:
4747
APPRAISAL_NAME: ${{ matrix.appraisal_name }}
4848
BUNDLE_GEMFILE: ${{ format('./gemfiles/{0}.gemfile', matrix.appraisal_name) }}
@@ -51,17 +51,7 @@ jobs:
5151
- uses: ruby/setup-ruby@v1
5252
with:
5353
ruby-version: ${{ matrix.ruby }}
54-
- uses: actions/cache@v4
55-
with:
56-
path: vendor/bundle
57-
key: bundle-use-ruby-ubuntu-latest-${{ matrix.ruby }}-${{ env.APPRAISAL_NAME }}-${{ hashFiles(format('{0}.lock', env.BUNDLE_GEMFILE)) }}
58-
restore-keys: |
59-
bundle-use-ruby-ubuntu-latest-${{ matrix.ruby }}-${{ env.APPRAISAL_NAME }}
60-
- name: bundle install
61-
run: |
62-
bundle config deployment true
63-
bundle config path vendor/bundle
64-
bundle install --jobs 4
54+
bundler-cache: true
6555
- name: "Run RSpec"
6656
run: |
6757
bin/rspec

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
/spec/examples.txt
77
/.yardoc
88
/_yardoc/
9+
spec/dummy/log
10+
spec/dummy/tmp

.rubocop.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
require:
1+
plugins:
2+
- rubocop-factory_bot
23
- rubocop-rake
34
- rubocop-rspec
45

56
AllCops:
7+
NewCops: enable
68
Exclude:
79
- Appraisals
810
- "bin/*"
911
- "gemfiles/**/*"
10-
TargetRubyVersion: 3.0
12+
- "vendor/**/*"
13+
TargetRubyVersion: 3.4
1114

1215
Bundler/OrderedGems:
1316
Enabled: false
1417

15-
Gemspec/DateAssignment:
18+
# Explicit is better.
19+
FactoryBot/SyntaxMethods:
20+
Enabled: false
21+
22+
Gemspec/DeprecatedAttributeAssignment:
1623
Enabled: true
1724

25+
# We use appraisals.
26+
Gemspec/DevelopmentDependencies:
27+
Enabled: false
28+
1829
Layout/ArgumentAlignment:
1930
Enabled: false
2031

@@ -98,7 +109,7 @@ Lint/UnusedMethodArgument:
98109
Enabled: false
99110

100111
Metrics/AbcSize:
101-
Max: 25
112+
Max: 30
102113

103114
# This doesn't work with anything that uses a DSL
104115
Metrics/BlockLength:
@@ -113,7 +124,7 @@ Metrics/MethodLength:
113124
Naming/MethodName:
114125
Enabled: false
115126

116-
Naming/PredicateName:
127+
Naming/PredicatePrefix:
117128
ForbiddenPrefixes:
118129
- is_
119130

@@ -126,6 +137,9 @@ RSpec/DescribeClass:
126137
RSpec/DescribedClass:
127138
Enabled: false
128139

140+
RSpec/ExampleWording:
141+
Enabled: false
142+
129143
RSpec/LeadingSubject:
130144
Enabled: false
131145

Appraisals

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# frozen_string_literal: true
22

3+
appraise "jwt_2" do
4+
gem "jwt", ">= 2.2.0", "< 3"
5+
end
6+
7+
appraise "jwt_3" do
8+
gem "jwt", ">= 3", "< 4"
9+
end
10+
311
appraise "rack_2" do
412
gem "rack", ">= 2.2", "< 3"
513
end
@@ -8,14 +16,26 @@ appraise "rack_3" do
816
gem "rack", ">= 3", "< 4"
917
end
1018

11-
appraise "rails_6_0" do
12-
gem "rails", ">= 6", "< 6.1.0"
19+
appraise "rails_7_1" do
20+
gem "rails", ">= 7.1.0", "< 8.0.0"
21+
22+
gem "rspec-rails", "5.0.1"
23+
end
24+
25+
appraise "rails_7_2" do
26+
gem "rails", ">= 7.2.0", "< 8.0.0"
27+
28+
gem "rspec-rails", "5.0.1"
29+
end
30+
31+
appraise "rails_8_0" do
32+
gem "rails", ">= 8.0.0", "< 9.0.0"
1333

1434
gem "rspec-rails", "5.0.1"
1535
end
1636

17-
appraise "rails_6_1" do
18-
gem "rails", ">= 6.1.0", "< 6.2.0"
37+
appraise "rails_8_1" do
38+
gem "rails", ">= 8.0.0", "< 9.0.0"
1939

2040
gem "rspec-rails", "5.0.1"
2141
end

bin/appraisal

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,9 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
require "pathname"
12-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13-
Pathname.new(__FILE__).realpath)
14-
15-
bundle_binstub = File.expand_path("../bundle", __FILE__)
16-
17-
if File.file?(bundle_binstub)
18-
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19-
load(bundle_binstub)
20-
else
21-
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22-
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23-
end
24-
end
11+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2512

2613
require "rubygems"
2714
require "bundler/setup"
2815

29-
load Gem.bin_path("appraisal", "appraisal")
16+
load Gem.bin_path("appraisal2", "appraisal")

gemfiles/jwt_2.gemfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file was generated by Appraisal2
2+
3+
source "https://rubygems.org"
4+
5+
gem "jwt", ">= 2.2.0", "< 3"
6+
7+
gemspec :path => "../"

0 commit comments

Comments
 (0)