-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
315 lines (299 loc) · 8.08 KB
/
.gitlab-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
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
# Cache gems in between builds
stages:
- build
- test
- prepare
- deploy
cache:
key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
paths:
- vendor
.before_script: &before_script
# rails 5.1 and lower need older version of bundler
- ls
- rm -f Gemfile.lock
- bundle install
- |-
if [[ "$BUNDLE_GEMFILE" = *rails* ]]; then
cd test/rails_app && \
BUNDLE_GEMFILE=../../$BUNDLE_GEMFILE DATABASE_URL=sqlite3::memory: bundle exec rails generate rodauth:oauth:views -a && \
cd ../..
fi
.prepare_dbs: &prepare_dbs
- PGPASSWORD=password createdb -h postgres -U oauth oauth-unique 'oauth database to keep single row for access tokens'
- MYSQL_PWD=password mariadb -h mysql -u root -e 'CREATE DATABASE oauthunique'
.install_deps: &install_deps
- apt-get update && apt-get install -y shared-mime-info libyaml-dev libsqlite3-dev libmariadb-dev-compat mariadb-client libmariadb-dev postgresql-client libpq-dev
.test: &test
- "DATABASE_URL=sqlite3::memory: bundle exec rake test:ci"
- "DATABASE_URL=postgresql://oauth:password@postgres/oauth bundle exec rake test"
# concurrency limited with mysql, to avoid deadlock messages
- "PARALLEL=0 && DATABASE_URL=mysql2://root:password@mysql/oauth bundle exec rake test"
# DB optimization modes
- "DATABASE_URL=postgresql://oauth:password@postgres/oauth-unique ONLY_ONE_TOKEN=1 bundle exec rake test"
- "PARALLEL=0 && DATABASE_URL=mysql2://root:password@mysql/oauthunique ONLY_ONE_TOKEN=1 bundle exec rake test"
# JWT supported libs
- "JWT_LIB=json/jwt DATABASE_URL=sqlite3::memory: bundle exec rake test"
.jtest: &jtest
- "DATABASE_URL=sqlite3::memory: bundle exec rake test"
- "DATABASE_URL=postgresql://oauth:password@postgres/oauth bundle exec rake test"
- "DATABASE_URL=mysql://root:password@mysql/oauth bundle exec rake test"
.truffletest: &truffletest
- "DATABASE_URL=sqlite3::memory: bundle exec rake test"
- "DATABASE_URL=postgresql://oauth:password@postgres/oauth bundle exec rake test"
- "DATABASE_URL=mysql2://root:password@mysql/oauth bundle exec rake test"
# JWT supported libs
- "JWT_LIB=json/jwt DATABASE_URL=postgresql://oauth:password@postgres/oauth bundle exec rake test"
.test_services: &test_services
services:
-
name: postgres:13
alias: postgres
# entrypoint: ["/usr/local/bin/db-postgres"]
-
name: mysql:8
alias: mysql
command:
- "--mysql-native-password=ON"
variables:
BUNDLE_WITHOUT: demo:docs
BUNDLE_JOBS: 10
BUNDLE_PATH: vendor
CI: 1
PARALLEL: 1
# Postgres
POSTGRES_DB: oauth
POSTGRES_USER: oauth
POSTGRES_PASSWORD: password
POSTGRES_HOST_AUTH_METHOD: trust
# Mysql
MYSQL_DATABASE: oauth
MYSQL_ROOT_PASSWORD: password
jruby:
<<: *test_services
cache:
paths:
- vendor/jruby
allow_failure: true
variables:
JRUBY_OPTS: --debug
before_script:
- apt-get update && apt-get install -y git shared-mime-info
- *before_script
image: "jruby:9.4"
script:
- *jtest
artifacts:
paths:
- "coverage/"
truffleruby:
<<: *test_services
allow_failure: true
before_script:
- dnf install -y git libxslt-devel libxml2-devel sqlite-devel postgresql-devel xz
- dnf --enablerepo=ol9_codeready_builder install mysql-devel
- *before_script
image: "ghcr.io/graalvm/truffleruby-community:latest"
script:
- *truffletest
artifacts:
paths:
- "coverage/"
ruby25:
<<: *test_services
before_script:
- *install_deps
- *before_script
image: "ruby:2.5"
script:
- "DATABASE_URL=sqlite3::memory: bundle exec rake test:ci"
artifacts:
paths:
- "coverage/"
parallel:
matrix:
- BUNDLE_GEMFILE: [Gemfile, Gemfile-rails52, Gemfile-rails51]
ruby26:
<<: *test_services
before_script:
- *install_deps
- *before_script
image: "ruby:2.6"
only:
- master
script:
- "DATABASE_URL=sqlite3::memory: bundle exec rake test:ci"
artifacts:
paths:
- "coverage/"
parallel:
matrix:
- BUNDLE_GEMFILE: [Gemfile, Gemfile-rails61, Gemfile-rails60, Gemfile-rails52]
ruby27:
<<: *test_services
before_script:
- *install_deps
- *before_script
- *prepare_dbs
image: "ruby:2.7"
script:
- *test
parallel:
matrix:
- BUNDLE_GEMFILE: [Gemfile, Gemfile-rails71, Gemfile-rails70, Gemfile-rails61, Gemfile-rails60, Gemfile-rails52]
artifacts:
paths:
- "coverage/"
ruby30:
<<: *test_services
before_script:
- *install_deps
- *before_script
- *prepare_dbs
image: "ruby:3.0"
script:
- *test
parallel:
matrix:
- BUNDLE_GEMFILE: [Gemfile, Gemfile-rails71, Gemfile-rails70, Gemfile-rails61, Gemfile-rails60]
artifacts:
paths:
- "coverage/"
ruby31:
<<: *test_services
before_script:
- *install_deps
- *before_script
- *prepare_dbs
# export RUBYOPT='-rbundler/setup -rrbs/test/setup'
# export RBS_TEST_RAISE=true
# export RBS_TEST_LOGLEVEL=error
# export RBS_TEST_OPT='-Isig'
# export RBS_TEST_TARGET='Rodauth*'
image: "ruby:3.1"
script:
- *test
parallel:
matrix:
- BUNDLE_GEMFILE: [Gemfile, Gemfile-rails72, Gemfile-rails71, Gemfile-rails70]
artifacts:
paths:
- "coverage/"
ruby32:
<<: *test_services
before_script:
- *install_deps
- *before_script
- *prepare_dbs
# export RUBYOPT='-rbundler/setup -rrbs/test/setup'
# export RBS_TEST_RAISE=true
# export RBS_TEST_LOGLEVEL=error
# export RBS_TEST_OPT='-Isig'
# export RBS_TEST_TARGET='Rodauth*'
image: "ruby:3.2"
script:
- bundle exec rake check_method_doc
- *test
parallel:
matrix:
- BUNDLE_GEMFILE: [Gemfile, Gemfile-rails80, Gemfile-rails72, Gemfile-rails71, Gemfile-rails70]
artifacts:
paths:
- "coverage/"
ruby33:
<<: *test_services
before_script:
- *install_deps
- *before_script
- *prepare_dbs
# export RUBYOPT='-rbundler/setup -rrbs/test/setup'
# export RBS_TEST_RAISE=true
# export RBS_TEST_LOGLEVEL=error
# export RBS_TEST_OPT='-Isig'
# export RBS_TEST_TARGET='Rodauth*'
image: "ruby:3.3"
script:
- bundle exec rake check_method_doc
- *test
parallel:
matrix:
- BUNDLE_GEMFILE: [Gemfile, Gemfile-rails80, Gemfile-rails72, Gemfile-rails71, Gemfile-rails70]
artifacts:
paths:
- "coverage/"
coverage:
stage: prepare
coverage: '/\(\d+.\d+%\) covered/'
before_script:
- gem install simplecov --no-doc
dependencies:
- jruby
- truffleruby
- ruby25
- ruby27
- ruby33
image: "ruby:3.3"
script:
# this is a workaround, because simplecov doesn't support relative paths.
#
# https://github.com/simplecov-ruby/simplecov/issues/887
#
# this is necessary in our case, because coverage files are generated inside
# the custom docker container, which runs in /home, and the absolute paths aren't
# gonna match the paths where the files are, once we merge them. Therefore,
# all of those have to be rewritten before the merge happens.
#
- find coverage -name "*resultset.json" -exec sed -i 's?/home?'`pwd`'?' {} \;
- rake coverage:report
artifacts:
paths:
- "coverage/"
pages:
stage: deploy
needs:
- coverage
image: "ruby:3.3"
variables:
BUNDLE_WITHOUT: test:coverage:assorted
before_script:
- gem install hanna-nouveau
script:
- rake prepare_website
- mkdir -p public/
- cp -r coverage/ public/
artifacts:
paths:
- rdoc/
- wiki/
- data/
- coverage/
- public/
# only:
# - master
prepare_release:
stage: prepare
rules:
- if: $CI_COMMIT_TAG
when: never
script:
- echo "EXTRA_DESCRIPTION=$(cat doc/release_notes/${${CI_COMMIT_TAG:1}//./_}.md)" >> variables.env
- echo "TAG=v$(cat CI_COMMIT_TAG)" >> variables.env
artifacts:
reports:
dotenv: variables.env
release:
stage: deploy
image: registry.gitlab.com/gitlab-org/release-cli:latest
needs:
- job: prepare_release
artifacts: true
rules:
- if: $CI_COMMIT_TAG
when: never
script:
- echo "running release_job for $TAG"
release:
name: 'Release $TAG'
description: '$EXTRA_DESCRIPTION'
tag_name: '$TAG'
ref: '$CI_COMMIT_SHA'