2024-12-28 18:35:42 +01:00
|
|
|
name: Run unit tests
|
2024-07-12 15:11:24 +02:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
pull_request:
|
2024-11-03 09:31:10 +01:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
2024-07-12 15:11:24 +02:00
|
|
|
jobs:
|
|
|
|
unit_tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
postgres:
|
|
|
|
image: postgres
|
|
|
|
env:
|
|
|
|
POSTGRES_USER: postgres
|
|
|
|
POSTGRES_PASSWORD: postgres
|
|
|
|
ports:
|
|
|
|
- 5432
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
2025-01-14 19:51:29 +01:00
|
|
|
- uses: ruby/setup-ruby@v1.207.0
|
2024-07-12 15:11:24 +02:00
|
|
|
- run: bundle install
|
2024-12-28 18:35:04 +01:00
|
|
|
- run: bundle exec rubocop --force-exclusion --parallel
|
2024-07-30 21:30:16 +02:00
|
|
|
- name: Wait until Postgres is ready to accept connections
|
|
|
|
run: |
|
2024-07-30 21:33:02 +02:00
|
|
|
apt-get update && apt-get install -f -y postgresql-client
|
2024-07-30 21:30:16 +02:00
|
|
|
until pg_isready -h postgres -U postgres -d postgres
|
|
|
|
do
|
|
|
|
sleep 1
|
|
|
|
echo "Trying again"
|
|
|
|
done
|
2024-07-12 15:11:24 +02:00
|
|
|
- run: |
|
2024-07-30 21:37:22 +02:00
|
|
|
bundle exec rake db:schema:load
|
2024-07-12 15:11:24 +02:00
|
|
|
bundle exec rspec
|
|
|
|
env:
|
|
|
|
RAILS_ENV: test
|
|
|
|
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres
|
2024-08-09 20:15:41 +02:00
|
|
|
- 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
|