Skip to content

Commit ed7be9b

Browse files
committed
Fix ci
1 parent 40760ad commit ed7be9b

88 files changed

Lines changed: 1854 additions & 1492 deletions

File tree

Some content is hidden

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

.github/workflows/pr-validation.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,42 @@ jobs:
118118
run: |
119119
case "${{ matrix.test-type }}" in
120120
unit)
121-
bundle exec rspec spec/models spec/lib spec/services spec/serializers --format progress --format RspecJunitFormatter --out tmp/rspec-unit.xml
121+
UNIT_DIRS="spec/models spec/serializers"
122+
if [ -d "spec/lib" ]; then
123+
UNIT_DIRS="$UNIT_DIRS spec/lib"
124+
fi
125+
if [ -d "spec/services" ]; then
126+
UNIT_DIRS="$UNIT_DIRS spec/services"
127+
fi
128+
bundle exec rspec $UNIT_DIRS --format progress --format RspecJunitFormatter --out tmp/rspec-unit.xml
122129
;;
123130
integration)
124-
bundle exec rspec spec/requests spec/controllers --format progress --format RspecJunitFormatter --out tmp/rspec-integration.xml
131+
INTEGRATION_DIRS=""
132+
if [ -d "spec/requests" ]; then
133+
INTEGRATION_DIRS="$INTEGRATION_DIRS spec/requests"
134+
fi
135+
if [ -d "spec/controllers" ]; then
136+
INTEGRATION_DIRS="$INTEGRATION_DIRS spec/controllers"
137+
fi
138+
if [ -z "$INTEGRATION_DIRS" ]; then
139+
echo "No integration specs found. Skipping."
140+
exit 0
141+
fi
142+
bundle exec rspec $INTEGRATION_DIRS --format progress --format RspecJunitFormatter --out tmp/rspec-integration.xml
125143
;;
126144
system)
127-
bundle exec rspec spec/features spec/system --format progress --format RspecJunitFormatter --out tmp/rspec-system.xml
145+
SYSTEM_DIRS=""
146+
if [ -d "spec/features" ]; then
147+
SYSTEM_DIRS="$SYSTEM_DIRS spec/features"
148+
fi
149+
if [ -d "spec/system" ]; then
150+
SYSTEM_DIRS="$SYSTEM_DIRS spec/system"
151+
fi
152+
if [ -z "$SYSTEM_DIRS" ]; then
153+
echo "No system specs found. Skipping."
154+
exit 0
155+
fi
156+
bundle exec rspec $SYSTEM_DIRS --format progress --format RspecJunitFormatter --out tmp/rspec-system.xml
128157
;;
129158
esac
130159

.rubocop.yml

Lines changed: 48 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# StreamSource RuboCop Configuration
2-
# Rails-focused linting with sensible defaults
32

43
plugins:
54
- rubocop-rails
6-
- rubocop-performance
5+
- rubocop-performance
76
- rubocop-rspec
87

98
AllCops:
10-
TargetRubyVersion: 3.3
11-
TargetRailsVersion: 8.0
12-
SuggestExtensions: false
9+
TargetRubyVersion: 4.0
10+
TargetRailsVersion: 8.1
1311
NewCops: enable
12+
SuggestExtensions: false
1413
Exclude:
1514
- 'bin/**/*'
1615
- 'tmp/**/*'
@@ -23,41 +22,57 @@ AllCops:
2322
- 'public/**/*'
2423
- 'storage/**/*'
2524
- 'Gemfile.lock'
26-
- 'config/environments/production.rb'
2725
- 'config/boot.rb'
2826
- 'config/application.rb'
27+
- 'config/environments/production.rb'
2928

30-
# Project-specific overrides
3129
Rails:
3230
Enabled: true
3331

34-
# Allow longer lines for API documentation and complex queries
32+
# Keep Rails conventions; allow slightly more flexibility in specs.
3533
Layout/LineLength:
3634
Max: 120
3735
AllowedPatterns:
38-
- '\A\s*#.*\z' # Comments
39-
- '\A\s*it\s.*\z' # RSpec test descriptions
40-
- '\A\s*describe\s.*\z' # RSpec describe blocks
41-
- '\A\s*context\s.*\z' # RSpec context blocks
36+
- '\\A\\s*#.*\\z'
37+
- '\\A\\s*it\\s.*\\z'
38+
- '\\A\\s*describe\\s.*\\z'
39+
- '\\A\\s*context\\s.*\\z'
40+
41+
Style/StringLiterals:
42+
EnforcedStyle: double_quotes
43+
ConsistentQuotesInMultiline: true
44+
45+
Style/ClassAndModuleChildren:
46+
EnforcedStyle: nested
47+
48+
Style/FrozenStringLiteralComment:
49+
EnforcedStyle: never
50+
51+
Style/SingleLineMethods:
52+
AllowIfMethodIsEmpty: true
53+
54+
Style/TrailingCommaInArrayLiteral:
55+
EnforcedStyleForMultiline: comma
56+
57+
Style/TrailingCommaInHashLiteral:
58+
EnforcedStyleForMultiline: comma
59+
60+
Style/TrailingCommaInArguments:
61+
EnforcedStyleForMultiline: comma
4262

43-
# Allow longer methods for complex Rails actions and RSpec tests
4463
Metrics/MethodLength:
4564
Max: 20
4665
CountAsOne: ['array', 'heredoc']
4766
Exclude:
4867
- 'spec/**/*'
49-
- 'app/controllers/**/*'
5068
- 'config/routes.rb'
5169

52-
# Allow longer classes for controllers and models with many methods
5370
Metrics/ClassLength:
5471
Max: 150
5572
CountAsOne: ['array', 'heredoc']
5673
Exclude:
5774
- 'spec/**/*'
58-
- 'app/controllers/**/*'
5975

60-
# Allow longer blocks for RSpec and routes
6176
Metrics/BlockLength:
6277
Max: 25
6378
CountAsOne: ['array', 'heredoc']
@@ -68,120 +83,32 @@ Metrics/BlockLength:
6883
- 'Guardfile'
6984
- 'Rakefile'
7085

71-
# Disable ABC size for complex methods (often needed in Rails)
7286
Metrics/AbcSize:
73-
Enabled: false
87+
Max: 25
88+
Exclude:
89+
- 'spec/**/*'
7490

75-
# Allow complexity in controllers and specs
7691
Metrics/CyclomaticComplexity:
7792
Max: 10
7893
Exclude:
7994
- 'spec/**/*'
8095

81-
# More flexible on parameter counts for controllers
96+
Metrics/PerceivedComplexity:
97+
Max: 10
98+
Exclude:
99+
- 'spec/**/*'
100+
82101
Metrics/ParameterLists:
83102
Max: 8
84103

85-
# Allow assignment in conditions (common Rails pattern)
86-
Lint/AssignmentInCondition:
87-
Enabled: false
88-
89-
# Allow empty when (useful for case statements)
90-
Lint/EmptyWhen:
91-
Enabled: false
92-
93-
# Documentation requirements - be more lenient
94-
Style/Documentation:
95-
Enabled: false
96-
97-
# Allow compact module/class definitions
98-
Style/ClassAndModuleChildren:
99-
Enabled: false
100-
101-
# Flexible on frozen string literals (Rails handles this)
102-
Style/FrozenStringLiteralComment:
103-
Enabled: false
104-
105-
# Allow single line methods
106-
Style/SingleLineMethods:
107-
AllowIfMethodIsEmpty: true
108-
109-
# Allow guard clauses
110-
Style/GuardClause:
111-
Enabled: true
112-
113-
# Be flexible with hash syntax in Rails
114-
Style/HashSyntax:
115-
EnforcedStyle: ruby19
116-
117-
# Allow trailing commas (good for Git diffs)
118-
Style/TrailingCommaInArrayLiteral:
119-
EnforcedStyleForMultiline: comma
120-
121-
Style/TrailingCommaInHashLiteral:
122-
EnforcedStyleForMultiline: comma
123-
124-
Style/TrailingCommaInArguments:
125-
EnforcedStyleForMultiline: comma
126-
127-
# Be more flexible with string literals
128-
Style/StringLiterals:
129-
EnforcedStyle: double_quotes
130-
ConsistentQuotesInMultiline: true
131-
132-
# Allow both lambda styles
133-
Style/Lambda:
134-
Enabled: false
135-
136-
# Naming conventions
137-
Naming/VariableNumber:
138-
EnforcedStyle: snake_case
139-
140-
Naming/PredicatePrefix:
141-
ForbiddenPrefixes:
142-
- is_
143-
- have_
144-
AllowedMethods:
145-
- is_a?
104+
RSpec/ExampleLength:
105+
Max: 12
146106

147-
# Rails cops will be loaded from rubocop-rails gem
107+
RSpec/MultipleExpectations:
108+
Max: 3
148109

149-
# Performance cops will be loaded from rubocop-performance gem
150-
151-
# Security cops
152-
Security/YAMLLoad:
153-
Enabled: true
154-
155-
Security/Eval:
156-
Enabled: true
157-
158-
# RSpec cops will be loaded from rubocop-rspec gem
159-
160-
# Bundler cops
161-
Bundler/OrderedGems:
162-
Enabled: false
163-
164-
# Disable cops that conflict with Rails conventions
165-
Layout/EmptyLinesAroundAttributeAccessor:
166-
Enabled: false
167-
168-
Layout/SpaceAroundMethodCallOperator:
169-
Enabled: true
170-
171-
Lint/RaiseException:
172-
Enabled: true
173-
174-
Lint/StructNewOverride:
175-
Enabled: true
176-
177-
Style/ExponentialNotation:
178-
Enabled: true
179-
180-
Style/HashEachMethods:
181-
Enabled: true
182-
183-
Style/HashTransformKeys:
184-
Enabled: true
110+
RSpec/MultipleMemoizedHelpers:
111+
Max: 7
185112

186-
Style/HashTransformValues:
187-
Enabled: true
113+
RSpec/NestedGroups:
114+
Max: 4

Gemfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ gem "image_processing"
5454
gem "rack-cors"
5555

5656
# Authentication
57-
gem "jwt"
5857
gem "devise"
5958
gem "devise-jwt"
59+
gem "jwt"
6060

6161
# Authorization
6262
gem "pundit"
@@ -89,19 +89,22 @@ group :development, :test do
8989
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
9090
gem "brakeman", require: false
9191

92+
# Performance profiling for CI performance checks
93+
gem "memory_profiler", require: false
94+
9295
# Ruby style guide enforcement
9396
gem "rubocop", require: false
94-
gem "rubocop-rails", require: false
9597
gem "rubocop-performance", require: false
98+
gem "rubocop-rails", require: false
9699
gem "rubocop-rspec", require: false
97100

98101
# Testing
99-
gem "rspec-rails"
102+
gem "database_cleaner-active_record"
100103
gem "factory_bot_rails"
101104
gem "faker"
102-
gem "shoulda-matchers"
103-
gem "database_cleaner-active_record"
104105
gem "rails-controller-testing"
106+
gem "rspec-rails"
107+
gem "shoulda-matchers"
105108
end
106109

107110
group :development do
@@ -115,8 +118,8 @@ end
115118
group :test do
116119
gem "rswag-specs"
117120
gem "simplecov", require: false
118-
gem "webmock"
119121
gem "vcr"
122+
gem "webmock"
120123
end
121124

122125
# Performance monitoring

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ GEM
204204
net-pop
205205
net-smtp
206206
marcel (1.1.0)
207+
memory_profiler (1.1.0)
207208
mini_magick (5.3.1)
208209
logger
209210
mini_mime (1.1.5)
@@ -459,6 +460,7 @@ DEPENDENCIES
459460
jsbundling-rails
460461
jwt
461462
lograge
463+
memory_profiler
462464
ostruct
463465
pagy
464466
pg

app/channels/application_cable/connection.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module ApplicationCable
2+
# Handles ActionCable connection authentication.
23
class Connection < ActionCable::Connection::Base
34
identified_by :current_user
45

@@ -14,13 +15,13 @@ def find_verified_user
1415

1516
if token.present?
1617
decoded = JsonWebToken.decode(token)
17-
if verified_user = User.find_by(id: decoded["user_id"])
18+
if (verified_user = User.find_by(id: decoded["user_id"]))
1819
return verified_user
1920
end
2021
end
2122

2223
# Fall back to session-based auth
23-
if verified_user = User.find_by(id: cookies.encrypted[:user_id])
24+
if (verified_user = User.find_by(id: cookies.encrypted[:user_id]))
2425
return verified_user
2526
end
2627

app/channels/application_channel.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Base ActionCable channel behavior.
12
class ApplicationChannel < ApplicationCable::Channel
23
def subscribed
34
# stream_from "some_channel"

0 commit comments

Comments
 (0)