Skip to content

Instantly share code, notes, and snippets.

@davidteren
Created May 18, 2020 16:34
Show Gist options
  • Save davidteren/5d4c79d0bc5d4e1beac5293706797495 to your computer and use it in GitHub Desktop.
Save davidteren/5d4c79d0bc5d4e1beac5293706797495 to your computer and use it in GitHub Desktop.
GitHub Workflow - Linter & Test CI
name: CI
on: [push, pull_request]
jobs:
linters:
name: Linters
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Ruby gem cache
uses: actions/cache@v1
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: 10.13.0
- 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: Install packages
run: |
yarn install --pure-lockfile
- name: Run linters
run: |
bin/rubocop --parallel
- name: Run security checks
run: |
bin/bundler-audit --update
bin/brakeman -q -w2
tests:
name: Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11@sha256:85d79cba2d4942dad7c99f84ec389a5b9cc84fb07a3dcd3aff0fb06948cdc03b
ports: ['5432:5432']
env:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: ""
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14.2.0
- 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: Install packages
run: |
yarn install --pure-lockfile
- name: Setup Ruby
uses: ruby/setup-ruby@v1
- name: Ruby gem cache
uses: actions/cache@v1
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
gem install codeclimate-test-reporter
- name: Setup test database
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:@localhost:5432/testing_rails6_test
run: |
bin/rails db:prepare
- name: Run tests
run: bundle exec rspec --format doc
- name: Coverage reporter
env:
CODECLIMATE_REPO_TOKEN: ${{ secrets.CODECLIMATE_REPO_TOKEN }}
run: codeclimate-test-reporter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment