MSVC2022 Qt6.7 TinyDrivers #76
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQL | |
# --- | |
# Forces TLS connections with the caching_sha2_password and certificate validation, also validates | |
# certificate's CN for issuer and subject. | |
# ccache | |
# --- | |
# Uses /ccache_drivers folder and the compressed cache size is 1.8G (after whole workflow finishes) | |
name: MSVC2022 Qt6.7 TinyDrivers | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- gh-actions | |
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) | |
TINY_QT_VERSION: 6.7.2 | |
TINY_QT_SPEC: win64_msvc2019_64 | |
TINY_MYSQL_SERVICE: MySQL90 | |
# My system is unresponsive with 10 | |
TINY_PARALLEL: 8 | |
# State variables | |
TINY_VCPKG_NEEDS_UPGRADE: false | |
strategy: | |
matrix: | |
lto: [ OFF ] | |
drivers-type: [ Shared, Loadable, Static ] | |
build-type: | |
- key: debug | |
name: Debug | |
- key: release | |
name: Release | |
include: | |
- lto: ON | |
drivers-type: Loadable | |
build-type: | |
key: release | |
name: Release | |
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 | |
$mysqlExePath = (Get-Command -Name mysql.exe).Source | |
$mysqlInstallationPath = Split-Path -Parent -Path (Split-Path -Parent -Path $mysqlExePath) | |
"TinyMySQLInstallationPath=$mysqlInstallationPath" >> $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. | |
$tinyormBuildName = 'Drivers-msvc-${{ matrix.drivers-type }}-${{ matrix.build-type.key }}' + | |
('${{ matrix.lto }}' -ceq 'ON' ? '-lto' : '') | |
"TinyORMBuildName=$tinyormBuildName" >> $env:GITHUB_ENV | |
$tinyormBuildTree = Join-Path -Path $env:RUNNER_WORKSPACE TinyORM-builds-cmake ` | |
$tinyormBuildName | |
"TinyORMBuildTree=$tinyormBuildTree" >> $env:GITHUB_ENV | |
$qtSpecSplitted = $env:TINY_QT_SPEC.Split('_') | |
$qtSpecPlain = $qtSpecSplitted[1..($qtSpecSplitted.Count - 1)] -join '_' | |
"TinyQtSpecPlain=$qtSpecPlain" >> $env:GITHUB_ENV | |
- name: MySQL add libmysql.dll on the $env:Path, INCLUDE, and LIB | |
run: | | |
"$env:TinyMySQLInstallationPath\lib" >> $env:GITHUB_PATH | |
# Needed by the lastest FindMySQL.cmake module, it stopped working without this | |
"INCLUDE=$env:TinyMySQLInstallationPath\include" >> $env:GITHUB_ENV | |
"LIB=$env:TinyMySQLInstallationPath\lib" >> $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 }} | |
- name: Print MySQL database version | |
run: | | |
mysql.exe --version | |
- name: Ninja install latest version | |
uses: seanmiddleditch/gha-setup-ninja@master | |
with: | |
destination: ${{ env.TinyRunnerWorkPath }}/ninja-build | |
- name: Visual Studio 2022 pwsh shell setup | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: x64 | |
# Don't use the default CCACHE_DIR path on self-hosted runners | |
- name: Ccache prepare environment | |
run: | | |
$ccacheDirPath = Join-Path -Path $env:RUNNER_WORKSPACE -ChildPath ccache_drivers | |
"CCACHE_DIR=$ccacheDirPath" >> $env:GITHUB_ENV | |
# I'm managing the ccache configuration manually on self-hosted runners using the ccache.conf | |
# because it's used by more actions. | |
- name: Ccache print version and configuration | |
run: | | |
Write-Output '::group::Print version' | |
ccache.exe --version | |
Write-Output '::endgroup::' | |
Write-Output '::group::Print ccache config' | |
ccache.exe --show-config | |
Write-Output '::endgroup::' | |
- name: Self-hosted runner prepare environment | |
run: | | |
'C:\Program Files\CMake\bin' >> $env:GITHUB_PATH | |
"$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_PATH | |
"$env:TINY_QT_ROOT\$env:TINY_QT_VERSION\$env:TinyQtSpecPlain\bin" >> $env:GITHUB_PATH | |
# Must be after the ilammy/msvc-dev-cmd@v1 because vcvars64 overrides the VCPKG_ROOT | |
# Define the VCPKG_DEFAULT_BINARY_CACHE because it takes ~20G in C:\Windows\ServiceProfiles | |
- name: vcpkg prepare environment | |
run: | | |
"VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_ENV | |
'VCPKG_DEFAULT_TRIPLET=x64-windows' >> $env:GITHUB_ENV | |
"VCPKG_MAX_CONCURRENCY=$env:TINY_PARALLEL" >> $env:GITHUB_ENV | |
$vcpkgArchivesPath = Join-Path -Path $env:RUNNER_WORKSPACE -ChildPath vcpkg_archives | |
"VCPKG_DEFAULT_BINARY_CACHE=$vcpkgArchivesPath" >> $env: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 | |
run: | | |
cmake.exe --version | |
- name: vcpkg print version | |
run: | | |
vcpkg.exe --version | |
- name: Ccache clear statistics | |
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 }}) | |
working-directory: ${{ env.TinyORMPath }} | |
run: >- | |
cmake.exe --log-level=DEBUG --log-context | |
-S . | |
-B $env:TinyORMBuildTree | |
-G Ninja | |
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache.exe | |
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$env: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 CMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=${{ matrix.lto }} | |
-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 }}) | |
working-directory: ${{ env.TinyORMBuildTree }} | |
run: | | |
cmake.exe --build . --target all --parallel $env:TINY_PARALLEL | |
- name: Ccache print statistics | |
run: | | |
ccache.exe --show-stats --verbose | |
- name: TinyORM add on the $env:Path | |
run: | | |
$env:TinyORMBuildTree >> $env:GITHUB_PATH | |
# Used migrate:fresh instead (is safer) | |
- name: Create and Seed tables for unit tests 🎉 | |
working-directory: ${{ env.TinyORMBuildTree }}/tests/testdata_tom | |
run: | | |
.\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 }} | |
DB_MYSQL_SSL_CA: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/ca.pem | |
DB_MYSQL_SSL_CERT: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/client-cert.pem | |
DB_MYSQL_SSL_KEY: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/client-key.pem | |
DB_MYSQL_SSL_MODE: ${{ secrets.DB_MYSQL_SSL_MODE }} | |
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF }} | |
TOM_TESTDATA_ENV: ${{ vars.TOM_TESTDATA_ENV }} | |
# $env:NUMBER_OF_PROCESSORS / 2 : rounds down | |
- name: TinyORM execute ctest 🔥 | |
working-directory: ${{ env.TinyORMBuildTree }} | |
run: >- | |
ctest.exe --output-on-failure | |
--parallel ([int] $env:TINY_PARALLEL + $env: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 }} | |
DB_MYSQL_SSL_CA: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/ca.pem | |
DB_MYSQL_SSL_CERT: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/client-cert.pem | |
DB_MYSQL_SSL_KEY: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/client-key.pem | |
DB_MYSQL_SSL_MODE: ${{ secrets.DB_MYSQL_SSL_MODE }} | |
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF }} | |
TOM_TESTS_ENV: ${{ vars.TOM_TESTS_ENV }} | |
- name: Tom example test some commands (MySQL) 🚀 | |
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom | |
run: | | |
.\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 }} | |
DB_MYSQL_SSL_CA: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/ca.pem | |
DB_MYSQL_SSL_CERT: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/client-cert.pem | |
DB_MYSQL_SSL_KEY: ${{ secrets.DB_MYSQL_DATA_SELF_WINDOWS }}/client-key.pem | |
DB_MYSQL_SSL_MODE: ${{ secrets.DB_MYSQL_SSL_MODE }} | |
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF }} | |
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }} | |
# The reason for this is the concurrency:group: can contain only two in_progress workflows, | |
# one will be in_progress and the second will be queued (waiting until the first finish), | |
# and all others will be canceled. | |
# Jobs are run randomly! They are sorted from 0 to strategy.job-total - 1 in GitHub UI, so | |
# the first job has index 0, the second job has index 1, ... | |
# Execute the next workflow inly if it's active and isn't disabled (disabled_manually state). | |
# Also, if the step fails due to any error, continue (eg. network unreachable or similar). | |
- name: Run vcpkg-windows.yml workflow | |
continue-on-error: true | |
if: strategy.job-index == 0 | |
working-directory: ${{ env.TinyORMPath }} | |
run: | | |
$workflowState = gh workflow list --all --json path,state ` | |
--jq '.[] | select (.path | endswith("/vcpkg-windows.yml")) | .state' | |
if ($? -and $workflowState -ceq 'active') { | |
gh workflow run vcpkg-windows.yml --ref $env:GITHUB_REF_NAME | |
} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Cancel vcpkg-windows.yml workflow (on failure) | |
if: ${{ failure() }} | |
working-directory: ${{ env.TinyORMPath }} | |
run: | | |
$databaseId = gh run list --workflow vcpkg-windows.yml --event workflow_dispatch ` | |
--json databaseId,conclusion,status ` | |
--jq '.[] | select (.status == "pending") | select (.conclusion == "") | .databaseId' | |
if ($? -and $null -ne $databaseId -and $databaseId -match '^\d+$' -and | |
[int64] $databaseId -ne 0 | |
) { | |
gh run cancel $databaseId | |
} | |
env: | |
GH_TOKEN: ${{ github.token }} |