Skip to content

Instantly share code, notes, and snippets.

@robzolkos
Created November 20, 2023 19:21
Show Gist options
  • Save robzolkos/5f80b14d1967b4faf92d12aea8f5204e to your computer and use it in GitHub Desktop.
Save robzolkos/5f80b14d1967b4faf92d12aea8f5204e to your computer and use it in GitHub Desktop.
Github Action for CI for Rails app
name: CI
on:
pull_request:
branches:
- master
env:
RAILS_ENV: test
REDIS_URL: redis://redis:6379/1
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
HOSTNAME: 127.0.0.1
jobs:
install-cache:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install Node
uses: actions/setup-node@v4
with:
cache: "yarn"
- run: yarn install
linting:
runs-on: ubuntu-latest
needs: install-cache
timeout-minutes: 15
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install Node
uses: actions/setup-node@v4
with:
cache: "yarn"
- run: yarn install
- name: Run rubocop
run: |
bundle exec rubocop
tests:
runs-on: ubuntu-latest
needs: install-cache
timeout-minutes: 15
services:
redis:
image: redis
ports:
- "6379:6379"
db:
image: mysql:8.0.28-oracle
ports:
- "3306:3306"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install Node
uses: actions/setup-node@v4
with:
cache: "yarn"
- run: yarn install
- name: Prepare database
run: |
bin/rails db:create
bin/rails db:schema:load
- name: Unit Tests
run: |
bin/rails test
system_tests:
runs-on: ubuntu-latest
needs: install-cache
timeout-minutes: 15
services:
redis:
image: redis
ports:
- "6379:6379"
db:
image: mysql:8.0.28-oracle
ports:
- "3306:3306"
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
steps:
- name: Checkout Commit
uses: actions/checkout@v4
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install Node
uses: actions/setup-node@v4
with:
cache: "yarn"
- run: yarn install
- name: Prepare database
run: |
bin/rails db:create
bin/rails db:schema:load
- name: System Tests
run: |
bin/rails test:system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment