Manuel Bustillo
e612cf9936
Some checks failed
Run unit tests / reversible_migrations (pull_request) Failing after 4m36s
Run unit tests / build-static-assets (pull_request) Has been skipped
Check usage of free licenses / check-licenses (pull_request) Successful in 1m39s
Add copyright notice / copyright_notice (pull_request) Successful in 3m19s
Run unit tests / rubocop (pull_request) Successful in 1m49s
Run unit tests / unit_tests (pull_request) Successful in 5m34s
105 lines
3.3 KiB
YAML
105 lines
3.3 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
|
|
build-static-assets:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
needs:
|
|
- unit_tests
|
|
- rubocop
|
|
- reversible_migrations
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to the private Docker registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ secrets.PRIVATE_REGISTRY_HOST }}
|
|
username: ${{ secrets.PRIVATE_REGISTRY_USERNAME }}
|
|
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }}
|
|
|
|
- name: Build and push intermediate stages (build)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
target: build
|
|
push: ${{ github.ref == 'refs/heads/main' }}
|
|
tags: ${{ secrets.PRIVATE_REGISTRY_HOST }}/${{ env.GITHUB_REPOSITORY }}:build
|
|
cache-from: type=registry,ref=${{ secrets.PRIVATE_REGISTRY_HOST }}/${{ env.GITHUB_REPOSITORY }}:build
|
|
cache-to: type=inline
|
|
|
|
- name: Build and push (final)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: ${{ github.ref == 'refs/heads/main' }}
|
|
tags: ${{ secrets.PRIVATE_REGISTRY_HOST }}/${{ env.GITHUB_REPOSITORY }}:latest
|
|
cache-from: type=registry,ref=${{ secrets.PRIVATE_REGISTRY_HOST }}/${{ env.GITHUB_REPOSITORY }}:latest
|
|
cache-to: type=inline |