Files
growstuff/.github/workflows/ci.yml
2020-08-26 12:36:58 +12:00

106 lines
2.9 KiB
YAML

name: CI
on:
pull_request:
push:
branches:
- mainline
- dev
jobs:
contributors:
runs-on: ubuntu-latest
steps:
- name: Install ruby version specified in .ruby-version
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install gem bundle
run: |
gem install bundler
bundle install
- name: Check contributors
run: |
bundle exec script/check_contributors_md.rb
test:
runs-on: ubuntu-latest
services:
db:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: growstuff_test
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout this repo
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Setup yarn cache
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install required OS packages
run: |
sudo apt-get -y install libpq-dev google-chrome-stable
- name: Install NodeJS
uses: actions/setup-node@v2-beta
with:
node-version: '12'
- name: Install ruby version specified in .ruby-version
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Install gem bundle
run: |
gem install bundler
bundle install
- name: Install JS dependencies
run: yarn install
- name: Setup codeclimate
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Prepare database for testing
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/growstuff_test
DEVISE_SECRET_KEY: growstuff
RAILS_ENV: test
run: |
bundle exec rails db:prepare
- name: Run rspec (report results to Percy.io and codeclimate)
env:
DATABASE_URL: postgres://postgres:postgres@localhost:5432/growstuff_test
DEVISE_SECRET_KEY: growstuff
growstuff_ONLINE_SECRET_KEY_BASE: growstuff
APP_DOMAIN_NAME: localhost:3000
APP_PROTOCOL: http
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
run: |
bundle exec rspec spec
./cc-test-reporter after-build --exit-code $?