9fd38cae5e
System specs have been available since Rails 5.1, and are better integrated with the Rails framework. - Rename `spec/features` to `spec/system` - Rename `feature do` to `describe do` - Configure Capybara for system specs Steps mostly taken from https://medium.com/table-xi/a-quick-guide-to-rails-system-tests-in-rspec-b6e9e8a8b5f6
108 lines
2.8 KiB
YAML
108 lines
2.8 KiB
YAML
name: Continuous Integration
|
|
on:
|
|
push:
|
|
branches: 'main'
|
|
pull_request:
|
|
branches: 'main'
|
|
|
|
jobs:
|
|
linters:
|
|
name: Linters
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
bundler-cache: true
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '14'
|
|
- name: Find yarn cache location
|
|
id: yarn-cache
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
- name: JS package cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ steps.yarn-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-
|
|
- name: Install packages
|
|
run: |
|
|
yarn install --frozen-lockfile
|
|
|
|
- name: Run linters
|
|
run: |
|
|
bundle exec rake lint
|
|
|
|
tests:
|
|
name: Tests
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
postgres:
|
|
image: postgres:12
|
|
env:
|
|
POSTGRES_USER: tps_test
|
|
POSTGRES_DB: tps_test
|
|
POSTGRES_PASSWORD: tps_test
|
|
ports: ["5432:5432"]
|
|
|
|
strategy:
|
|
matrix:
|
|
pattern:
|
|
- bin/rake zeitwerk:check
|
|
- bin/rspec spec/controllers/*_spec.rb
|
|
- bin/rspec spec/controllers/[a-l]**/*_spec.rb
|
|
- bin/rspec spec/controllers/[m-z]**/*_spec.rb
|
|
- bin/rspec spec/system
|
|
- bin/rspec spec/helpers spec/lib spec/middlewares
|
|
- bin/rspec spec/mailers spec/jobs spec/policies
|
|
- bin/rspec spec/models
|
|
- bin/rspec spec/serializers spec/services
|
|
- bin/rspec spec/views
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup Ruby
|
|
uses: ruby/setup-ruby@v1
|
|
with:
|
|
bundler-cache: true
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v2
|
|
with:
|
|
node-version: '14'
|
|
- name: Find yarn cache location
|
|
id: yarn-cache
|
|
run: echo "::set-output name=dir::$(yarn cache dir)"
|
|
- name: JS package cache
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ${{ steps.yarn-cache.outputs.dir }}
|
|
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-yarn-
|
|
- name: Install packages
|
|
run: |
|
|
yarn install --frozen-lockfile
|
|
|
|
- name: Setup test database
|
|
env:
|
|
RAILS_ENV: test
|
|
DATABASE_URL: "postgres://tps_test@localhost:5432/tps_test"
|
|
run: |
|
|
bundle exec rake db:create db:schema:load db:migrate
|
|
|
|
- name: Setup environment variables
|
|
run: |
|
|
cp config/env.example .env
|
|
|
|
- name: Run tests
|
|
run: ${{ matrix.pattern }}
|