-
Notifications
You must be signed in to change notification settings - Fork 28
325 lines (267 loc) · 12.4 KB
/
msys2-ucrt64-drivers.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
# MySQL
# ---
# Both use the default unencrypted database connections because maria client can't connect
# to the MySQL >= 8.0.34 or >=8.1, there is some problem in TLS 1.2 and 1.3 connection, it can't
# select correct cipher. I will revert this back in the future when it will be fixed.
# ccache
# ---
# Uses /ccache_msys2_gcc folder and compressed cache size is 1.2G (after whole workflow finishes)
# Uses /ccache_msys2_clang folder and compressed cache size is 1G (after whole workflow finishes)
# Notes
# ---
# Build folders must be manually deleted after bumping version numbers because ccache doesn't get it
# and then the tst_Versions test case fails.
name: MSYS2 UCRT64 GCC/Clang TinyDrivers
on: workflow_dispatch
concurrency:
group: tinyorm-windows
# I will not remove the build folders before a job execution it's not necessary and
# it will be faster this way. I can still remove them manually if needed or
# if something goes wrong.
jobs:
build:
name: cmake build / ctest
# Self-hosted runner is Windows 11 (Release Preview channel - 24H2)
runs-on: [ self-hosted, windows ]
env:
# Settings (constant variables)
# Don't user more than 3 for GCC, it would need 64GB RAM (no money 💵)
TINY_PARALLEL_GCC: 3
TINY_PARALLEL_CLANG_OR_VCPKG: 9
TINY_MYSQL_SERVICE: MySQL84
# Used by the msys2.cmd script and cygpath.exe
MSYS2_ROOT: C:\msys64
# State variables
TINY_VCPKG_NEEDS_UPGRADE: false
strategy:
matrix:
drivers-type: [ Shared, Loadable, Static ]
build-type:
- key: debug
name: Debug
- key: release
name: Release
compiler:
- key: clang
command: clang++.exe
- key: gcc
command: g++.exe
steps:
- uses: actions/checkout@v4
with:
path: main
- name: TinyORM prepare environment
run: |
$runnerWorkPath = Resolve-Path -Path "$env:RUNNER_WORKSPACE/.."
"TinyRunnerWorkPath=$runnerWorkPath" >> $env:GITHUB_ENV
$tinyormPath = Resolve-Path -Path ./main
"TinyORMPath=$tinyormPath" >> $env:GITHUB_ENV
# I had to shorten the folder name because of long path names, removed build-Tiny
# at the beginning, u means ucrt64.
$tinyormBuildName = 'Drivers-msys2-u-${{ matrix.compiler.key }}-' +
'${{ matrix.drivers-type }}-${{ matrix.build-type.key }}'
"TinyORMBuildName=$tinyormBuildName" >> $env:GITHUB_ENV
$tinyormBuildTree = Join-Path -Path $env:RUNNER_WORKSPACE TinyORM-builds-cmake `
$tinyormBuildName
"TinyORMBuildTree=$tinyormBuildTree" >> $env:GITHUB_ENV
$tinyormBuildTreeCyg = & "$env:MSYS2_ROOT\usr\bin\cygpath.exe" --unix $tinyormBuildTree
"TinyORMBuildTreeCyg=$tinyormBuildTreeCyg" >> $env:GITHUB_ENV
$parallel = '${{ matrix.compiler.key }}' -ceq 'gcc' ? $env:TINY_PARALLEL_GCC :
$env:TINY_PARALLEL_CLANG_OR_VCPKG
"TinyParallel=$parallel" >> $env:GITHUB_ENV
"TinyParallelVcpkg=$env:TINY_PARALLEL_CLANG_OR_VCPKG" >> $env:GITHUB_ENV
- name: MySQL service check status
run: |
Write-Output '::group::Get-Service'
$mysqlService = Get-Service $env:TINY_MYSQL_SERVICE
Write-Output $mysqlService
Write-Output '::endgroup::'
Write-Output '::group::Service running check'
$mysqlService.status.ToString() -ceq 'Running' -or `
$(throw "$env:TINY_MYSQL_SERVICE service is not running") > $null
Write-Output '::endgroup::'
# .mylogin.cnf isn't detected because self-hosted runners are running under
# the NT AUTHORITY\NetworkService account so the $env:APPDATA points to:
# C:\WINDOWS\ServiceProfiles\NetworkService\AppData\Roaming
# [client] sections from the $env:ProgramFiles\MySQL\MySQL Server 8.x\my.ini are picked up
# correctly.
Write-Output '::group::Ping'
mysqladmin.exe --host=$env:DB_MYSQL_HOST --user=$env:DB_MYSQL_USERNAME `
--password=$env:DB_MYSQL_PASSWORD ping
Write-Output '::endgroup::'
env:
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST_SELF }}
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD_SELF }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF }}
# This is a little useless because mysql.exe isn't reachable from the MSYS2 shell but I leave it
# here as it for sure prints a MySQL version on the host self-hosted runner instance.
- name: Print MySQL database version
run: |
mysql.exe --version
# I will not use the msys2/setup-msys action here as I will manage it manually on the host
# machine, it would be a waste of resources because everything is already installed and
# up to date.
# msys2.cmd helper script for GitHub self-hosted runner to avoid using msys2_shell.cmd
- name: MSYS2 UCRT64 prepare environment
run: |
'E:\actions-runners\bin' >> $env:GITHUB_PATH
# Don't use the default CCACHE_DIR path on self-hosted runners and use a separate ccache folder
# for MSYS2 and compiler.
- name: Ccache prepare environment
run: |
$ccacheDirPath = Join-Path $env:RUNNER_WORKSPACE ccache_msys2_${{ matrix.compiler.key }}
"CCACHE_DIR=$ccacheDirPath" >> $env:GITHUB_ENV
- name: Ccache print version and configuration
shell: msys2 {0}
run: |
echo '::group::Print version'
ccache.exe --version
echo '::endgroup::'
echo '::group::Print ccache config'
ccache.exe --show-config
echo '::endgroup::'
# Define the VCPKG_DEFAULT_BINARY_CACHE because it takes ~20G in C:\Windows\ServiceProfiles
- name: vcpkg prepare environment
shell: msys2 {0}
run: |
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV
echo 'VCPKG_DEFAULT_TRIPLET=x64-mingw-dynamic' >> $GITHUB_ENV
echo 'VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-dynamic' >> $GITHUB_ENV
echo "VCPKG_MAX_CONCURRENCY=$TinyParallelVcpkg" >> $GITHUB_ENV
vcpkgArchivesPath=$(cygpath.exe --windows "$RUNNER_WORKSPACE\vcpkg_archives")
echo "VCPKG_DEFAULT_BINARY_CACHE=$vcpkgArchivesPath" >> $GITHUB_ENV
- name: vcpkg create binary caching folder
run: |
if (-not (Test-Path $env:VCPKG_DEFAULT_BINARY_CACHE)) {
New-Item -Type Directory $env:VCPKG_DEFAULT_BINARY_CACHE
}
- name: vcpkg needs upgrade? (once per day)
run: |
$vcpkgUpgradedAtFilepath = "$env:RUNNER_WORKSPACE/.vcpkg_upgraded_at"
if (-not (Test-Path -Path $vcpkgUpgradedAtFilepath)) {
'TINY_VCPKG_NEEDS_UPGRADE=true' >> $env:GITHUB_ENV
exit 0
}
$datePreviousUpgrade = New-Object System.DateTime
$result = [System.DateTime]::TryParseExact( `
(Get-Content "$env:RUNNER_WORKSPACE/.vcpkg_upgraded_at"), 'yyyyMMdd', `
[cultureinfo]::InvariantCulture, `
[System.Globalization.DateTimeStyles]::None -bor `
[System.Globalization.DateTimeStyles]::AssumeLocal, [ref] $datePreviousUpgrade)
if (-not $result) {
throw "Parsing the '.vcpkg_upgraded_at' failed."
}
$dateToday = Get-Date -Hour 0 -Minute 0 -Second 0 -Millisecond 0
if ($datePreviousUpgrade -lt $dateToday) {
'TINY_VCPKG_NEEDS_UPGRADE=true' >> $env:GITHUB_ENV
}
- name: vcpkg upgrade repository (latest version)
if: env.TINY_VCPKG_NEEDS_UPGRADE == 'true'
run: |
Set-Location -Path $env:VCPKG_INSTALLATION_ROOT
git.exe switch master
git.exe fetch --tags origin
git.exe reset --hard origin/master
.\bootstrap-vcpkg.bat
Get-Date -Format 'yyyyMMdd' > "$env:RUNNER_WORKSPACE/.vcpkg_upgraded_at"
- name: CMake print version
shell: msys2 {0}
run: |
cmake.exe --version
- name: vcpkg print version
shell: msys2 {0}
run: |
"$VCPKG_INSTALLATION_ROOT/vcpkg.exe" --version
- name: Ccache clear statistics
shell: msys2 {0}
run: |
ccache.exe --zero-stats
# BUILD_TREE_DEPLOY isn't needed because CMake forces linker to write absolute paths to exe, but
# I enable it anyway to test this feature.
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct as we need to test missing #include-s.
- name: TinyORM cmake configure (${{ env.TinyORMBuildName }})
shell: msys2 {0}
working-directory: ${{ env.TinyORMPath }}
run: >-
cmake.exe --log-level=DEBUG --log-context
-S .
-B "$TinyORMBuildTreeCyg"
-G Ninja
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache.exe
-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=${{ matrix.build-type.name }}
-D CMAKE_CXX_SCAN_FOR_MODULES:BOOL=OFF
-D VCPKG_APPLOCAL_DEPS:BOOL=OFF
-D VERBOSE_CONFIGURE:BOOL=ON
-D BUILD_TREE_DEPLOY:BOOL=ON
-D MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=ON
-D STRICT_MODE:BOOL=ON
-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=ON
-D DRIVERS_TYPE:STRING=${{ matrix.drivers-type }}
- name: TinyORM cmake build ✨ (${{ env.TinyORMBuildName }})
shell: msys2 {0}
working-directory: ${{ env.TinyORMBuildTree }}
run: |
cmake.exe --build . --target all --parallel $TinyParallel
- name: Ccache print statistics
shell: msys2 {0}
run: |
ccache.exe --show-stats --verbose
# Used migrate:fresh instead (is safer)
- name: Create and Seed tables for unit tests 🎉
shell: msys2 {0}
working-directory: ${{ env.TinyORMBuildTree }}/tests/testdata_tom
run: |
export PATH="$TinyORMBuildTreeCyg"${PATH:+:}"$PATH"
./tom_testdata.exe migrate:fresh --database=tinyorm_testdata_tom_mysql --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_SELF }}
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD_SELF_MSYS2 }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF_MSYS2 }}
TOM_TESTDATA_ENV: ${{ vars.TOM_TESTDATA_ENV }}
# $NUMBER_OF_PROCESSORS / 2 : rounds down; also don't use nproc here!
- name: TinyORM execute ctest 🔥
shell: msys2 {0}
working-directory: ${{ env.TinyORMBuildTree }}
run: |
ctest.exe --output-on-failure --parallel $(($TinyParallel + $NUMBER_OF_PROCESSORS / 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_SELF }}
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD_SELF_MSYS2 }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF_MSYS2 }}
TOM_TESTS_ENV: ${{ vars.TOM_TESTS_ENV }}
- name: Tom example test some commands (MySQL) 🚀
shell: msys2 {0}
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom
run: |
export PATH="$TinyORMBuildTreeCyg"${PATH:+:}"$PATH"
./tom.exe migrate:fresh --database=tinyorm_tom_mysql --no-ansi
./tom.exe migrate:uninstall --reset --database=tinyorm_tom_mysql --no-ansi
./tom.exe migrate:install --database=tinyorm_tom_mysql --no-ansi
./tom.exe migrate --database=tinyorm_tom_mysql --seed --no-ansi
./tom.exe migrate:status --database=tinyorm_tom_mysql --no-ansi
./tom.exe migrate:refresh --database=tinyorm_tom_mysql --seed --no-ansi
./tom.exe migrate:reset --database=tinyorm_tom_mysql --no-ansi
./tom.exe 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_SELF }}
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD_SELF_MSYS2 }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF_MSYS2 }}
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }}