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

Inertia #38

Merged
merged 10 commits into from
Aug 26, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 24 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ESLint
on: [push]
jobs:
eslint:
runs-on: ubuntu-latest

env:
RAILS_ENV: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.17.0"
cache: "npm"

- name: Install JS dependencies
run: npm install --legacy-peer-deps

- name: Run Linter
run: npx eslint -c eslint.config.js .
56 changes: 36 additions & 20 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,47 @@ on: [push]
jobs:
run-rspec-tests:
runs-on: ubuntu-latest

env:
RAILS_ENV: test
VAPID_PUBLIC_KEY: BCUWtDYeou4CLLwWUu44NylAkAkPYNobTJ7wuWhvjBb0YF4JhJAT_GeUrOjJvoXvcTO4ehmeCHyP0QH2mS5cyj4 # testing only
VAPID_PRIVATE_KEY: WE83Oc3c1GaC08gcEM2YKddtTpx0DdrjEfTHONVqR0s # testing only
SWAY_DATABASE_PASSWORD: testing123! # testing only

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby and install gems
uses: ruby/setup-ruby@v1
with:
# Not needed with a .ruby-version file
ruby-version: 3.3.1
# runs 'bundle install' and caches installed gems automatically
ruby-version: "3.3.4"
bundler-cache: true

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.17.0"
cache: "npm"

- name: Install JS dependencies
run: npm install --legacy-peer-deps

- name: Precompile assets
run: npm run build

- name: Set up database
env:
RAILS_ENV: test
VAPID_PUBLIC_KEY: BCUWtDYeou4CLLwWUu44NylAkAkPYNobTJ7wuWhvjBb0YF4JhJAT_GeUrOjJvoXvcTO4ehmeCHyP0QH2mS5cyj4 # testing only
VAPID_PRIVATE_KEY: WE83Oc3c1GaC08gcEM2YKddtTpx0DdrjEfTHONVqR0s # testing only
SWAY_DATABASE_PASSWORD: testing123! # testing only
run: | # multi-line run command: https://stackoverflow.com/a/66809682/6410635
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:schema:load
bundle exec rails db:seed
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:schema:load
bundle exec rails db:seed

- name: Set up certs
run: | # multi-line run command: https://stackoverflow.com/a/66809682/6410635
mv config/ssl/github-cert.pem config/ssl/cert.pem
mv config/ssl/github-key.pem config/ssl/key.pem

- name: Run tests
env:
RAILS_ENV: test
VAPID_PUBLIC_KEY: BCUWtDYeou4CLLwWUu44NylAkAkPYNobTJ7wuWhvjBb0YF4JhJAT_GeUrOjJvoXvcTO4ehmeCHyP0QH2mS5cyj4 # testing only
VAPID_PRIVATE_KEY: WE83Oc3c1GaC08gcEM2YKddtTpx0DdrjEfTHONVqR0s # testing only
SWAY_DATABASE_PASSWORD: testing123! # testing only
run: | # multi-line run command: https://stackoverflow.com/a/66809682/6410635
bundle exec rspec
bundle exec rspec
24 changes: 24 additions & 0 deletions .github/workflows/typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Typescript
on: [push]
jobs:
tsc:
runs-on: ubuntu-latest

env:
RAILS_ENV: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.17.0"
cache: "npm"

- name: Install JS dependencies
run: npm install --legacy-peer-deps

- name: Run Typescript tsc
run: npx tsc --project tsconfig.json
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@

# Ignore master key for decrypting credentials and more.
/config/master.key
/config/ssl/
/config/keys/
/config/ssl/
!/config/ssl/github-cert.pem
!/config/ssl/github-key.pem

# Vite Ruby
/public/vite*
Expand Down
21 changes: 21 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env zsh

set -eu

changed_files=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')

echo "Running prettier on changed files"
npx prettier $changed_files --write --ignore-unknown

echo "Run ESLint on changed files"
npx eslint -c eslint.config.js --no-warn-ignored $changed_files

echo "Run tsc on project"
npx tsc --project tsconfig.json

echo "Run rubocop on changed files, autofix any fixable offenses"
bundle exec rubocop --autocorrect --only-recognized-file-types $changed_files

bundle exec annotate --models

git update-index --again
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.12.2
v20.17.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.12.2
v20.17.0
22 changes: 22 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
inherit_mode:
merge:
- Exclude

require:
- standard
- rubocop-performance

inherit_gem:
standard: config/base.yml
standard-performance: config/base.yml
standard-custom: config/base.yml

inherit_from:
- .rubocop/rails.yml
- .rubocop/rspec.yml
- .rubocop/strict.yml

AllCops:
NewCops: disable
SuggestExtensions: false
TargetRubyVersion: 3.2
198 changes: 198 additions & 0 deletions .rubocop/rails.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
# Based on removed standard configuration:
# https://github.com/testdouble/standard/commit/94d133f477a5694084ac974d5ee01e8a66ce777e#diff-65478e10d5b2ef41c7293a110c0e6b7c

require:
- rubocop-rails

Rails/ActionFilter:
Enabled: true
EnforcedStyle: action
Include:
- app/controllers/**/*.rb

Rails/ActiveRecordAliases:
Enabled: true

Rails/ActiveSupportAliases:
Enabled: true

Rails/ApplicationJob:
Enabled: true

Rails/ApplicationRecord:
Enabled: true

Rails/AssertNot:
Enabled: true
Include:
- "**/test/**/*"

Rails/Blank:
Enabled: true
# Convert usages of `nil? || empty?` to `blank?`
NilOrEmpty: true
# Convert usages of `!present?` to `blank?`
NotPresent: true
# Convert usages of `unless present?` to `if blank?`
UnlessPresent: true

Rails/BulkChangeTable:
Enabled: true
Database: null
Include:
- db/migrate/*.rb

Rails/CreateTableWithTimestamps:
Enabled: true
Include:
- db/migrate/*.rb

Rails/Date:
Enabled: true
EnforcedStyle: flexible

Rails/Delegate:
Enabled: true
EnforceForPrefixed: true

Rails/DelegateAllowBlank:
Enabled: true

Rails/DynamicFindBy:
Enabled: true
Whitelist:
- find_by_sql

Rails/EnumUniqueness:
Enabled: true
Include:
- app/models/**/*.rb

Rails/EnvironmentComparison:
Enabled: true

Rails/Exit:
Enabled: true
Include:
- app/**/*.rb
- config/**/*.rb
- lib/**/*.rb
Exclude:
- lib/**/*.rake

Rails/FilePath:
Enabled: true
EnforcedStyle: arguments

Rails/FindBy:
Enabled: true
Include:
- app/models/**/*.rb

Rails/FindEach:
Enabled: true
Include:
- app/models/**/*.rb

Rails/HasAndBelongsToMany:
Enabled: true
Include:
- app/models/**/*.rb

Rails/HttpPositionalArguments:
Enabled: true
Include:
- "spec/**/*"
- "test/**/*"

Rails/HttpStatus:
Enabled: true
EnforcedStyle: symbolic

Rails/InverseOf:
Enabled: true
Include:
- app/models/**/*.rb

Rails/LexicallyScopedActionFilter:
Enabled: true
Safe: false
Include:
- app/controllers/**/*.rb

Rails/NotNullColumn:
Enabled: true
Include:
- db/migrate/*.rb

Rails/Output:
Enabled: true
Include:
- app/**/*.rb
- config/**/*.rb
- db/**/*.rb
- lib/**/*.rb

Rails/OutputSafety:
Enabled: true

Rails/PluralizationGrammar:
Enabled: true

Rails/Presence:
Enabled: true

Rails/Present:
Enabled: true
NotNilAndNotEmpty: true
NotBlank: true
UnlessBlank: true

Rails/ReadWriteAttribute:
Enabled: true
Include:
- app/models/**/*.rb

Rails/RedundantReceiverInWithOptions:
Enabled: true

Rails/RefuteMethods:
Enabled: true
Include:
- "**/test/**/*"

Rails/RelativeDateConstant:
Enabled: true
AutoCorrect: false

Rails/RequestReferer:
Enabled: true
EnforcedStyle: referer

Rails/ReversibleMigration:
Enabled: true
Include:
- db/migrate/*.rb

Rails/SafeNavigation:
Enabled: true
ConvertTry: false

Rails/ScopeArgs:
Enabled: true
Include:
- app/models/**/*.rb

Rails/TimeZone:
Enabled: true
EnforcedStyle: flexible

Rails/UniqBeforePluck:
Enabled: true
EnforcedStyle: conservative
AutoCorrect: false

Rails/Validation:
Enabled: true
Include:
- app/models/**/*.rb
Loading