Skip to content

Instantly share code, notes, and snippets.

@adipasquale
Last active March 5, 2021 16:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adipasquale/82c4734f91f8eac396b012f4740f2f53 to your computer and use it in GitHub Desktop.
Save adipasquale/82c4734f91f8eac396b012f4740f2f53 to your computer and use it in GitHub Desktop.
GitHub Action for CI Rails Tests with a specific ruby version, minitest, Chrome Headless and PostgreSQL
# .github/workflows/rails-tests.yml
name: Rails Tests
on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
PGHOST: localhost
PGUSER: postgres
RAILS_ENV: test
services:
postgres:
image: postgres:11.5
ports: ["5432:5432"]
redis:
image: redis
ports:
- 6379/tcp
steps:
- uses: actions/checkout@v1
- name: Install correct ruby version through RVM
run: |
curl -sSL https://get.rvm.io | bash
source $HOME/.rvm/scripts/rvm
rvm install $(cat .ruby-version) --binary
rvm --default use $(cat .ruby-version)
- name: Install PostgreSQL client & chrome Headless
run: |
sudo apt-get update
sudo apt-get -yqq install libpq-dev
sudo apt-get install google-chrome-stable
- name: Build App
run: |
source $HOME/.rvm/scripts/rvm
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rails db:setup
- name: Precompile assets
env:
SECRET_KEY_BASE: a
RAILS_ENV: production
run: |
source $HOME/.rvm/scripts/rvm
bundle exec rake assets:precompile
- name: Run Tests
run: |
source $HOME/.rvm/scripts/rvm
bundle exec rails test:system test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment