Repository navigation
325 lines (265 loc) · 10.5 KB
/
Copy pathtests.yml
File metadata and controls
325 lines (265 loc) · 10.5 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
name: Tests
defaults:
run:
shell: bash
permissions:
contents: read
concurrency:
group: tests-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
on:
workflow_call: # the Release workflow runs the full gate on the exact commit it releases
push:
branches: [ "main" ]
pull_request:
branches: [ "*" ]
paths:
- "**"
- "!**.md"
env:
DB_NAME: tests
DB_USER: root
DB_PASS: pass
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
bundler-cache: true
# protocol codec, generator, golden snapshots, formatting rules (incl. the protobuf codec cross-check)
- name: Unit & golden tests
run: bundle exec rake test
compatibility:
name: Plugin on Ruby ${{ matrix.ruby-version }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
ruby-version: ['3.1', '3.2', '3.4', '4.0']
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
# the process plugin runs on whatever Ruby the user has: no bundler, only the standard library + minitest
- name: Unit tests
run: ruby -Ilib -Itest -e 'Dir["test/*_test.rb"].sort.each { |file| require File.expand_path(file) }'
end2end-pg:
name: End-to-End (PostgreSQL, Ruby ${{ matrix.ruby-version }}, ${{ matrix.variant }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
ruby-version: ['3.1', '3.2', '3.3', '3.4', '4.0']
variant: ['default']
include:
- ruby-version: '4.0'
variant: 'module-no-prepared'
- ruby-version: '3.1'
variant: 'bundled-timeout'
services:
postgres:
image: postgres:16.2
env:
POSTGRES_DB: tests
POSTGRES_USER: root
POSTGRES_PASSWORD: pass
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U root -d tests"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
POSTGRES_HOST: 127.0.0.1
EXAMPLES_DRIVER: pg
EXAMPLES_MODULE: ${{ matrix.variant == 'module-no-prepared' && 'MyApp::Db' || 'PgCodegen' }}
PREPARED_STATEMENTS: ${{ matrix.variant == 'module-no-prepared' && 'false' || 'true' }}
E2E_TIMEOUT_GEM: ${{ matrix.variant == 'bundled-timeout' && '0.2.0' || '' }}
BUNDLE_GEMFILE: ${{ (matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2') && 'Gemfile.e2e' || 'Gemfile' }}
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: ${{ matrix.ruby-version != '3.1' && matrix.ruby-version != '3.2' }}
- name: Load tool versions
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default'
run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV"
- uses: sqlc-dev/setup-sqlc@v5
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default'
with:
sqlc-version: '${{ env.SQLC_VERSION }}'
- name: Generate version-specific examples
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2'
run: |
ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.local.yaml --generate-gemfile
echo "EXAMPLES_DIR=$PWD/.examples-ruby-${{ matrix.ruby-version }}" >> "$GITHUB_ENV"
- name: Generate option variant
if: matrix.variant == 'module-no-prepared'
run: |
ruby scripts/tests/generate_examples.rb 4.0 sqlc.local.yaml --driver pg --options '{"moduleName":"MyApp::Db","preparedStatements":false}'
echo "EXAMPLES_DIR=$PWD/.examples-ruby-4.0" >> "$GITHUB_ENV"
- name: Install E2E dependencies
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2'
run: bundle install
- name: Create the schema
run: psql -v ON_ERROR_STOP=1 -h 127.0.0.1 -U "${DB_USER}" -d "${DB_NAME}" -f examples/authors/postgresql/schema.sql
env:
PGPASSWORD: ${{ env.DB_PASS }}
- name: End-to-End tests
run: bundle exec rake end2end_pg
end2end-mysql:
name: End-to-End (MySQL, Ruby ${{ matrix.ruby-version }}, ${{ matrix.variant }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
ruby-version: ['3.1', '3.2', '3.3', '3.4', '4.0']
variant: ['default']
include:
- ruby-version: '4.0'
variant: 'module-name'
services:
mysql:
image: mysql:8.3.0
env:
MYSQL_DATABASE: tests
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping -h 127.0.0.1"
--health-interval 5s
--health-timeout 5s
--health-retries 20
env:
MYSQL_HOST: 127.0.0.1
EXAMPLES_DRIVER: mysql2
EXAMPLES_MODULE: ${{ matrix.variant == 'module-name' && 'MyApp::Db' || 'Mysql2Codegen' }}
BUNDLE_GEMFILE: ${{ (matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2') && 'Gemfile.e2e' || 'Gemfile' }}
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: ${{ matrix.ruby-version != '3.1' && matrix.ruby-version != '3.2' }}
- name: Load tool versions
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default'
run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV"
- uses: sqlc-dev/setup-sqlc@v5
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default'
with:
sqlc-version: '${{ env.SQLC_VERSION }}'
- name: Generate version-specific examples
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2'
run: |
ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.local.yaml --generate-gemfile
echo "EXAMPLES_DIR=$PWD/.examples-ruby-${{ matrix.ruby-version }}" >> "$GITHUB_ENV"
- name: Generate option variant
if: matrix.variant == 'module-name'
run: |
ruby scripts/tests/generate_examples.rb 4.0 sqlc.local.yaml --driver mysql2 --options '{"moduleName":"MyApp::Db"}'
echo "EXAMPLES_DIR=$PWD/.examples-ruby-4.0" >> "$GITHUB_ENV"
- name: Install E2E dependencies
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2'
run: bundle install
- name: Create the schema (and allow LOAD DATA LOCAL INFILE for :copyfrom)
run: |
mysql -h 127.0.0.1 -u "${DB_USER}" -e 'SET GLOBAL local_infile = 1'
mysql -h 127.0.0.1 -u "${DB_USER}" "${DB_NAME}" < examples/authors/mysql/schema.sql
- name: End-to-End tests
run: bundle exec rake end2end_mysql2
end2end-sqlite:
name: End-to-End (SQLite, Ruby ${{ matrix.ruby-version }}, ${{ matrix.variant }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
ruby-version: ['3.1', '3.2', '3.3', '3.4', '4.0']
variant: ['default']
include:
- ruby-version: '4.0'
variant: 'module-name'
env:
EXAMPLES_DRIVER: sqlite3
EXAMPLES_MODULE: ${{ matrix.variant == 'module-name' && 'MyApp::Db' || 'Sqlite3Codegen' }}
BUNDLE_GEMFILE: ${{ (matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2') && 'Gemfile.e2e' || 'Gemfile' }}
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: ${{ matrix.ruby-version != '3.1' && matrix.ruby-version != '3.2' }}
- name: Load tool versions
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default'
run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV"
- uses: sqlc-dev/setup-sqlc@v5
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2' || matrix.variant != 'default'
with:
sqlc-version: '${{ env.SQLC_VERSION }}'
- name: Generate version-specific examples
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2'
run: |
ruby scripts/tests/generate_examples.rb "${{ matrix.ruby-version }}" sqlc.local.yaml --generate-gemfile
echo "EXAMPLES_DIR=$PWD/.examples-ruby-${{ matrix.ruby-version }}" >> "$GITHUB_ENV"
- name: Generate option variant
if: matrix.variant == 'module-name'
run: |
ruby scripts/tests/generate_examples.rb 4.0 sqlc.local.yaml --driver sqlite3 --options '{"moduleName":"MyApp::Db"}'
echo "EXAMPLES_DIR=$PWD/.examples-ruby-4.0" >> "$GITHUB_ENV"
- name: Install E2E dependencies
if: matrix.ruby-version == '3.1' || matrix.ruby-version == '3.2'
run: bundle install
- name: End-to-End tests
run: bundle exec rake end2end_sqlite3
end2end-options:
name: Generator options E2E (Ruby ${{ matrix.ruby-version }})
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
ruby-version: ['3.1', '4.0']
services:
postgres:
image: postgres:16.2
env:
POSTGRES_DB: tests
POSTGRES_USER: root
POSTGRES_PASSWORD: pass
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U root -d tests"
--health-interval 5s
--health-timeout 5s
--health-retries 10
env:
POSTGRES_HOST: 127.0.0.1
BUNDLE_GEMFILE: Gemfile.options.e2e
steps:
- uses: actions/checkout@v7
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: false
- name: Install options test dependencies
run: bundle install
- name: Load tool versions
run: grep -E '^[A-Z_]+=' scripts/tool-versions.env >> "$GITHUB_ENV"
- uses: sqlc-dev/setup-sqlc@v5
with:
sqlc-version: '${{ env.SQLC_VERSION }}'
- name: End-to-end option tests
run: bundle exec ruby tests/end2end_options.rb