Skip to content

MSYS2 UCRT64 GCC/Clang TinyDrivers #55

MSYS2 UCRT64 GCC/Clang TinyDrivers

MSYS2 UCRT64 GCC/Clang TinyDrivers #55

# 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: MySQL90
# 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 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 }}