Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions CI + Rubocop enforcement #86

Merged
merged 5 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "weekly"
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Tests

on:
pull_request:
branches:
- '*'
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports: ['5432:5432']
redis:
image: redis
ports: ['6379:6379']
options: --entrypoint redis-server

steps:
- uses: actions/checkout@v3

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler: default
bundler-cache: true

- name: Precompile assets
run: RAILS_ENV=test bundle exec rake assets:precompile

- name: Use sample application.yml file
run: mv config/application-sample.yml config/application.yml

- name: Rubocop Check
run: bundle exec rubocop

- name: Run tests
env:
DATABASE_URL: postgres://postgres:password@localhost:5432/test
REDIS_URL: redis://localhost:6379/0
RAILS_ENV: test
PG_USER: postgres
run: |
bundle exec rails db:drop db:create db:schema:load RAILS_ENV=test
bundle exec rspec spec/
98 changes: 98 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
inherit_mode:
merge:
- Exclude

AllCops:
TargetRubyVersion: 3.2
DisplayCopNames: true
Exclude:
- bin/*
- tmp/**/*
- db/schema.rb
- vendor/*/**
SuggestExtensions:
rubocop-capybara: true
rubocop-factory_bot: true
rubocop-rails: true
rubocop-rspec: true


Layout/EmptyLinesAroundClassBody:
Enabled: false

Layout/HashAlignment:
Enabled: true

Lint/ConstantDefinitionInBlock:
Enabled: false

Metrics/ClassLength:
Enabled: false

Naming/VariableNumber:
Enabled: false

Naming/MemoizedInstanceVariableName:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/Documentation:
Enabled: false

Style/GuardClause:
Enabled: false

Style/HashSyntax:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

Style/NumericLiterals:
Enabled: false

Style/RedundantFreeze:
Enabled: false

Style/RedundantSelf:
Enabled: false

Style/StringLiterals:
Enabled: false

Style/SymbolArray:
Enabled: false

Style/WordArray:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false

Metrics/CyclomaticComplexity:
Max: 20

Metrics/MethodLength:
Max: 60

Metrics/BlockLength:
Enabled: false

Metrics/AbcSize:
Max: 50

Metrics/PerceivedComplexity:
Max: 20

Layout/LineLength:
Severity: warning
Max: 250

Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

# Global variable is the only way to subscribe for more tickers in the websocket connection between Rails <-> Polygon
Style/GlobalVars:
Enabled: false
51 changes: 28 additions & 23 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,55 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.2.0'

gem 'rails', '7.1.0'
gem 'sprockets-rails'
gem 'pg'
gem 'puma', '6'
gem 'chartkick'
gem 'delayed' # delayed_job_active_record rails 7 fork: https://github.com/betterment/delayed
gem 'devise'
gem 'figaro', git: 'https://github.com/ryanckulp/figaro' # patched version for Ruby 3.2.0 File.exist?()
gem 'groupdate' # used by Chartkick
gem 'httparty'
gem 'importmap-rails'
gem 'turbo-rails'
gem 'stimulus-rails'
gem 'tailwindcss-rails'
gem 'jbuilder'
gem 'redis'
gem 'httparty'
gem 'figaro', git: 'https://github.com/ryanckulp/figaro' # patched version for Ruby 3.2.0 File.exist?()
gem 'rename', '1.1.3', git: 'https://github.com/ryanckulp/rename' # remove this gem after use
gem 'delayed' # delayed_job_active_record rails 7 fork: https://github.com/betterment/delayed
gem 'metamagic' # easily insert metatags for SEO / opengraph
gem 'rack-cors', :require => 'rack/cors'
gem 'pg'
gem 'postmark-rails'
gem 'devise'
gem 'puma', '6'
gem 'rack-cors', :require => 'rack/cors'
gem 'rails', '7.1.0'
gem 'redis'
gem 'rename', '1.1.3', git: 'https://github.com/ryanckulp/rename' # remove this gem after use
gem 'sprockets-rails'
gem 'stimulus-rails'
gem 'stripe'
gem 'chartkick'
gem 'groupdate' # used by Chartkick
gem 'tailwindcss-rails'
gem 'turbo-rails'

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

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false

group :development, :test do
gem 'debug', platforms: %i[ mri mingw x64_mingw ]
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'rubocop', require: false # code styling
gem 'rubocop-capybara', require: false
gem 'rubocop-factory_bot', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
end

group :development do
gem 'web-console'
gem 'letter_opener' # view mailers in browser
gem 'web-console'
end

group :test do
gem 'capybara'
gem 'selenium-webdriver'
gem 'webdrivers'
gem 'rspec-rails', '6.0.3'
gem 'factory_bot_rails'
gem 'faker'
gem 'rspec-rails', '6.0.3'
gem 'selenium-webdriver'
gem 'shoulda-callback-matchers'
gem 'shoulda-matchers'
gem 'faker'
gem 'webdrivers'
end
45 changes: 45 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.1.1)
bcrypt (3.1.19)
bigdecimal (3.1.4)
Expand Down Expand Up @@ -156,6 +157,7 @@ GEM
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
launchy (2.5.2)
addressable (~> 2.8)
letter_opener (1.8.1)
Expand Down Expand Up @@ -189,7 +191,13 @@ GEM
nio4r (2.5.9)
nokogiri (1.15.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.4-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
pg (1.5.4)
postmark (1.24.1)
json
Expand Down Expand Up @@ -241,6 +249,7 @@ GEM
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.0.6)
rdoc (6.5.0)
psych (>= 4.0.0)
Expand Down Expand Up @@ -272,6 +281,33 @@ GEM
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.1)
rubocop (1.56.4)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-rails (2.21.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-rspec (2.24.1)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
selenium-webdriver (4.10.0)
Expand All @@ -295,6 +331,8 @@ GEM
stripe (9.4.0)
tailwindcss-rails (2.0.30-x86_64-darwin)
railties (>= 6.0.0)
tailwindcss-rails (2.0.30-x86_64-linux)
railties (>= 6.0.0)
thor (1.2.2)
timeout (0.4.0)
turbo-rails (1.4.0)
Expand All @@ -303,6 +341,7 @@ GEM
railties (>= 6.0.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
Expand All @@ -325,6 +364,7 @@ GEM

PLATFORMS
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
bootsnap
Expand All @@ -350,6 +390,11 @@ DEPENDENCIES
redis
rename (= 1.1.3)!
rspec-rails (= 6.0.3)
rubocop
rubocop-capybara
rubocop-factory_bot
rubocop-rails
rubocop-rspec
selenium-webdriver
shoulda-callback-matchers
shoulda-matchers
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ class AccountController < ApplicationController
before_action :authenticate_user!
before_action :set_flashes

def index
end
def index; end

def update
current_user.update(account_update_params)
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ class Admin::UsersController < ApplicationController
before_action :authenticate_user!
before_action :set_user

def edit
end
def edit; end

def update
@user.update(user_params)
Expand Down
5 changes: 1 addition & 4 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ class ApplicationController < ActionController::Base

def after_sign_in_path_for(resource)
resource.paying_customer? ? dashboard_index_path : subscribe_index_path # point these wherever you want
end
end

def maybe_skip_onboarding
redirect_to dashboard_index_path, notice: "You're already subscribed" if current_user.finished_onboarding?
end


protected

# whitelist extra User model params by uncommenting below and adding User attrs as keys
# def configure_permitted_parameters
# devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ class DashboardController < ApplicationController
before_action :authenticate_user!
before_action :set_flashes

def index
end
def index; end

private

Expand Down
Loading