Rails way #20
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
# This workflow uses actions that are not certified by GitHub. They are | |
# provided by a third-party and are governed by separate terms of service, | |
# privacy policy, and support documentation. | |
# | |
# This workflow will install a prebuilt Ruby version, install dependencies, and | |
# run tests and linters. | |
name: Testing the application | |
on: | |
pull_request: | |
branches: ["master"] | |
jobs: | |
rspec-test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: password | |
ports: ["5432:5432"] | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Setting up Ruby | |
uses: ruby/[email protected] | |
with: | |
ruby-version: 3.1.2 | |
- name: Installing Bundler & Gems | |
run: | | |
gem install bundler | |
bundle install --jobs 4 --retry 3 | |
- name: Run yarn commands | |
run: | | |
yarn install | |
yarn run build | |
- name: Preparing Database | |
env: | |
DATABASE_URL: postgres://postgres:password@localhost:5432/test | |
RAILS_ENV: test | |
PG_USER: postgres | |
run: | | |
bundle exec rails db:create | |
bundle exec rails db:migrate | |
- name: StandardRB Linter | |
run: bundle exec standardrb | |
- name: erb-lint | |
run: bundle exec erblint --lint-all | |
- name: Testing routes | |
env: | |
DATABASE_URL: postgres://postgres:password@localhost:5432/test | |
RAILS_ENV: test | |
PG_USER: postgres | |
run: rspec spec/routing -fd | |
- name: Testing requests | |
env: | |
DATABASE_URL: postgres://postgres:password@localhost:5432/test | |
RAILS_ENV: test | |
PG_USER: postgres | |
run: rspec spec/requests -fd | |
- name: Testing models | |
env: | |
DATABASE_URL: postgres://postgres:password@localhost:5432/test | |
RAILS_ENV: test | |
PG_USER: postgres | |
run: rspec spec/models -fd | |
- name: Testing helpers | |
env: | |
DATABASE_URL: postgres://postgres:password@localhost:5432/test | |
RAILS_ENV: test | |
PG_USER: postgres | |
run: rspec spec/helpers -fd | |
- name: Setup Chrome | |
uses: browser-actions/[email protected] | |
- name: setup-chromedriver | |
uses: nanasess/[email protected] | |
- name: Testing features | |
env: | |
DATABASE_URL: postgres://postgres:password@localhost:5432/test | |
RAILS_ENV: test | |
PG_USER: postgres | |
run: | | |
export DISPLAY=:99 | |
chromedriver & | |
sudo Xvfb -ac :99 > /dev/null 2>&1 & # optional | |
rspec spec/features -fd | |
# 'sudo Xvfb -ac :99 > /dev/null 2>&1 & # optional' command launches an instance of Xvfb (X Virtual Framebuffer), a virtual display server for X11 that allows running graphical applications without an actual display hardware. |