Skip to content

feat(ci-checks): add workflow to run rspec and jest on PR #2

feat(ci-checks): add workflow to run rspec and jest on PR

feat(ci-checks): add workflow to run rspec and jest on PR #2

Workflow file for this run

name: CI Check
on:
pull_request:
types:
- opened
- synchronize
- reopened
jobs:
test:
runs-on: ubuntu-latest
container:
image: ruby:3.2
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_DB: postgres
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Gem cache
id: cache-bundle
uses: actions/cache@v1
with:
path: vendor/bundle
key: bundle-${{ hashFiles('**/Gemfile.lock') }}
- name: Bundle install
env:
RAILS_ENV: test
run: |
gem install bundler
bundle install --jobs 4 --retry 3 --path vendor/bundle
- name: Install yarn
run: npm install -g yarn
# NOTE: Yarn cache doesn't seem to be working quite yet
- name: Get yarn cache dir
id: yarn-cache-dir
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Yarn cache
id: cache-yarn
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
- name: Setup DB, Run tests
env:
PGHOST: postgres
PGUSER: postgres
PGPORT: ${{ job.services.postgres.ports[5432] }}
RAILS_ENV: test
run: |
bin/rails db:create db:schema:load
bundle exec rspec
- name: Yarn install
run: |
yarn install
yarn test