Skip to content

Instantly share code, notes, and snippets.

@sulmanweb
Created July 25, 2020 15:53
Show Gist options
  • Save sulmanweb/d5059dd74be71d204272b9b06985b326 to your computer and use it in GitHub Desktop.
Save sulmanweb/d5059dd74be71d204272b9b06985b326 to your computer and use it in GitHub Desktop.
RSpec Rails API GitHub Actions Workflow
name: CI RSpec Tests
on: [push, pull_request]
push:
paths:
- 'api/**'
pull_request:
paths:
- 'api/**'
jobs:
build:
name: CI
runs-on: ubuntu-latest
env:
api-dir: ./api
services:
postgres:
image: postgres:11.6
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis
ports: ["6379:6379"]
elasticsearch:
image: elasticsearch:6.8.8
ports: ["9200:9200"]
options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
steps:
- uses: actions/checkout@v1
- uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.6
- name: Install PostgreSQL
run: sudo apt-get -yqq install libpq-dev
- name: Run bundle install
working-directory: ${{env.api-dir}}
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Setup Database
working-directory: ${{env.api-dir}}
env:
RAILS_ENV: test
PGHOST: localhost
PGUSER: postgres
run: bin/rails db:create db:schema:load
- name: Build and test with rspec
working-directory: ${{env.api-dir}}
env:
RAILS_ENV: test
PGHOST: localhost
PGUSER: postgres
run: bundle exec rspec spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment