Skip to content

remove commented lin #31

remove commented lin

remove commented lin #31

Workflow file for this run

name: CI
on:
push:
branches:
- DR-3256-migrate-ci-to-gh-actions
- qa
- nypl-dams-prod
pull_request:
branches:
- qa
- nypl-dams-prod
jobs:
build_and_test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: >-
--health-cmd="pg_isready -U postgres"
--health-interval=10s
--health-timeout=5s
--health-retries=5
ports:
- 5432:5432
mysql:
image: mysql:5.6
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=10
--memory=512m --cpus=0.5
ports:
- 3306:3306
env:
RAILS_ENV: test
IMAGE_FILESTORE_DATABASE_NAME: image_filestore_test
AMI_FILESTORE_DATABASE_NAME: ami_filestore_test
IMAGE_FILESTORE_DATABASE_USER: root
AMI_FILESTORE_DATABASE_USER: root
# DATABASE_USERNAME: root
#DATABASE_PASSWORD: "" # Empty password
#DATABASE_HOST: 127.0.0.1
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3.3
bundler-cache: true
- name: Update RubyGems and install Bundler
run: |
gem update --system '3.3.22'
gem install bundler -v '2.5.18'
- name: Set up PostgreSQL
run: |
docker exec ${{ job.services.postgres.id }} bash -c "psql -U postgres -c 'ALTER SYSTEM SET shared_buffers TO 65536;'"
docker exec ${{ job.services.postgres.id }} bash -c "psql -U postgres -c 'ALTER SYSTEM SET work_mem TO 4096;'"
docker exec ${{ job.services.postgres.id }} bash -c "psql -U postgres -c 'SELECT pg_reload_conf();'"
- name: Set up MySQL
run: |
docker exec ${{ job.services.mysql.id }} bash -c "echo '[mysqld]' > /etc/mysql/conf.d/custom.cnf"
docker exec ${{ job.services.mysql.id }} bash -c "echo 'innodb_buffer_pool_size=64M' >> /etc/mysql/conf.d/custom.cnf"
docker restart ${{ job.services.mysql.id }}
# - name: Wait for Database Services
# run: |
# sudo apt-get update
# sudo apt-get install -y postgresql-client mysql-client
# until pg_isready -h localhost -U postgres; do echo "Waiting for PostgreSQL..."; sleep 1; done
# #until mysqladmin ping --silent; do echo "Waiting for MySQL..."; sleep 1; done
# Re-check readiness
- name: Wait for Database Services after restart
run: |
until docker exec ${{ job.services.postgres.id }} pg_isready -U postgres; do
echo "Waiting for PostgreSQL to be ready after restart..."
sleep 2
done
# Uncomment if needed for MySQL
# until docker exec ${{ job.services.mysql.id }} mysqladmin ping --silent; do
# echo "Waiting for MySQL to be ready after restart..."
# sleep 2
# done
- name: Show Database Logs
run: |
echo "PostgreSQL logs:"
docker logs $(docker ps -qf "ancestor=postgres:11")
echo "MySQL logs:"
docker logs $(docker ps -qf "ancestor=mysql:5.6")
- name: Set up Databases
run: |
psql -U postgres -c 'create database fedora_ingest_rails_test;'
mysql -uroot -e 'CREATE DATABASE ami_filestore_test; CREATE DATABASE image_filestore_test'
mysql -uroot ami_filestore_test < ./db/resources/ami_filestore_schema.sql
mysql -uroot image_filestore_test < ./db/resources/image_filestore_schema.sql
- name: Run Tests
run: |
bundle exec rspec