Skip to content

Commit 4aac3de

Browse files
committed
complete overhaul of app to use vite / remove webpacker / upgrade ruby & rails / add playwright
1 parent 9ff40b2 commit 4aac3de

Some content is hidden

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

56 files changed

+3901
-7492
lines changed

.github/workflows/test.yml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: Rails Tests with Playwright
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
env:
10+
RAILS_ENV: test
11+
NODE_ENV: test
12+
DATABASE_URL: postgres://postgres:postgres@localhost:5432/quik_course_test
13+
REDIS_URL: redis://localhost:6379/0
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
19+
services:
20+
postgres:
21+
image: postgres:15
22+
env:
23+
POSTGRES_USER: postgres
24+
POSTGRES_PASSWORD: postgres
25+
POSTGRES_DB: quik_course_test
26+
ports:
27+
- 5432:5432
28+
options: >-
29+
--health-cmd pg_isready
30+
--health-interval 10s
31+
--health-timeout 5s
32+
--health-retries 5
33+
34+
redis:
35+
image: redis:7-alpine
36+
ports:
37+
- 6379:6379
38+
options: >-
39+
--health-cmd "redis-cli ping"
40+
--health-interval 10s
41+
--health-timeout 5s
42+
--health-retries 5
43+
44+
steps:
45+
- name: Checkout code
46+
uses: actions/checkout@v4
47+
48+
- name: Set up Ruby
49+
uses: ruby/setup-ruby@v1
50+
with:
51+
ruby-version: 3.4.7
52+
bundler-cache: true
53+
54+
- name: Set up Node.js
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: '20'
58+
cache: 'yarn'
59+
60+
- name: Install dependencies
61+
run: |
62+
bundle install --jobs 4 --retry 3
63+
yarn install --frozen-lockfile
64+
65+
- name: Install Playwright browsers
66+
run: npx playwright install --with-deps
67+
68+
- name: Set up database
69+
run: |
70+
bin/rails db:create db:schema:load db:seed
71+
72+
- name: Build assets
73+
run: bin/vite build
74+
75+
- name: Run RSpec tests (non-system)
76+
run: bundle exec rspec --exclude-pattern "spec/system/**/*"
77+
78+
- name: Run Playwright system tests
79+
run: |
80+
# Start Rails server in background for testing
81+
RAILS_ENV=test bin/rails server -p 3001 -d
82+
83+
# Wait for server to start
84+
sleep 10
85+
86+
# Run RSpec system tests with Playwright
87+
bundle exec rspec spec/system/playwright --format documentation
88+
89+
# Stop Rails server
90+
pkill -f "rails server"
91+
env:
92+
PLAYWRIGHT_BASE_URL: http://localhost:3001
93+
PLAYWRIGHT_HEADLESS: true
94+
95+
- name: Upload Playwright artifacts
96+
uses: actions/upload-artifact@v4
97+
if: failure()
98+
with:
99+
name: playwright-results
100+
path: |
101+
tmp/screenshots/
102+
tmp/playwright-report/
103+
tmp/playwright-results.json
104+
retention-days: 7
105+
106+
- name: Upload test coverage
107+
if: always()
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: coverage-report
111+
path: coverage/
112+
retention-days: 7
113+
114+
lint:
115+
runs-on: ubuntu-latest
116+
steps:
117+
- name: Checkout code
118+
uses: actions/checkout@v4
119+
120+
- name: Set up Ruby
121+
uses: ruby/setup-ruby@v1
122+
with:
123+
ruby-version: 3.4.7
124+
bundler-cache: true
125+
126+
- name: Set up Node.js
127+
uses: actions/setup-node@v4
128+
with:
129+
node-version: '20'
130+
cache: 'yarn'
131+
132+
- name: Install dependencies
133+
run: |
134+
bundle install --jobs 4 --retry 3
135+
yarn install --frozen-lockfile
136+
137+
- name: Run RuboCop
138+
run: bundle exec rubocop --parallel
139+
140+
- name: Run Brakeman security scan
141+
run: bundle exec brakeman --no-pager
142+
143+
- name: Run Bundle Audit
144+
run: bundle exec bundle-audit check --update
145+
146+
build:
147+
runs-on: ubuntu-latest
148+
steps:
149+
- name: Checkout code
150+
uses: actions/checkout@v4
151+
152+
- name: Set up Node.js
153+
uses: actions/setup-node@v4
154+
with:
155+
node-version: '20'
156+
cache: 'yarn'
157+
158+
- name: Install dependencies
159+
run: yarn install --frozen-lockfile
160+
161+
- name: Build assets
162+
run: yarn build
163+
164+
- name: Upload build artifacts
165+
uses: actions/upload-artifact@v4
166+
with:
167+
name: vite-assets
168+
path: public/vite/
169+
retention-days: 1

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--require spec_helper

.rubocop.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require:
2+
- rubocop-rails
3+
- rubocop-performance
4+
5+
AllCops:
6+
TargetRubyVersion: 3.4
7+
NewCops: enable
8+
Exclude:
9+
- 'db/**/*'
10+
- 'config/**/*'
11+
- 'bin/**/*'
12+
- 'node_modules/**/*'
13+
- 'tmp/**/*'
14+
- 'vendor/**/*'
15+
- 'log/**/*'
16+
- 'storage/**/*'
17+
18+
Style/Documentation:
19+
Enabled: false
20+
21+
Metrics/MethodLength:
22+
Max: 15
23+
24+
Metrics/BlockLength:
25+
Exclude:
26+
- 'spec/**/*'
27+
- 'config/routes.rb'
28+
29+
Layout/LineLength:
30+
Max: 120

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby-3.1.2
1+
3.4.7

Gemfile

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
source 'https://rubygems.org'
22
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
33

4-
ruby '3.2.0'
4+
ruby '3.4.7'
55

66
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
7-
gem 'rails', '6.1.7.2'
7+
gem 'rails', '8.0.3'
88
# Use postgresql as the database for Active Record
99
gem 'pg', '~> 1.1'
1010
# Use Puma as the app server
11-
gem 'puma', '~> 5.0'
11+
gem 'puma', '~> 6.0'
1212
# Use SCSS for stylesheets
13-
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
14-
gem 'webpacker', '~> 5.0'
15-
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
16-
gem 'turbolinks', '~> 5'
13+
# Use Vite for frontend asset management
14+
gem 'vite_rails'
15+
# Turbo makes navigating your web application faster. Read more: https://hotwired.dev
16+
gem 'turbo-rails', '~> 2.0'
17+
gem 'stimulus-rails', '~> 1.3'
1718
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
18-
gem 'jbuilder', '~> 2.7'
19-
# Use Redis adapter to run Action Cable in production
20-
# gem 'redis', '~> 4.0'
19+
gem 'jbuilder', '~> 2.12'
20+
# Use Redis adapter to run Action Cable in production and caching
21+
gem 'redis', '~> 5.0'
22+
gem 'hiredis', '~> 0.6.3' # Faster Redis client
2123
# Use Active Model has_secure_password
2224
# gem 'bcrypt', '~> 3.1.7'
2325

@@ -30,6 +32,11 @@ gem 'bootsnap', '>= 1.4.4', require: false
3032
group :development, :test do
3133
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
3234
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
35+
36+
# Modern Testing Framework
37+
gem 'rspec-rails', '~> 6.1'
38+
gem 'factory_bot_rails', '~> 6.4'
39+
gem 'shoulda-matchers', '~> 6.0'
3340
end
3441

3542
group :development do
@@ -49,26 +56,55 @@ group :test do
4956
gem 'selenium-webdriver', '>= 4.0.0.rc1'
5057
# Easy installation and use of web drivers to run system tests with browsers
5158
gem 'webdrivers'
59+
# Playwright integration for modern end-to-end testing
60+
gem 'playwright-ruby-client', '~> 1.44'
5261
end
5362

5463
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
5564
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
5665

5766
group :development do
5867
gem "ruby-lsp", require: false
68+
69+
# Code Quality & Security
70+
gem 'rubocop', '~> 1.60', require: false
71+
gem 'rubocop-rails', '~> 2.23', require: false
72+
gem 'rubocop-performance', '~> 1.20', require: false
73+
gem 'brakeman', '~> 6.0', require: false
74+
gem 'bundle-audit', '~> 0.1.0', require: false
75+
gem 'rails_best_practices', '~> 1.23', require: false
76+
77+
# Performance monitoring (development)
78+
gem 'bullet', '~> 8.0' # N+1 query detection (Rails 8 compatible)
5979
end
6080

6181
gem 'net-smtp'
6282
gem 'erb-formatter'
6383
gem 'haml-rails'
6484
gem 'simple_form'
6585
gem 'faker'
66-
gem 'devise'
86+
gem 'devise', '~> 4.9'
6787
gem 'friendly_id'
68-
gem 'ransack'
88+
89+
# Modern Security & Authentication
90+
gem 'devise-two-factor', '~> 6.1' # 2FA support (Rails 8 compatible)
91+
gem 'rqrcode', '~> 2.0' # QR codes for 2FA
92+
gem 'rack-attack', '~> 6.7' # Rate limiting
93+
gem 'secure_headers', '~> 6.5' # Security headers
94+
gem 'ransack', '~> 4.0'
6995
gem 'public_activity'
7096
gem 'rolify'
7197
gem 'pundit'
7298
gem 'pagy'
7399

100+
# Modern CSS & Performance
74101
gem "dartsass-rails", "~> 0.4.0"
102+
gem 'image_processing', '~> 1.2' # For Active Storage variants
103+
104+
# API & Serialization
105+
gem 'fast_jsonapi', '~> 1.5'
106+
107+
# Performance & Monitoring
108+
# Note: redis-rails not needed in Rails 8 - Redis integration is built-in
109+
gem 'skylight', '~> 6.0' # Performance monitoring (comment out if using New Relic)
110+
# gem 'newrelic_rpm' # Alternative: New Relic (uncomment if preferred)

0 commit comments

Comments
 (0)