name: CI
-
on:
- pull_request:
push:
- branches: [ main ]
-
+ branches: [main]
+ pull_request:
+ branches: [main]
jobs:
scan_ruby:
runs-on: ubuntu-latest
-
steps:
- name: Checkout code
uses: actions/checkout@v4
-
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
-
- name: Scan for common Rails security vulnerabilities using static analysis
run: bin/brakeman --no-pager
- scan_js:
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout code
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- ruby-version: .ruby-version
- bundler-cache: true
-
- - name: Scan for security vulnerabilities in JavaScript dependencies
- run: bin/importmap audit
-
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
-
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
-
- name: Lint code for consistent style
run: bin/rubocop -f github
test:
runs-on: ubuntu-latest
-
services:
mysql:
- image: mysql
+ image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
- # redis:
- # image: redis
- # ports:
- # - 6379:6379
- # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
-
steps:
- name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl default-mysql-client libjemalloc2 libvips
ruby-version: .ruby-version
bundler-cache: true
- - name: Run tests
+ - name: Setup test database and run tests
env:
RAILS_ENV: test
DATABASE_URL: mysql2://127.0.0.1:3306
# REDIS_URL: redis://localhost:6379/0
- run: bin/rails db:test:prepare test test:system
+ ENCRYPTION_PRIMARY_KEY: ${{ secrets.ENCRYPTION_PRIMARY_KEY || 'test_primary_key_1234567890' }}
+ ENCRYPTION_DETERMINISTIC_KEY: ${{ secrets.ENCRYPTION_DETERMINISTIC_KEY || 'test_deterministic_key_1234567890' }}
+ ENCRYPTION_KEY_DERIVATION_SALT: ${{ secrets.ENCRYPTION_KEY_DERIVATION_SALT || 'test_derivation_salt_1234567890' }}
+ run: |
+ bin/rails db:test:prepare
+ bin/rails test test:system
- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
+
+AllCops:
+ NewCops: enable
+ TargetRubyVersion: 3.2
+
+# Disable checks for trailing empty lines
+Layout/TrailingEmptyLines:
+ Enabled: false
+
+# Disable checks for comment spacing
+Layout/LeadingCommentSpace:
+ Enabled: false
+
+# Allow both tabs and spaces
+Layout/IndentationStyle:
+ Enabled: false
+
+# You might want to disable more rules that you don't care about
+Style/Documentation:
+ Enabled: false
+
+Style/FrozenStringLiteralComment:
+ Enabled: false
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
+ config.active_record.encryption.primary_key = ENV.fetch('ENCRYPTION_PRIMARY_KEY') { 'test' * 8 }
+ config.active_record.encryption.deterministic_key = ENV.fetch('ENCRYPTION_DETERMINISTIC_KEY') { 'test' * 8 }
+ config.active_record.encryption.key_derivation_salt = ENV.fetch('ENCRYPTION_KEY_DERIVATION_SALT') { 'test' * 8 }
+
# While tests run files are not watched, reloading is not necessary.
config.enable_reloading = false
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
-
+
# Turn off captcha stuff for localhost
config.hcaptcha_enabled = false
-
+
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true