feat(ci-checks): add workflow to run rspec and jest on PR #1
Workflow file for this run
This file contains 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 Check | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
jobs: | |
rspec: | |
runs-on: ubuntu-latest | |
container: | |
image: ruby:3.2.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 |