-
Notifications
You must be signed in to change notification settings - Fork 28
783 lines (670 loc) Β· 32.3 KB
/
linux-qt6.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
# MySQL
# ---
# Forces TLS connections with the caching_sha2_password and certificate validation, also validates
# certificate's CN for issuer and subject.
# PostgreSQL
# ---
# Forces TLS connections with the certificate authentication and full certificate validation
# using the clientname=DN map=dn in the pg_hba.conf, so the username is matched against
# the entire Distinguished Name (DN) of the client certificate and sslmode=verify-full
# on the libpq client side, so the the server host name is matched against the CN (Common Name)
# stored in the server certificate.
name: Linux GCC/Clang Qt6.4
on:
workflow_dispatch:
push:
branches:
- main
- gh-actions
jobs:
build:
name: cmake build / ctest
runs-on: ubuntu-24.04
env:
# Settings (constant variables)
# This number must also be changed in the matrix as env context can't be used in the matrix
TINY_LLVM_VERSION: 18
TINY_LLVM_APT_NAME: noble
# First value is a compressed data size
# gcc: ~ 165 * 3 + 100 ; clang: ~ 100 * 3 + 100
TINY_CCACHE_MAX_SIZE_GCC: 600M
TINY_CCACHE_MAX_SIZE_CLANG: 400M
# Clang and vcpkg use $(nproc) (max. available cores)
TINY_PARALLEL_GCC: 2
strategy:
matrix:
compiler:
- key: clang
name: clang18
apt: [ clang-18, lld-18 ]
command: clang++-18
- key: gcc
name: gcc12
apt: [ g++-12 ]
command: g++-12
steps:
- uses: actions/checkout@v4
- name: TinyORM prepare environment
run: |
runnerWorkPath=$(realpath "$RUNNER_WORKSPACE/..")
echo "TinyRunnerWorkPath=$runnerWorkPath" >> $GITHUB_ENV
sqlitePath="$runnerWorkPath/SQLite/$DB_SQLITE_DATABASE"
echo "TinySQLitePath=$sqlitePath" >> $GITHUB_ENV
[[ '${{ matrix.compiler.key }}' == 'gcc' ]] && ccacheMaxSize="$TINY_CCACHE_MAX_SIZE_GCC" \
|| ccacheMaxSize="$TINY_CCACHE_MAX_SIZE_CLANG"
echo "TinyCcacheMaxSize=$ccacheMaxSize" >> $GITHUB_ENV
[[ '${{ matrix.compiler.key }}' == 'gcc' ]] && parallel=$TINY_PARALLEL_GCC \
|| parallel=$(nproc)
echo "TinyParallel=$parallel" >> $GITHUB_ENV
echo "TinyParallelVcpkg=$(nproc)" >> $GITHUB_ENV
tinyormBuildName='${{ matrix.compiler.name }}-cmake-debug'
echo "TinyORMBuildName=$tinyormBuildName" >> $GITHUB_ENV
tinyormBuildTree="$RUNNER_WORKSPACE/TinyORM-builds-cmake/build-$tinyormBuildName"
echo "TinyORMBuildTree=$tinyormBuildTree" >> $GITHUB_ENV
env:
DB_SQLITE_DATABASE: ${{ secrets.DB_SQLITE_DATABASE }}
- name: Hosts add PostgreSQL server hostname
run: >-
sudo -- sh -c "echo '127.0.0.1\t$DB_PGSQL_HOST' >> /etc/hosts"
env:
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST_SSL }}
- name: PostgreSQL service start
run: |
sudo systemctl start postgresql.service
- name: PostgreSQL prepare environment
id: databases-initialize-postgresql
run: |
pgConfigFile=$(sudo --user=postgres --login -- \
psql --command='show config_file;' --no-align --tuples-only)
pgConfigPath=$(dirname "$pgConfigFile")
echo "PgConfigPath=$pgConfigPath" >> $GITHUB_OUTPUT
pgDataPath=$(sudo --user=postgres --login -- \
psql --command='show data_directory;' --no-align --tuples-only)
echo "PgDataPath=$pgDataPath" >> $GITHUB_OUTPUT
- name: PostgreSQL initialize configuration
working-directory: .github/resources/postgresql
run: |
sudo --user=postgres -- cp --recursive --target-directory="$pg_config_path" ./
echo "\
ssl_cert_file = 'server.crt'
ssl_key_file = 'server.key'
" | \
sudo tee --append "$pg_config_path/conf.d/90-crystal.conf" > /dev/null
env:
pg_config_path: ${{ steps.databases-initialize-postgresql.outputs.PgConfigPath }}
- name: PostgreSQL SSL certificates initialize
id: openssl-initialize-postgresql-certificates
run: |
folderPath="$TinyRunnerWorkPath/tiny-postgresql-certificates"
# Create an empty folder for generating certificates
sudo mkdir "$folderPath"
sudo chown runner:docker "$folderPath"
echo "FolderPath=$folderPath" >> $GITHUB_OUTPUT
# This hash invalidates the PostgreSQL certificates cache every month
hash=$(date +%4Y%2m)
echo "Hash=$hash" >> $GITHUB_OUTPUT
- name: PostgreSQL SSL certificates restore cache
uses: actions/cache/restore@v4
id: openssl-cache-postgresql-certificates
with:
path: |
${{ env.folder_path }}/*.crt
${{ env.folder_path }}/*.key
key: ${{ runner.os }}-openssl-${{ env.cache_name }}-${{ env.cache_hash }}
env:
# This hash invalidates this certificates cache every month
cache_hash: ${{ steps.openssl-initialize-postgresql-certificates.outputs.Hash }}
cache_name: postgresql-certificates
folder_path: ${{ steps.openssl-initialize-postgresql-certificates.outputs.FolderPath }}
- name: PostgreSQL SSL certificates generate
if: steps.openssl-cache-postgresql-certificates.outputs.cache-hit != 'true'
working-directory: ${{ steps.openssl-initialize-postgresql-certificates.outputs.FolderPath }}
run: |
echo '::group::Print openssl version'
openssl version -a
echo '::endgroup::'
echo '::group::CA certificate'
# -days 32 is important, -days 30 is not enough
openssl req -new -x509 -nodes -subj "$DB_PGSQL_SSL_SUBJECT_CA" -days 32 \
-keyout ./root.key -out ./root.crt
echo '::endgroup::'
echo '::group::Server certificate'
openssl req -new -nodes -subj "$DB_PGSQL_SSL_SUBJECT_SERVER" -keyout ./server.key -out \
./server.csr
OPENSSL_SAN="DNS:${DB_PGSQL_HOST}" \
openssl x509 -req -CA ./root.crt -CAkey ./root.key -days 32 -set_serial 01 \
-extfile "$extfile" -in ./server.csr -out ./server.crt
echo '::endgroup::'
echo '::group::Client certificate'
openssl req -new -nodes -subj "$DB_PGSQL_SSL_SUBJECT_CLIENT" -keyout ./postgresql.key \
-out ./postgresql.csr
OPENSSL_SAN="DNS:${DB_PGSQL_USERNAME}" \
openssl x509 -req -CA ./root.crt -CAkey ./root.key -days 32 -set_serial 02 \
-extfile "$extfile" -in ./postgresql.csr -out ./postgresql.crt
echo '::endgroup::'
env:
extfile: ${{ github.workspace }}/.github/resources/openssl/usr_cert.cnf
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST_SSL }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
DB_PGSQL_SSL_SUBJECT_CA: ${{ secrets.DB_PGSQL_SSL_SUBJECT_CA }}
DB_PGSQL_SSL_SUBJECT_SERVER: ${{ secrets.DB_PGSQL_SSL_SUBJECT_SERVER }}
DB_PGSQL_SSL_SUBJECT_CLIENT: ${{ secrets.DB_PGSQL_SSL_SUBJECT_CLIENT }}
- name: PostgreSQL SSL certificates print
working-directory: ${{ steps.openssl-initialize-postgresql-certificates.outputs.FolderPath }}
run: |
echo '::group::CA certificate'
openssl x509 -noout -text -in ./root.crt
echo '::endgroup::'
echo '::group::Server certificate'
openssl x509 -noout -text -in ./server.crt
echo '::endgroup::'
echo '::group::Client certificate'
openssl x509 -noout -text -in ./postgresql.crt
echo '::endgroup::'
# Always verify, regardless if certificates were newly generated or restored from the cache
- name: PostgreSQL SSL certificates verify
working-directory: ${{ steps.openssl-initialize-postgresql-certificates.outputs.FolderPath }}
run: |
openssl verify -CAfile ./root.crt ./server.crt ./postgresql.crt
# Save the cache only if certificates were newly generated
# The actions/cache/save allows to use the Move-Item during the install step
- name: PostgreSQL SSL certificates save cache
if: steps.openssl-cache-postgresql-certificates.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
${{ env.folder_path }}/*.crt
${{ env.folder_path }}/*.key
key: ${{ steps.openssl-cache-postgresql-certificates.outputs.cache-primary-key }}
env:
folder_path: ${{ steps.openssl-initialize-postgresql-certificates.outputs.FolderPath }}
- name: PostgreSQL SSL certificates install
working-directory: ${{ steps.openssl-initialize-postgresql-certificates.outputs.FolderPath }}
run: |
echo '::group::Install server certificates'
sudo cp --target-directory="$pg_data_path" ./root.crt
sudo mv --target-directory="$pg_data_path" ./server.{crt,key}
sudo chown postgres:postgres "$pg_data_path"/server.{crt,key} "$pg_data_path/root.crt"
sudo chmod 600 "$pg_data_path/server.key"
sudo chmod 640 "$pg_data_path"/{root,server}.crt
echo '::endgroup::'
echo '::group::Install client certificates'
folderPath=~/.postgresql
mkdir "$folderPath"
mv --target-directory="$folderPath" ./postgresql.{crt,key} ./root.crt
chmod 600 "$folderPath/postgresql.key"
chmod 640 "$folderPath"/{postgresql,root}.crt
echo '::endgroup::'
env:
pg_data_path: ${{ steps.databases-initialize-postgresql.outputs.PgDataPath }}
- name: PostgreSQL change ${{ secrets.DB_PGSQL_ROOT_USERNAME }} password
run: >-
sudo --user=postgres --login --
psql --command="alter user \"$DB_PGSQL_ROOT_USERNAME\"
with password '$DB_PGSQL_ROOT_PASSWORD';"
env:
DB_PGSQL_ROOT_PASSWORD: ${{ secrets.DB_PGSQL_ROOT_PASSWORD }}
DB_PGSQL_ROOT_USERNAME: ${{ secrets.DB_PGSQL_ROOT_USERNAME }}
- name: PostgreSQL create TinyORM user
run: >-
sudo --user=postgres --login --
psql --command="create user \"$DB_PGSQL_USERNAME\"
with createdb password '$DB_PGSQL_PASSWORD';"
env:
DB_PGSQL_PASSWORD: ${{ secrets.DB_PGSQL_PASSWORD }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
- name: PostgreSQL create TinyORM database
run: >-
sudo --user=postgres --login --
createdb --owner="$DB_PGSQL_USERNAME" "$DB_PGSQL_DATABASE"
env:
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
- name: PostgreSQL initialize client authentication
run: |
# Create the $PGDATA/tinyorm_dbs file with databases list
tinyormDbsPath="$pg_config_path/tinyorm_dbs"
databasesArr=("$DB_PGSQL_DATABASE" "$TINYORM_DATABASE_TESTS_SCHEMABUILDER")
(IFS=$'\n'; echo "${databasesArr[*]}") | \
sudo --user=postgres -- tee --append "$tinyormDbsPath" > /dev/null
sudo chmod 640 "$tinyormDbsPath"
pgHbaConf="$pg_config_path/pg_hba.conf"
pgHbaTmplTmpl='\\n\
# crystal\
hostssl @tinyorm_dbs %s 127.0.0.1\/32 cert clientname=DN map=dn'
pgHbaTmpl=$(printf "$pgHbaTmplTmpl" "$DB_PGSQL_USERNAME")
sudo sed --regexp-extended "s/(# +TYPE +DATABASE +USER +ADDRESS +METHOD)/\1$pgHbaTmpl/" \
--in-place "$pgHbaConf"
pgIdentConf="$pg_config_path/pg_ident.conf"
printf 'dn "/^%s$" %s' "$DB_PGSQL_SSL_DN" "$DB_PGSQL_USERNAME" | \
sudo tee --append "$pgIdentConf" > /dev/null
env:
pg_config_path: ${{ steps.databases-initialize-postgresql.outputs.PgConfigPath }}
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }}
DB_PGSQL_SSL_DN: ${{ secrets.DB_PGSQL_SSL_DN }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
TINYORM_DATABASE_TESTS_SCHEMABUILDER: ${{ secrets.TINYORM_DATABASE_TESTS_SCHEMABUILDER }}
- name: PostgreSQL service restart
run: |
sudo systemctl restart postgresql.service
- name: PostgreSQL service check status
run: |
echo '::group::Service status'
systemctl status postgresql.service
echo '::endgroup::'
echo '::group::pg_isready'
pg_isready
echo '::endgroup::'
# Adding the DB_MYSQL_HOST_CLIENT isn't strictly needed (works without it too)
- name: Hosts add MySQL server hostname
run: >-
sudo -- sh -c "echo '127.0.0.1\t$DB_MYSQL_HOST $DB_MYSQL_HOST_CLIENT' >> /etc/hosts"
env:
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST_SSL }}
DB_MYSQL_HOST_CLIENT: ${{ secrets.DB_MYSQL_HOST_CLIENT_SSL }}
- name: MySQL initialize crystal_mysqld.cnf configuration
working-directory: .github/resources/linux
run: |
sudo mv ./crystal_mysqld_ssl.cnf /etc/mysql/mysql.conf.d/crystal_mysqld.cnf
- name: MySQL initialize crystal_client.cnf configuration (global)
working-directory: .github/resources/linux
run: >-
cat ./crystal_client_ssl.template.cnf |
sed 's/{SSL_CERTIFICATES_PATH}/\/usr\/local\/share\/crystal-mysql/' |
sed "s/{MYSQL_HOST}/$DB_MYSQL_HOST/" |
sudo tee /etc/mysql/conf.d/crystal_client.cnf > /dev/null
env:
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST_SSL }}
# Remove certificates to generate are own
- name: MySQL SSL certificates remove
run: >-
sudo --user=mysql --
rm /var/lib/mysql/{ca,ca-key,server-cert,server-key,client-cert,client-key}.pem
- name: MySQL SSL certificates initialize
id: openssl-initialize-mysql-certificates
run: |
folderPath="$TinyRunnerWorkPath/tiny-mysql-certificates"
# Create an empty folder for generating certificates
sudo mkdir "$folderPath"
sudo chown runner:docker "$folderPath"
echo "FolderPath=$folderPath" >> $GITHUB_OUTPUT
# This hash invalidates the MySQL certificates cache every month
hash=$(date +%4Y%2m)
echo "Hash=$hash" >> $GITHUB_OUTPUT
- name: MySQL SSL certificates restore cache
uses: actions/cache/restore@v4
id: openssl-cache-mysql-certificates
with:
path: |
${{ env.folder_path }}/*.pem
key: ${{ runner.os }}-openssl-${{ env.cache_name }}-${{ env.cache_hash }}
env:
# This hash invalidates this certificates cache every month
cache_hash: ${{ steps.openssl-initialize-mysql-certificates.outputs.Hash }}
cache_name: mysql-certificates
folder_path: ${{ steps.openssl-initialize-mysql-certificates.outputs.FolderPath }}
- name: MySQL SSL certificates generate
if: steps.openssl-cache-mysql-certificates.outputs.cache-hit != 'true'
working-directory: ${{ steps.openssl-initialize-mysql-certificates.outputs.FolderPath }}
run: |
echo '::group::Print openssl version'
openssl version -a
echo '::endgroup::'
echo '::group::CA certificate'
# -days 32 is important, -days 30 is not enough
openssl req -new -x509 -nodes -subj "$DB_MYSQL_SSL_SUBJECT_CA" -days 32 \
-keyout ./ca-key.pem -out ./ca.pem
echo '::endgroup::'
echo '::group::Server certificate'
openssl req -new -nodes -subj "$DB_MYSQL_SSL_SUBJECT_SERVER" -keyout ./server-key.pem -out \
./server-req.pem
OPENSSL_SAN="DNS:${DB_MYSQL_HOST}" \
openssl x509 -req -CA ./ca.pem -CAkey ./ca-key.pem -days 32 -set_serial 01 \
-extfile "$extfile" -in ./server-req.pem -out ./server-cert.pem
echo '::endgroup::'
echo '::group::Client certificate'
openssl req -new -nodes -subj "$DB_MYSQL_SSL_SUBJECT_CLIENT" -keyout ./client-key.pem \
-out ./client-req.pem
OPENSSL_SAN="DNS:${DB_MYSQL_HOST_CLIENT}" \
openssl x509 -req -CA ./ca.pem -CAkey ./ca-key.pem -days 32 -set_serial 02 \
-extfile "$extfile" -in ./client-req.pem -out ./client-cert.pem
echo '::endgroup::'
env:
extfile: ${{ github.workspace }}/.github/resources/openssl/usr_cert.cnf
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST_SSL }}
DB_MYSQL_HOST_CLIENT: ${{ secrets.DB_MYSQL_HOST_CLIENT_SSL }}
DB_MYSQL_SSL_SUBJECT_CA: ${{ secrets.DB_MYSQL_SSL_SUBJECT_CA }}
DB_MYSQL_SSL_SUBJECT_SERVER: ${{ secrets.DB_MYSQL_SSL_SUBJECT_SERVER }}
DB_MYSQL_SSL_SUBJECT_CLIENT: ${{ secrets.DB_MYSQL_SSL_SUBJECT_CLIENT }}
# Always verify, regardless if certificates were newly generated or restored from the cache
- name: MySQL SSL certificates verify
working-directory: ${{ steps.openssl-initialize-mysql-certificates.outputs.FolderPath }}
run: |
openssl verify -CAfile ./ca.pem ./server-cert.pem ./client-cert.pem
# Save the cache only if certificates were newly generated
# The actions/cache/save allows to use the Move-Item during the install step
- name: MySQL SSL certificates save cache
if: steps.openssl-cache-mysql-certificates.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
${{ env.folder_path }}/*.pem
key: ${{ steps.openssl-cache-mysql-certificates.outputs.cache-primary-key }}
env:
folder_path: ${{ steps.openssl-initialize-mysql-certificates.outputs.FolderPath }}
- name: MySQL SSL certificates install
working-directory: ${{ steps.openssl-initialize-mysql-certificates.outputs.FolderPath }}
run: |
mysqlDataPath=/var/lib/mysql
echo '::group::Install CA certificate'
sudo mv --target-directory="$mysqlDataPath" ./ca.pem
sudo chmod 644 "$mysqlDataPath/ca.pem"
sudo chown mysql:mysql "$mysqlDataPath/ca.pem"
echo '::endgroup::'
echo '::group::Install server certificates'
sudo mv --target-directory="$mysqlDataPath" ./server-{cert,key}.pem
sudo chmod 640 "$mysqlDataPath/server-cert.pem"
sudo chmod 600 "$mysqlDataPath/server-key.pem"
sudo chown mysql:mysql "$mysqlDataPath"/server-{cert,key}.pem
echo '::endgroup::'
echo '::group::Install client certificates'
sudo mv --target-directory="$mysqlDataPath" ./client-{cert,key}.pem
sudo chmod 640 "$mysqlDataPath/client-cert.pem"
sudo chmod 600 "$mysqlDataPath/client-key.pem"
sudo chown mysql:mysql "$mysqlDataPath"/client-{cert,key}.pem
echo '::endgroup::'
env:
pg_data_path: ${{ steps.databases-initialize-mysql.outputs.PgDataPath }}
- name: MySQL copy SSL certificates for runner user
run: |
crystalMySqlPath=/usr/local/share/crystal-mysql
sudo mkdir --parents "$crystalMySqlPath"
cd "$crystalMySqlPath"
sudo cp --target-directory="$crystalMySqlPath" \
/var/lib/mysql/{ca,client-cert,client-key}.pem
sudo chown --recursive root:root "$crystalMySqlPath"
sudo chmod 444 "$crystalMySqlPath"/{ca,client-cert,client-key}.pem
- name: MySQL service start
run: |
sudo systemctl start mysql.service
# Securing the root account even on localhost is for testing to make sure that everything
# works as expected
- name: MySQL change ${{ secrets.DB_MYSQL_ROOT_USERNAME }} password
run: >-
echo "
alter user '$DB_MYSQL_ROOT_USERNAME'@'localhost'
identified with caching_sha2_password by '$DB_MYSQL_ROOT_PASSWORD'
require issuer '$DB_MYSQL_SSL_SUBJECT_CA' and
subject '$DB_MYSQL_SSL_SUBJECT_CLIENT';" |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD_DEFAULT"
env:
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }}
DB_MYSQL_ROOT_PASSWORD_DEFAULT: ${{ secrets.DB_MYSQL_ROOT_PASSWORD_DEFAULT }}
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }}
DB_MYSQL_SSL_SUBJECT_CA: ${{ secrets.DB_MYSQL_SSL_SUBJECT_CA }}
DB_MYSQL_SSL_SUBJECT_CLIENT: ${{ secrets.DB_MYSQL_SSL_SUBJECT_CLIENT }}
- name: MySQL populate time zone tables π
run: >-
mysql_tzinfo_to_sql /usr/share/zoneinfo |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD" mysql
sudo systemctl restart mysql.service
env:
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }}
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }}
- name: MySQL service check status
run: |
echo '::group::Service status'
systemctl status mysql.service
echo '::endgroup::'
echo '::group::Service is-active check'
systemctl is-active --quiet mysql.service
echo '::endgroup::'
echo '::group::Ping'
mysqladmin --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD" ping
echo '::endgroup::'
env:
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }}
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }}
- name: MySQL create TinyORM database
run: >-
echo "
create database if not exists \`$DB_MYSQL_DATABASE\`
default character set $DB_MYSQL_CHARSET
default collate $DB_MYSQL_COLLATION;" |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD"
env:
DB_MYSQL_CHARSET: ${{ secrets.DB_MYSQL_CHARSET }}
DB_MYSQL_COLLATION: ${{ secrets.DB_MYSQL_COLLATION }}
DB_MYSQL_DATABASE: ${{ secrets.DB_MYSQL_DATABASE }}
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }}
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }}
- name: MySQL create TinyORM user
run: >-
echo "
create user '$DB_MYSQL_USERNAME'@'%'
identified with caching_sha2_password by '$DB_MYSQL_PASSWORD'
require issuer '$DB_MYSQL_SSL_SUBJECT_CA' and
subject '$DB_MYSQL_SSL_SUBJECT_CLIENT';
grant all privileges on \`tinyorm\\_%\`.* to '$DB_MYSQL_USERNAME'@'%';
grant select on \`mysql\`.\`time_zone_name\` to '$DB_MYSQL_USERNAME'@'%';
flush privileges;" |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD"
env:
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }}
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }}
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }}
DB_MYSQL_SSL_SUBJECT_CA: ${{ secrets.DB_MYSQL_SSL_SUBJECT_CA }}
DB_MYSQL_SSL_SUBJECT_CLIENT: ${{ secrets.DB_MYSQL_SSL_SUBJECT_CLIENT }}
- name: SQLite create TinyORM database
run: |
mkdir --parents "$(dirname "$TinySQLitePath")"
touch "$TinySQLitePath"
- name: Print MySQL, PostgreSQL, and SQLite database versions
run: |
echo '::group::MySQL version'
mysql --version
echo '::endgroup::'
echo '::group::PostgreSQL version'
pg_config --version
echo '::endgroup::'
echo '::group::SQLite version'
sqlite3 --version
echo '::endgroup::'
- name: add-apt-repository Clang ${{ env.TINY_LLVM_VERSION }}
if: matrix.compiler.key == 'clang'
run: >-
wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key |
sudo tee /etc/apt/trusted.gpg.d/llvm-${{ env.TINY_LLVM_VERSION }}.asc > /dev/null
sudo add-apt-repository --yes
--sourceslist 'deb http://apt.llvm.org/${{ env.TINY_LLVM_APT_NAME }}/
llvm-toolchain-${{ env.TINY_LLVM_APT_NAME }}-${{ env.TINY_LLVM_VERSION }} main'
- name: apt update
run: |
sudo apt update
- name: apt install ${{ join(matrix.compiler.apt, ', ') }}, Qt 6 base, and ccache
run: >-
sudo apt install --yes ${{ join(matrix.compiler.apt, ' ') }}
qt6-base-dev libqt6sql6-mysql libqt6sql6-sqlite libqt6sql6-psql ccache
# No need to use lukka/get-cmake, these images always have latest version
- name: Ninja install latest version
uses: seanmiddleditch/gha-setup-ninja@master
with:
destination: ${{ env.TinyRunnerWorkPath }}/ninja-build
- name: Ccache initialize
id: ccache-initialize-cache
run: |
cachePath=$(ccache --get-config cache_dir)
echo "CachePath=$cachePath" >> $GITHUB_OUTPUT
echo "ImageOS=$ImageOS" >> $GITHUB_OUTPUT
- name: Ccache restore cache πΊ
uses: actions/cache@v4
with:
path: ${{ env.cache_path }}
key: ${{ runner.os }}-${{ env.image_os }}-ccache-${{ env.cache_name }}-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-${{ env.image_os }}-ccache-${{ env.cache_name }}-
env:
cache_name: ${{ matrix.compiler.name }}-qt6
cache_path: ${{ steps.ccache-initialize-cache.outputs.CachePath }}
image_os: ${{ steps.ccache-initialize-cache.outputs.ImageOS }}
- name: Ccache prepare configuration π₯³
run: |
ccache --set-config max_size="$TinyCcacheMaxSize"
ccache --set-config sloppiness=pch_defines,time_macros
- name: Ccache print version and configuration
run: |
echo '::group::Print version'
ccache --version
echo '::endgroup::'
echo '::group::Print ccache config'
ccache --show-config
echo '::endgroup::'
- name: vcpkg prepare environment
run: |
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV
echo 'VCPKG_DEFAULT_TRIPLET=x64-linux-dynamic' >> $GITHUB_ENV
echo "VCPKG_MAX_CONCURRENCY=$TinyParallelVcpkg" >> $GITHUB_ENV
- name: CMake print version
run: |
cmake --version
- name: Ccache clear statistics
run: |
ccache --zero-stats
- name: TinyORM cmake configure (${{ env.TinyORMBuildName }})
run: >-
cmake --log-level=DEBUG --log-context
-S .
-B "$TinyORMBuildTree"
-G Ninja
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache
-D CMAKE_CXX_COMPILER:FILEPATH=${{ matrix.compiler.command }}
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
-D CMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=ON
-D CMAKE_EXPORT_PACKAGE_REGISTRY:BOOL=OFF
-D CMAKE_BUILD_TYPE:STRING=Debug
-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF
-D VCPKG_APPLOCAL_DEPS:BOOL=OFF
-D VERBOSE_CONFIGURE:BOOL=ON
-D BUILD_TREE_DEPLOY:BOOL=OFF
-D STRICT_MODE:BOOL=OFF
-D MYSQL_PING:BOOL=ON
-D BUILD_TESTS:BOOL=ON
-D ORM:BOOL=ON
-D TOM:BOOL=ON
-D TOM_EXAMPLE:BOOL=ON
-D BUILD_DRIVERS:BOOL=OFF
- name: TinyORM cmake build β¨ (${{ env.TinyORMBuildName }})
working-directory: ${{ env.TinyORMBuildTree }}
run: |
cmake --build . --target all --parallel $TinyParallel
- name: Ccache print statistics
run: |
ccache --show-stats --verbose
- name: TinyORM add on the $LD_LIBRARY_PATH
run: |
echo "LD_LIBRARY_PATH=$TinyORMBuildTree${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" >> $env:GITHUB_ENV
- name: Create and Seed tables for unit tests π
working-directory: ${{ env.TinyORMBuildTree }}/tests/testdata_tom
run: >-
./tom_testdata migrate
--database=tinyorm_testdata_tom_mysql,tinyorm_testdata_tom_postgres,tinyorm_testdata_tom_sqlite
--seed --no-ansi
env:
DB_MYSQL_CHARSET: ${{ secrets.DB_MYSQL_CHARSET }}
DB_MYSQL_COLLATION: ${{ secrets.DB_MYSQL_COLLATION }}
DB_MYSQL_DATABASE: ${{ secrets.DB_MYSQL_DATABASE }}
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST_SSL }}
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }}
DB_MYSQL_SSL_CA: /usr/local/share/crystal-mysql/ca.pem
DB_MYSQL_SSL_CERT: /usr/local/share/crystal-mysql/client-cert.pem
DB_MYSQL_SSL_KEY: /usr/local/share/crystal-mysql/client-key.pem
DB_MYSQL_SSL_MODE: ${{ secrets.DB_MYSQL_SSL_MODE }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }}
DB_PGSQL_CHARSET: ${{ secrets.DB_PGSQL_CHARSET }}
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }}
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST_SSL }}
DB_PGSQL_SEARCHPATH: ${{ secrets.DB_PGSQL_SEARCHPATH }}
DB_PGSQL_SSLMODE: ${{ secrets.DB_PGSQL_SSLMODE }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
DB_SQLITE_DATABASE: ${{ env.TinySQLitePath }}
TOM_TESTDATA_ENV: ${{ vars.TOM_TESTDATA_ENV }}
- name: TinyORM execute ctest π₯
working-directory: ${{ env.TinyORMBuildTree }}
run: |
ctest --output-on-failure --parallel $(($TinyParallel + $(nproc) / 2))
env:
DB_MYSQL_CHARSET: ${{ secrets.DB_MYSQL_CHARSET }}
DB_MYSQL_COLLATION: ${{ secrets.DB_MYSQL_COLLATION }}
DB_MYSQL_DATABASE: ${{ secrets.DB_MYSQL_DATABASE }}
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST_SSL }}
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }}
DB_MYSQL_SSL_CA: /usr/local/share/crystal-mysql/ca.pem
DB_MYSQL_SSL_CERT: /usr/local/share/crystal-mysql/client-cert.pem
DB_MYSQL_SSL_KEY: /usr/local/share/crystal-mysql/client-key.pem
DB_MYSQL_SSL_MODE: ${{ secrets.DB_MYSQL_SSL_MODE }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }}
DB_PGSQL_CHARSET: ${{ secrets.DB_PGSQL_CHARSET }}
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }}
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST_SSL }}
DB_PGSQL_SEARCHPATH: ${{ secrets.DB_PGSQL_SEARCHPATH }}
DB_PGSQL_SSLMODE: ${{ secrets.DB_PGSQL_SSLMODE }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
DB_SQLITE_DATABASE: ${{ env.TinySQLitePath }}
TOM_TESTS_ENV: ${{ vars.TOM_TESTS_ENV }}
- name: Tom example test some commands (MySQL) π
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom
run: |
./tom migrate:fresh --database=tinyorm_tom_mysql --no-ansi
./tom migrate:uninstall --reset --database=tinyorm_tom_mysql --no-ansi
./tom migrate:install --database=tinyorm_tom_mysql --no-ansi
./tom migrate --database=tinyorm_tom_mysql --seed --no-ansi
./tom migrate:status --database=tinyorm_tom_mysql --no-ansi
./tom migrate:refresh --database=tinyorm_tom_mysql --seed --no-ansi
./tom migrate:reset --database=tinyorm_tom_mysql --no-ansi
./tom migrate:uninstall --database=tinyorm_tom_mysql --no-ansi
env:
DB_MYSQL_CHARSET: ${{ secrets.DB_MYSQL_CHARSET }}
DB_MYSQL_COLLATION: ${{ secrets.DB_MYSQL_COLLATION }}
DB_MYSQL_DATABASE: ${{ secrets.DB_MYSQL_DATABASE }}
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST_SSL }}
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }}
DB_MYSQL_SSL_CA: /usr/local/share/crystal-mysql/ca.pem
DB_MYSQL_SSL_CERT: /usr/local/share/crystal-mysql/client-cert.pem
DB_MYSQL_SSL_KEY: /usr/local/share/crystal-mysql/client-key.pem
DB_MYSQL_SSL_MODE: ${{ secrets.DB_MYSQL_SSL_MODE }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }}
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }}
- name: Tom example test some commands (PostgreSQL) π
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom
run: |
./tom migrate:fresh --database=tinyorm_tom_postgres --no-ansi
./tom migrate:uninstall --reset --database=tinyorm_tom_postgres --no-ansi
./tom migrate:install --database=tinyorm_tom_postgres --no-ansi
./tom migrate --database=tinyorm_tom_postgres --seed --no-ansi
./tom migrate:status --database=tinyorm_tom_postgres --no-ansi
./tom migrate:refresh --database=tinyorm_tom_postgres --seed --no-ansi
./tom migrate:reset --database=tinyorm_tom_postgres --no-ansi
./tom migrate:uninstall --database=tinyorm_tom_postgres --no-ansi
env:
DB_PGSQL_CHARSET: ${{ secrets.DB_PGSQL_CHARSET }}
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }}
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST_SSL }}
DB_PGSQL_SEARCHPATH: ${{ secrets.DB_PGSQL_SEARCHPATH }}
DB_PGSQL_SSLMODE: ${{ secrets.DB_PGSQL_SSLMODE }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }}
- name: Tom example test some commands (SQLite) π
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom
run: |
./tom migrate:fresh --database=tinyorm_tom_sqlite --no-ansi
./tom migrate:uninstall --reset --database=tinyorm_tom_sqlite --no-ansi
./tom migrate:install --database=tinyorm_tom_sqlite --no-ansi
./tom migrate --database=tinyorm_tom_sqlite --seed --no-ansi
./tom migrate:status --database=tinyorm_tom_sqlite --no-ansi
./tom migrate:refresh --database=tinyorm_tom_sqlite --seed --no-ansi
./tom migrate:reset --database=tinyorm_tom_sqlite --no-ansi
./tom migrate:uninstall --database=tinyorm_tom_sqlite --no-ansi
env:
DB_SQLITE_DATABASE: ${{ env.TinySQLitePath }}
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }}