Skip to content

Commit e1521d4

Browse files
authored
Support Ruby 3.3+, update Rubocop, and prepare release process (#6)
* update ruby, rubocop, and add cop changes * fix broken rspec invocation * railtie spec: fix for rails >= 7 * add rubocop fixes * prepare for release of 0.3.0 * update github actions workflows and add gem push workflow
1 parent cc0f728 commit e1521d4

File tree

19 files changed

+280
-50
lines changed

19 files changed

+280
-50
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
name: Build
2-
on: [ push, pull_request ]
2+
on: [ push, pull_request, workflow_dispatch ]
33
jobs:
44
test:
55
strategy:
66
fail-fast: false
77
matrix:
88
os: [ ubuntu-latest, macos-latest ]
9-
ruby: [ '2.7', '3.0' ]
9+
ruby: [ '3.3', '3.4' ]
1010
runs-on: ${{ matrix.os }}
1111

1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: ruby/setup-ruby@v1
13+
- name: Check out repository
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Ruby
17+
uses: ruby/setup-ruby@v1
1518
with:
1619
ruby-version: ${{ matrix.ruby }}
1720
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
18-
- run: bundle exec rake
21+
22+
- name: Run checks
23+
run: bundle exec rake
24+
25+
- name: Upload artifacts
26+
if: ${{ always() }}
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: artifacts-${{ matrix.ruby }}-${{ matrix.os }}
30+
path: artifacts/**

.github/workflows/gem-push.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Ruby Gem
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+
18+
- name: Set up Ruby
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: '3.3'
22+
bundler-cache: true
23+
24+
- name: Publish to RubyGems
25+
run: |
26+
mkdir -p $HOME/.gem
27+
touch $HOME/.gem/credentials
28+
chmod 0600 $HOME/.gem/credentials
29+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
30+
gem build *.gemspec
31+
gem push *.gem
32+
env:
33+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"

.rubocop.yml

Lines changed: 177 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ AllCops:
66
- 'out/**/*'
77
# Exclude vendor files in GitHub build
88
- 'vendor/**/*'
9+
SuggestExtensions:
10+
rubocop-rails: false
911

1012
# Allow one line around block body (Layout/EmptyLines will still disallow two or more)
1113
Layout/EmptyLinesAroundBlockBody:
@@ -181,7 +183,7 @@ Lint/TripleQuotes: # (new in 1.9)
181183
Enabled: true
182184
Style/IfWithBooleanLiteralBranches: # (new in 1.9)
183185
Enabled: true
184-
Gemspec/DateAssignment: # (new in 1.10)
186+
Gemspec/DeprecatedAttributeAssignment: # (new in 1.10)
185187
Enabled: true
186188
Style/HashConversion: # (new in 1.10)
187189
Enabled: true
@@ -234,3 +236,177 @@ Style/MapToHash: # new in 1.24
234236
Style/NestedFileDirname: # new in 1.26
235237
Enabled: true
236238

239+
Gemspec/AddRuntimeDependency: # new in 1.65
240+
Enabled: true
241+
Gemspec/AttributeAssignment: # new in 1.77
242+
Enabled: true
243+
Gemspec/DevelopmentDependencies: # new in 1.44
244+
Enabled: false
245+
Layout/LineContinuationLeadingSpace: # new in 1.31
246+
Enabled: true
247+
Layout/LineContinuationSpacing: # new in 1.31
248+
Enabled: true
249+
Lint/ArrayLiteralInRegexp: # new in 1.71
250+
Enabled: true
251+
Lint/ConstantOverwrittenInRescue: # new in 1.31
252+
Enabled: true
253+
Lint/ConstantReassignment: # new in 1.70
254+
Enabled: true
255+
Lint/CopDirectiveSyntax: # new in 1.72
256+
Enabled: true
257+
Lint/DuplicateMagicComment: # new in 1.37
258+
Enabled: true
259+
Lint/DuplicateMatchPattern: # new in 1.50
260+
Enabled: true
261+
Lint/DuplicateSetElement: # new in 1.67
262+
Enabled: true
263+
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
264+
Enabled: true
265+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
266+
Enabled: true
267+
Lint/LiteralAssignmentInCondition: # new in 1.58
268+
Enabled: true
269+
Lint/MixedCaseRange: # new in 1.53
270+
Enabled: true
271+
Lint/NonAtomicFileOperation: # new in 1.31
272+
Enabled: true
273+
Lint/NumericOperationWithConstantResult: # new in 1.69
274+
Enabled: true
275+
Lint/RedundantRegexpQuantifiers: # new in 1.53
276+
Enabled: true
277+
Lint/RedundantTypeConversion: # new in 1.72
278+
Enabled: true
279+
Lint/RefinementImportMethods: # new in 1.27
280+
Enabled: true
281+
Lint/RequireRangeParentheses: # new in 1.32
282+
Enabled: true
283+
Lint/SharedMutableDefault: # new in 1.70
284+
Enabled: true
285+
Lint/SuppressedExceptionInNumberConversion: # new in 1.72
286+
Enabled: true
287+
Lint/UnescapedBracketInRegexp: # new in 1.68
288+
Enabled: true
289+
Lint/UselessConstantScoping: # new in 1.72
290+
Enabled: true
291+
Lint/UselessDefaultValueArgument: # new in 1.76
292+
Enabled: true
293+
Lint/UselessDefined: # new in 1.69
294+
Enabled: true
295+
Lint/UselessNumericOperation: # new in 1.66
296+
Enabled: true
297+
Lint/UselessOr: # new in 1.76
298+
Enabled: true
299+
Lint/UselessRescue: # new in 1.43
300+
Enabled: true
301+
Metrics/CollectionLiteralLength: # new in 1.47
302+
Enabled: true
303+
Naming/PredicateMethod: # new in 1.76
304+
Enabled: true
305+
Security/CompoundHash: # new in 1.28
306+
Enabled: true
307+
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
308+
Enabled: true
309+
Style/ArrayIntersect: # new in 1.40
310+
Enabled: true
311+
Style/BitwisePredicate: # new in 1.68
312+
Enabled: true
313+
Style/CollectionQuerying: # new in 1.77
314+
Enabled: true
315+
Style/CombinableDefined: # new in 1.68
316+
Enabled: true
317+
Style/ComparableBetween: # new in 1.74
318+
Enabled: true
319+
Style/ComparableClamp: # new in 1.44
320+
Enabled: true
321+
Style/ConcatArrayLiterals: # new in 1.41
322+
Enabled: true
323+
Style/DataInheritance: # new in 1.49
324+
Enabled: true
325+
Style/DigChain: # new in 1.69
326+
Enabled: true
327+
Style/DirEmpty: # new in 1.48
328+
Enabled: true
329+
Style/EmptyHeredoc: # new in 1.32
330+
Enabled: true
331+
Style/EmptyStringInsideInterpolation: # new in 1.76
332+
Enabled: true
333+
Style/EnvHome: # new in 1.29
334+
Enabled: true
335+
Style/ExactRegexpMatch: # new in 1.51
336+
Enabled: true
337+
Style/FetchEnvVar: # new in 1.28
338+
Enabled: true
339+
Style/FileEmpty: # new in 1.48
340+
Enabled: true
341+
Style/FileNull: # new in 1.69
342+
Enabled: true
343+
Style/FileTouch: # new in 1.69
344+
Enabled: true
345+
Style/HashFetchChain: # new in 1.75
346+
Enabled: true
347+
Style/HashSlice: # new in 1.71
348+
Enabled: true
349+
Style/ItAssignment: # new in 1.70
350+
Enabled: true
351+
Style/ItBlockParameter: # new in 1.75
352+
Enabled: true
353+
Style/KeywordArgumentsMerging: # new in 1.68
354+
Enabled: true
355+
Style/MagicCommentFormat: # new in 1.35
356+
Enabled: true
357+
Style/MapCompactWithConditionalBlock: # new in 1.30
358+
Enabled: true
359+
Style/MapIntoArray: # new in 1.63
360+
Enabled: true
361+
Style/MapToSet: # new in 1.42
362+
Enabled: true
363+
Style/MinMaxComparison: # new in 1.42
364+
Enabled: true
365+
Style/ObjectThen: # new in 1.28
366+
Enabled: true
367+
Style/OperatorMethodCall: # new in 1.37
368+
Enabled: true
369+
Style/RedundantArrayConstructor: # new in 1.52
370+
Enabled: true
371+
Style/RedundantArrayFlatten: # new in 1.76
372+
Enabled: true
373+
Style/RedundantConstantBase: # new in 1.40
374+
Enabled: true
375+
Style/RedundantCurrentDirectoryInPath: # new in 1.53
376+
Enabled: true
377+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
378+
Enabled: true
379+
Style/RedundantEach: # new in 1.38
380+
Enabled: true
381+
Style/RedundantFilterChain: # new in 1.52
382+
Enabled: true
383+
Style/RedundantFormat: # new in 1.72
384+
Enabled: true
385+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
386+
Enabled: true
387+
Style/RedundantInitialize: # new in 1.27
388+
Enabled: true
389+
Style/RedundantInterpolationUnfreeze: # new in 1.66
390+
Enabled: true
391+
Style/RedundantLineContinuation: # new in 1.49
392+
Enabled: true
393+
Style/RedundantRegexpArgument: # new in 1.53
394+
Enabled: true
395+
Style/RedundantRegexpConstructor: # new in 1.52
396+
Enabled: true
397+
Style/RedundantStringEscape: # new in 1.37
398+
Enabled: true
399+
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
400+
Enabled: true
401+
Style/SafeNavigationChainLength: # new in 1.68
402+
Enabled: true
403+
Style/SendWithLiteralMethodName: # new in 1.64
404+
Enabled: true
405+
Style/SingleLineDoEndBlock: # new in 1.57
406+
Enabled: true
407+
Style/SuperArguments: # new in 1.64
408+
Enabled: true
409+
Style/SuperWithArgsParentheses: # new in 1.58
410+
Enabled: true
411+
Style/YAMLFileRead: # new in 1.53
412+
Enabled: true

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.7
1+
~> 3.3

CHANGES.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# 0.2.8 (next)
1+
# 0.3.0 (2025-07-23)
22

3-
- Log `HTTP_USER_AGENT`
3+
- Update to support Ruby 3.3+ and Rails 7+ exclusively.
4+
- Update Rubocop & Style changes.
5+
- Log `HTTP_USER_AGENT`.
46

57
# 0.2.7 (2022-05-25)
68

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# =============================================================================
22
# Target: base
33

4-
FROM ruby:2.7-alpine AS base
4+
FROM ruby:3.3-alpine AS base
55

66
RUN apk --no-cache --update upgrade && \
77
apk --no-cache add \
@@ -12,6 +12,7 @@ RUN apk --no-cache --update upgrade && \
1212
openssl \
1313
tzdata \
1414
xz-libs \
15+
yaml-dev \
1516
&& rm -rf /var/cache/apk/*
1617

1718
WORKDIR /opt/app
@@ -29,8 +30,8 @@ RUN apk --update --no-cache add \
2930
git \
3031
&& rm -rf /var/cache/apk/*
3132

32-
# The base image ships bundler 1.17.2, but we want something more recent
33-
RUN gem install bundler -v 2.1.4
33+
# The base image ships an older bundler, but we want something more recent
34+
RUN gem install bundler -v 2.5.22
3435

3536
# Copy codebase to WORKDIR. Unlike application projects, for a gem project
3637
# we need to do this before running `bundle install`, in order for the gem

berkeley_library-logging.gemspec

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,40 @@ require 'berkeley_library/logging/module_info'
1111

1212
Gem::Specification.new do |spec|
1313
spec.name = BerkeleyLibrary::Logging::ModuleInfo::NAME
14-
spec.author = BerkeleyLibrary::Logging::ModuleInfo::AUTHOR
15-
spec.email = BerkeleyLibrary::Logging::ModuleInfo::AUTHOR_EMAIL
14+
spec.author = BerkeleyLibrary::Logging::ModuleInfo::AUTHORS
15+
spec.email = BerkeleyLibrary::Logging::ModuleInfo::AUTHOR_EMAILS
1616
spec.summary = BerkeleyLibrary::Logging::ModuleInfo::SUMMARY
1717
spec.description = BerkeleyLibrary::Logging::ModuleInfo::DESCRIPTION
1818
spec.license = BerkeleyLibrary::Logging::ModuleInfo::LICENSE
1919
spec.version = BerkeleyLibrary::Logging::ModuleInfo::VERSION
2020
spec.homepage = BerkeleyLibrary::Logging::ModuleInfo::HOMEPAGE
2121

2222
spec.files = `git ls-files -z`.split("\x0")
23-
spec.test_files = spec.files.grep(%r{^(test|spec|features|artifacts)/})
2423
spec.require_paths = ['lib']
2524

26-
spec.required_ruby_version = ">= #{ruby_version}"
25+
spec.required_ruby_version = ruby_version
2726

28-
rails_version = '>= 6'
27+
rails_version = '>= 7'
2928

3029
spec.add_dependency 'activesupport', rails_version
3130
spec.add_dependency 'amazing_print', '~> 1.1'
32-
spec.add_dependency 'colorize', '~> 0.8.1'
31+
spec.add_dependency 'colorize', '~> 1.0'
3332
spec.add_dependency 'lograge', '~> 0.11'
34-
spec.add_dependency 'ougai', '~> 1.8'
33+
spec.add_dependency 'ougai', '~> 2.0'
3534

3635
spec.add_development_dependency 'brakeman', '~> 4.9'
3736
spec.add_development_dependency 'bundle-audit', '~> 0.1'
3837
spec.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
3938
spec.add_development_dependency 'dotenv', '~> 2.7'
40-
spec.add_development_dependency 'irb', '~> 1.2' # workaroundfor https://github.com/bundler/bundler/issues/6929
41-
spec.add_development_dependency 'listen', '>= 3.0.5', '< 3.2'
39+
spec.add_development_dependency 'listen', '~> 3.2'
4240
spec.add_development_dependency 'rails', rails_version
4341
spec.add_development_dependency 'rake', '~> 13.0'
44-
spec.add_development_dependency 'rspec-support', '~> 3.9'
45-
spec.add_development_dependency 'rubocop', '~> 1.26.0'
46-
spec.add_development_dependency 'rubocop-rspec', '~> 2.4.0'
47-
spec.add_development_dependency 'simplecov', '~> 0.21.1'
48-
spec.add_development_dependency 'simplecov-console', '~> 0.9.1'
42+
spec.add_development_dependency 'rspec', '~> 3.9'
43+
spec.add_development_dependency 'rubocop', '~> 1.78.0'
44+
spec.add_development_dependency 'rubocop-rake', '~> 0.7.1'
45+
spec.add_development_dependency 'rubocop-rspec', '~> 3.6.0'
46+
spec.add_development_dependency 'simplecov', '~> 0.21'
47+
spec.add_development_dependency 'simplecov-console', '~> 0.9'
4948
spec.add_development_dependency 'simplecov-rcov', '~> 0.2'
5049

5150
spec.metadata['rubygems_mfa_required'] = 'true'

lib/berkeley_library/logging.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ def logger=(v)
2424
@logger = (ensure_logger(v) unless v.nil?)
2525
end
2626

27-
private
28-
2927
LOG_METHODS = %i[debug info warn error].freeze
3028

29+
private
30+
3131
def ensure_logger(v)
3232
return v if (missing = LOG_METHODS.reject { |m| v.respond_to?(m) }).empty?
3333

lib/berkeley_library/logging/env.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def env
1313
@env ||= begin
1414
# NOTE: can't just self.env= b/c it returns the wrong value -- see
1515
# https://stackoverflow.com/q/65226532/27358
16-
env = (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || FALLBACK_ENV)
16+
env = ENV['RAILS_ENV'] || ENV['RACK_ENV'] || FALLBACK_ENV
1717
ensure_rails_env_like(env)
1818
end
1919
end

lib/berkeley_library/logging/loggers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def default_log_file_for(config)
6363

6464
def ensure_log_directory
6565
File.join(workdir, FALLBACK_LOG_DIR).tap do |log_dir|
66-
FileUtils.mkdir(log_dir) unless File.exist?(log_dir)
66+
FileUtils.mkdir_p(log_dir)
6767
raise ArgumentError, "Not a directory: #{log_dir}" unless File.directory?(log_dir)
6868
end
6969
end

0 commit comments

Comments
 (0)