Skip to content

Commit

Permalink
Update CI pipeline with PG options and more description (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
leesheppard authored Jan 20, 2025
1 parent 24b4a52 commit 109787a
Showing 1 changed file with 37 additions and 16 deletions.
53 changes: 37 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,65 @@
name: CI
name: Continuous Integration

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:

jobs:
build:
name: Build and Test
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
image: postgres:latest
env:
POSTGRES_USER: ruby_au
POSTGRES_PASSWORD: ruby_au
POSTGRES_DB: ruby_au_test
ports:
- 5432/tcp
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
- 5432:5432
options: "--health-cmd \"pg_isready --host=localhost --username=ruby_au\" --health-interval 10s --health-timeout 5s --health-retries 5"

steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up ruby

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.5
ruby-version: .ruby-version
bundler-cache: true
- name: Set up node
uses: actions/setup-node@v3

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22.11.0
cache: "yarn"
- name: Install Yarn dependencies
node-version-file: .node-version
cache: yarn

- name: Install dependencies
run: |
yarn install
bundle install
- name: Prepare assets
run: |
bin/vite build
bundle exec rails assets:precompile
- name: Rubocop
- name: Lint Ruby code
run: bundle exec rubocop
- name: Test

- name: Wait for Database
run: |
until pg_isready --host=127.0.0.1 --port=5432 --username=ruby_au; do
echo "Waiting for database..."
sleep 1
done
echo "Database is ready!"
- name: Run Tests
env:
DATABASE_URL: postgres://ruby_au:[email protected]:${{ job.services.postgres.ports[5432] }}/ruby_au_test
DATABASE_URL: postgres://ruby_au:[email protected]:5432/ruby_au_test
run: bundle exec rspec

0 comments on commit 109787a

Please sign in to comment.