Created
July 6, 2022 21:17
-
-
Save joshuaclayton/3e2d32866034bd1e3828a4dd6e0578b1 to your computer and use it in GitHub Desktop.
GitHub action for a vanilla Rails app with linting and auto-formatting
This file contains hidden or 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
name: CI | |
on: [push] | |
jobs: | |
tests: | |
name: Tests | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:12 | |
env: | |
POSTGRES_USER: myapp | |
POSTGRES_DB: redirect_test | |
POSTGRES_PASSWORD: password | |
ports: ["5432:5432"] | |
options: --health-cmd pg_isready --health-interval 4s --health-timeout 2s --health-retries 10 | |
env: | |
PGHOST: localhost | |
PGUSER: myapp | |
PGPASSWORD: password | |
PIPE_ENV: test | |
RAILS_ENV: test | |
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
- name: Ruby gem cache | |
uses: actions/cache@v2 | |
with: | |
path: vendor/bundle | |
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} | |
restore-keys: | | |
${{ runner.os }}-gems- | |
- name: Install gems | |
run: | | |
bundle config path vendor/bundle | |
bundle install --jobs 4 --retry 3 | |
- name: Setup Node | |
uses: actions/setup-node@v1 | |
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@v1 | |
with: | |
path: ${{ steps.yarn-cache.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Setup | |
run: | | |
bin/setup | |
- name: Run tests | |
run: bin/rspec | |
- name: Lint JS | |
run: node_modules/.bin/prettier --check | |
- name: Lint Ruby | |
run: ./bin/standardrb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment