-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (120 loc) · 4.92 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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=10
# 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: Clone filestore db
run: |
git clone https://github.com/NYPL/filestore_databases_docker ../filestore_databases_docker
- name: set up docker
uses: docker/setup-buildx-action@v2
- name: install docker compose
run: |
sudo apt-get update
sudo apt-get install -y docker-compose
- 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: Start App
run: |
docker-compose up -d
- 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