Manuel Bustillo db55bafea1
Some checks failed
Add copyright notice / copyright_notice (pull_request) Successful in 2m23s
Check usage of free licenses / check-licenses (pull_request) Successful in 1m7s
Run unit tests / rubocop (pull_request) Successful in 3m3s
Build Nginx-based docker image / build-static-assets (pull_request) Successful in 50m52s
Run unit tests / unit_tests (pull_request) Successful in 6m1s
Run unit tests / reversible_migrations (pull_request) Failing after 3m20s
Reuse code to wait for Postgres to be active
2025-01-23 22:21:46 +01:00

65 lines
1.9 KiB
YAML

name: Run unit tests
on:
push:
branches:
- main
pull_request:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
unit_tests:
runs-on: ubuntu-latest
services: &services
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ruby/setup-ruby@v1.207.0
- run: bundle install
- &postgres_wait
name: Wait until Postgres is ready to accept connections
run: |
apt-get update && apt-get install -f -y postgresql-client
until pg_isready -h postgres -U postgres -d postgres
do
sleep 1
echo "Trying again"
done
- run: |
bundle exec rake db:schema:load
bundle exec rspec
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
- name: Clean up containers generated by this flow
if: failure()
run: docker ps --filter network=$JOB_CONTAINER_NAME-$GITHUB_JOB-network --filter name=$JOB_CONTAINER_NAME-* --format "{{.ID}}" | xargs docker rm -f
rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ruby/setup-ruby@v1.207.0
- run: bundle install
- run: bundle exec rubocop --force-exclusion --parallel
reversible_migrations:
runs-on: ubuntu-latest
services: *services
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ruby/setup-ruby@v1.207.0
- run: bundle install
- *postgres_wait
- run: bundle exec rake db:schema:load
- run: bundle exec rake db:migrate:redo