-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (151 loc) · 4.81 KB
/
ci.yml
File metadata and controls
177 lines (151 loc) · 4.81 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
name: CodeToQuery CI
on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]
jobs:
test_postgres:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:13
env:
POSTGRES_DB: code_to_query_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: secret
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
ruby-version: ["3.0", "3.1", "3.2", "3.3"]
ar-gemfile: ["activerecord7.0", "activerecord7.1", "activerecord7.2"]
exclude:
- ruby-version: "3.0"
ar-gemfile: "activerecord7.2"
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Install dependencies
run: |
cp gemfiles/Gemfile.${{ matrix.ar-gemfile }} Gemfile
bundle install --jobs 4 --retry 3
- name: Wait for Postgres
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client
for i in {1..10}; do
pg_isready -h localhost -p 5432 -U postgres && break
echo "Waiting for postgres..."
sleep 5
done
- name: Create test DB (Postgres)
run: |
psql -h localhost -U postgres -c "CREATE DATABASE code_to_query_test;" || true
- name: Prepare DB env (Postgres)
run: |
echo "DB_ADAPTER=postgresql" >> $GITHUB_ENV
echo "DB_HOST=localhost" >> $GITHUB_ENV
echo "DB_USER=postgres" >> $GITHUB_ENV
echo "DB_PASSWORD=secret" >> $GITHUB_ENV
echo "DB_DATABASE=code_to_query_test" >> $GITHUB_ENV
- name: Run tests
run: bundle exec rspec
- name: Run RuboCop
run: bundle exec rubocop
test_mysql:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
env:
MYSQL_DATABASE: code_to_query_test
MYSQL_ROOT_PASSWORD: secret
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1 --password=secret"
--health-interval 5s
--health-timeout 5s
--health-retries 5
strategy:
fail-fast: false
matrix:
ruby-version: ["3.0", "3.1", "3.2", "3.3"]
ar-gemfile: ["activerecord7.0", "activerecord7.1", "activerecord7.2"]
exclude:
- ruby-version: "3.0"
ar-gemfile: "activerecord7.2"
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Install dependencies
run: |
cp gemfiles/Gemfile.${{ matrix.ar-gemfile }} Gemfile
bundle install --jobs 4 --retry 3
- name: Wait for MySQL
run: |
sudo apt-get update
sudo apt-get install -y mysql-client
for i in {1..10}; do
mysqladmin ping -h 127.0.0.1 --password=secret && break
echo "Waiting for mysql..."
sleep 5
done
- name: Create test DB (MySQL)
run: |
mysql -h 127.0.0.1 -uroot -psecret -e "CREATE DATABASE IF NOT EXISTS code_to_query_test"
- name: Prepare DB env (MySQL)
run: |
echo "DB_ADAPTER=mysql2" >> $GITHUB_ENV
echo "DB_HOST=127.0.0.1" >> $GITHUB_ENV
echo "DB_USER=root" >> $GITHUB_ENV
echo "DB_PASSWORD=secret" >> $GITHUB_ENV
echo "DB_DATABASE=code_to_query_test" >> $GITHUB_ENV
- name: Run tests
run: bundle exec rspec
- name: Run RuboCop
run: bundle exec rubocop
test_sqlite:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version: ["3.0", "3.1", "3.2", "3.3"]
ar-gemfile: ["activerecord7.0", "activerecord7.1", "activerecord7.2"]
exclude:
- ruby-version: "3.0"
ar-gemfile: "activerecord7.2"
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Install dependencies
run: |
cp gemfiles/Gemfile.${{ matrix.ar-gemfile }} Gemfile
bundle install --jobs 4 --retry 3
- name: Prepare DB env (SQLite)
run: |
echo "DB_ADAPTER=sqlite3" >> $GITHUB_ENV
echo "DB_DATABASE=:memory:" >> $GITHUB_ENV
- name: Run tests
run: bundle exec rspec
- name: Run RuboCop
run: bundle exec rubocop