Ensure before actions run on root route #3164
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
env: | |
BUNDLE_JOBS: 4 | |
BUNDLE_RETRY: 3 | |
BUNDLE_PATH: vendor/bundle | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Dependencies | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
rubygems: latest | |
# Lint | |
- name: Run linter | |
run: bin/lint --nofix | |
development_environment: | |
name: Development Environment | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
env: | |
PGHOST: localhost | |
PGUSER: good_job | |
BUNDLE_JOBS: 4 | |
BUNDLE_RETRY: 3 | |
BUNDLE_PATH: vendor/bundle | |
DISABLE_SPRING: 1 | |
services: | |
postgres: | |
image: postgres:16 | |
env: | |
POSTGRES_USER: good_job | |
POSTGRES_DB: good_job_test | |
POSTGRES_PASSWORD: "" | |
POSTGRES_HOST_AUTH_METHOD: trust | |
ports: [ "5432:5432" ] | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Dependencies | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
rubygems: latest | |
# Validate Development Environment | |
- name: bin/setup | |
run: bin/rails db:test:prepare | |
- name: bin/rspec | |
run: bin/rspec --require ./spec/support/pre_documentation_formatter.rb --format PreDocumentationFormatter | |
# Archive | |
- name: Archive system spec screenshots | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: screenshots | |
path: | | |
demo/tmp/screenshots | |
demo/tmp/capybara | |
- name: Archive Rails logs | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: rails_logs | |
path: demo/log | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
timeout-minutes: 20 | |
strategy: | |
fail-fast: false | |
matrix: | |
ruby: ["3.0", 3.1, 3.2, 3.3] | |
pg: [16] | |
include: | |
- ruby: 3.3 | |
pg: 10 | |
env: | |
PGHOST: localhost | |
PGUSER: good_job | |
RAILS_ENV: test | |
BUNDLE_JOBS: 4 | |
BUNDLE_RETRY: 3 | |
BUNDLE_PATH: vendor/bundle | |
BUNDLE_WITHOUT: debug:lint:demo:production | |
RAILS_LOG_TO_STDOUT: false | |
services: | |
postgres: | |
image: postgres:${{ matrix.pg }} | |
env: | |
POSTGRES_USER: good_job | |
POSTGRES_DB: good_job_test | |
POSTGRES_PASSWORD: "" | |
POSTGRES_HOST_AUTH_METHOD: trust | |
ports: ["5432:5432"] | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: browser-actions/setup-chrome@latest | |
- run: chrome --version | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Update .ruby-version with matrix value | |
run: echo "${{ matrix.ruby }}" >| .ruby-version | |
- name: Set Rubygems version | |
id: rubygems | |
run: | | |
if [[ "${{ matrix.ruby }}" == "2.6" || "${{ matrix.ruby }}" == "2.7" || "${{ matrix.ruby }}" == "jruby-9.3" ]]; then | |
echo "version=3.3.27" >> $GITHUB_OUTPUT | |
else | |
echo "version=latest" >> $GITHUB_OUTPUT | |
fi | |
# Dependencies | |
- name: Remove Gemfile.lock | |
run: rm Gemfile.lock | |
- name: Set up generic Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: false | |
- name: Recreate Gemfile.lock | |
run: bundle lock --update && cat Gemfile.lock | |
- name: Set up Ruby and bundle install | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
rubygems: ${{ steps.rubygems.outputs.version }} | |
- name: Generate Appraisal Gemfile.lock files | |
run: | | |
bundle exec appraisal bundle lock --update | |
- name: Cache Appraisal gems | |
uses: actions/cache@v4 | |
with: | |
path: gemfiles/vendor/bundle | |
key: v1-bundler-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('Gemfile.lock', 'gemfiles/*.gemfile.lock') }} | |
restore-keys: | | |
v1-bundler-${{ runner.os }}-${{ matrix.ruby }}- | |
- name: Install Appraisal gems | |
run: bundle exec appraisal install | |
# Test | |
- name: Set up test database | |
run: bundle exec appraisal demo/bin/rails db:test:prepare | |
- name: Run Unit tests | |
run: | | |
bundle exec appraisal rspec --exclude-pattern "spec/system/**/*_spec.rb, spec/generators/**/*_spec.rb" \ | |
--require ./spec/support/pre_documentation_formatter.rb \ | |
--format PreDocumentationFormatter | |
- name: Run System tests | |
if: ${{ !contains(matrix.ruby, 'jruby') }} | |
run: | | |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \ | |
--format PreDocumentationFormatter \ | |
spec/system | |
- name: Run Generators tests | |
run: | | |
bundle exec appraisal rspec --require ./spec/support/pre_documentation_formatter.rb \ | |
--format PreDocumentationFormatter \ | |
spec/generators | |
# Archive | |
- name: Archive system spec screenshots | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: screenshots | |
path: | | |
demo/tmp/screenshots | |
demo/tmp/capybara | |
- name: Archive Rails logs | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: rails_logs | |
path: demo/log |