Skip to content

workflows vcpkg added comment #8

workflows vcpkg added comment

workflows vcpkg added comment #8

name: Vcpkg Windows
on:
workflow_dispatch:
push:
branches:
- main
- gh-actions
- silverqx-develop
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:
vcpkg-windows:
name: Vcpkg Windows
# Self-hosted runner is Windows 11 (Release Preview channel - 23H2)
runs-on: [ self-hosted, windows ]
# runs-on: windows-2022
strategy:
matrix:
build-type:
- key: debug
name: Debug
- key: release
name: Release
qt:
- key: qt6
name: Qt6
version: 6.7.0
# For vcpkg classic mode (install tests)
vcpkg-qt: qtbase
vcpkg-qt-features: qtbase[core]
vcpkg-tinyorm: tinyorm
vcpkg-tinyorm-features: tinyorm[core,build-mysql-driver,tom-example]
steps:
- uses: actions/checkout@v4
with:
path: main
# I don't install everything to the TinyRunnerWorkPath as in all other workflows, I leave it
# this way because I tried to refactor it to the env.TinyRunnerWorkPath and it looks terrible
- name: TinyORM prepare environment
run: |
$runnerWorkPath = Resolve-Path -Path '${{ 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
# Parallel 10 is maximum what my computer allows, I have to invoke Linux self-hosted runners
# manually so 10 is ok.
# --
# The description below is Outdated but I leave the comment.
# I must divide all parallel by 2 because I have 2 self-hosted runners on the same computer
# and also -1 for reserve to avoid swapping, so 10 / 2 - 1 = 4
"TinyParallel=10" >> $env:GITHUB_ENV
$tinyormPath = Resolve-Path -Path ./main
"TinyORMPath=$tinyormPath" >> $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: |
$serviceName = 'MySQL83'
Write-Output '::group::Get-Service'
$mysqlService = Get-Service $serviceName
Write-Output $mysqlService
Write-Output '::endgroup::'
Write-Output '::group::Service running check'
$mysqlService.status.ToString() -ceq 'Running' -or `
$(throw "$serviceName 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
# Must be after the ilammy/msvc-dev-cmd@v1 because vcvars64 overrides the VCPKG_ROOT
- 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.TinyParallel }}' >> $env:GITHUB_ENV
$vcpkgPath = Resolve-Path -Path '${{ env.TinyORMPath }}/cmake/vcpkg'
$portsPath = Join-Path -Path $vcpkgPath -ChildPath 'ports'
"VCPKG_OVERLAY_PORTS=$portsPath" >> $env:GITHUB_ENV
$tripletsPath = Join-Path -Path $vcpkgPath -ChildPath 'triplets'
"VCPKG_OVERLAY_TRIPLETS=$tripletsPath" >> $env:GITHUB_ENV
# Binary caching
'VCPKG_BINARY_SOURCES=clear;x-gha,readwrite' >> $env:GITHUB_ENV
- name: vcpkg prepare binary caching
uses: actions/github-script@v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Self-hosted runner prepare environment
run: |
'C:\Program Files\CMake\bin' >> $env:GITHUB_PATH
"$env:VCPKG_INSTALLATION_ROOT" >> $env:GITHUB_PATH
- name: CMake print version
run: |
cmake.exe --version
- name: vcpkg print version
run: |
vcpkg.exe --version
# Will be used in the classic method (vcpkg install tinyorm) and VcpkgManifest method
- name: vcpkg prepare TinyORM ports (update REF and SHA512)
working-directory: ${{ env.TinyORMPath }}
run: |
. ./tools/private/Common-Deploy.ps1
$portfileQt6Path = Resolve-Path -Path './cmake/vcpkg/ports/tinyorm/portfile.cmake'
$vcpkgRef = '${{ github.sha }}'
Edit-VcpkgRefAndHash -Project '${{ github.repository }}' -Ref $vcpkgRef `
-PortFile $portfileQt6Path -EnableRetries
# The following two steps (vcpkg install) are not needed below they only test if the vcpkg
# classic mode works correctly. The Release and Debug build types are build at once so invoke
# these two steps for the debug matrix only.
- name: vcpkg upgrade repository (latest version)
if: matrix.build-type.key == 'debug'
run: |
Set-Location -Path $env:VCPKG_INSTALLATION_ROOT
git.exe switch master
git.exe fetch --tags origin
git.exe reset --hard origin/master
# This should reliably remove the qtbase and tinyorm with all dependencies.
# It's much faster to do it this way like removing the whole vcpkg folder and then the binary
# caching should kick in.
- name: vcpkg remove ${{ matrix.qt.vcpkg-qt }} and ${{ matrix.qt.vcpkg-tinyorm }} (classic mode)
if: matrix.build-type.key == 'debug'
run: >-
vcpkg.exe remove --recurse vcpkg-cmake vcpkg-cmake-config zlib boost-uninstall libmysql
${{ matrix.qt.vcpkg-qt }} ${{ matrix.qt.vcpkg-tinyorm }}
# Install libmysql separately so I will see what's up if it fails
- name: vcpkg install libmysql (classic mode)
if: matrix.build-type.key == 'debug'
run: |
vcpkg.exe install libmysql
- name: vcpkg install ${{ matrix.qt.vcpkg-qt }} (classic mode)
if: matrix.build-type.key == 'debug'
run: |
vcpkg.exe install ${{ matrix.qt.vcpkg-qt-features }}
- name: vcpkg install ${{ matrix.qt.vcpkg-tinyorm }} (classic mode)
if: matrix.build-type.key == 'debug'
run: |
vcpkg.exe install ${{ matrix.qt.vcpkg-tinyorm-features }}
# Prepare TinyORM-HelloWorld-TinyDrivers project
- name: HelloWorld-TinyDrivers checkout
uses: actions/checkout@v4
with:
repository: silverqx/TinyORM-HelloWorld-TinyDrivers
path: HelloWorld-TinyDrivers
- name: TinyORM create folder for build trees
run: |
$buildTreesPath = '../TinyORM-builds-cmake'
if (-not (Test-Path $buildTreesPath)) {
New-Item -Type Directory $buildTreesPath
}
- name: HelloWorld-TinyDrivers create folder for build trees
run: |
$buildTreesPath = '../HelloWorld-builds-cmake'
if (-not (Test-Path $buildTreesPath)) {
New-Item -Type Directory $buildTreesPath
}
# VcpkgManifest method with the VCPKG_APPLOCAL_DEPS (no install or deployment)
# ---
# I don't need to use set(VCPKG_USE_HEAD_VERSION ON) and set HEAD_REF because I'm using
# Edit-VcpkgRefAndHash a few steps above to correctly set RED and SHA512.
- name: 🪡 VcpkgManifest method with the VCPKG_APPLOCAL_DEPS (no install or deployment) 🪡
run: |
Write-Output 'no-op'
- name: HelloWorld-TinyDrivers prepare VcpkgManifest method (vcpkg.json)
working-directory: HelloWorld-TinyDrivers
run: >-
Copy-Item -Path ./vcpkg.json.VcpkgManifest.${{ matrix.qt.name }}.example
-Destination ./vcpkg.json
# Don't use ccache for the VcpkgManifest method as the vcpkg has its own binary caching
- name: HelloWorld-TinyDrivers cmake configure (vcpkgmanifest-msvc-${{ matrix.build-type.key }})
working-directory: HelloWorld-TinyDrivers
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/Drivers-vcpkgmanifest-msvc-${{ matrix.build-type.key }}'
-G Ninja
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
-D CMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=ON
-D CMAKE_BUILD_TYPE:STRING=${{ matrix.build-type.name }}
-D VCPKG_APPLOCAL_DEPS:BOOL=ON
-D RESOLVE_TINYORM:STRING=VcpkgManifest
- name: HelloWorld-TinyDrivers cmake build ✨ (vcpkgmanifest-msvc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/Drivers-vcpkgmanifest-msvc-${{ matrix.build-type.key }}
run: |
cmake.exe --build . --target all --parallel ${{ env.TinyParallel }}
- name: HelloWorld-TinyDrivers execute (MySQL) 🏁
working-directory: >-
../HelloWorld-builds-cmake/Drivers-vcpkgmanifest-msvc-${{ matrix.build-type.key }}
run: |
.\HelloWorld-TinyDrivers.exe
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 }}
# The FetchContent and Manual methods below need Qt installed and to be accessible on the system
- name: ${{ matrix.qt.name }} prepare environment
run: |
"$env:TINY_QT_ROOT\${{ matrix.qt.version }}\msvc2019_64\bin" >> $env:GITHUB_PATH
# Prepare ccache
#
# The TinyORM build in the Manual method and the FetchContent method are using the ccache,
# packages build through the FetchContent CMake module are also using the ccache, they respect
# the CMAKE_CXX_COMPILER_LAUNCHER option.
# Don't use the default CCACHE_DIR path on self-hosted runners (also use separate folder
# for TinyDrivers).
- name: Ccache prepare environment
run: |
$ccacheDirPath = Join-Path -Path '${{ runner.workspace }}' -ChildPath ccache_drivers
"CCACHE_DIR=$ccacheDirPath" >> $env:GITHUB_ENV
# Manual method linking against the TinyORM build tree (no install or deployment)
# ---
- name: 🪡 Manual method linking against the TinyORM build tree (no install or deployment) 🪡
run: |
Write-Output 'no-op'
- name: Ccache clear statistics
run: |
ccache.exe --zero-stats
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct (Windows ccache doesn't work well with PCH)
# BUILD_TREE_DEPLOY=ON is needed here
- name: TinyORM cmake configure (manual-msvc-${{ matrix.build-type.key }})
working-directory: ${{ env.TinyORMPath }}
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/TinyORM-builds-cmake/Drivers-manual-msvc-${{ matrix.build-type.key }}'
-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_BUILD_TYPE:STRING=${{ matrix.build-type.name }}
-D CMAKE_EXPORT_PACKAGE_REGISTRY:BOOL=OFF
-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=OFF
-D MYSQL_PING:BOOL=OFF
-D BUILD_TESTS:BOOL=OFF
-D ORM:BOOL=ON
-D TOM:BOOL=OFF
-D TOM_EXAMPLE:BOOL=OFF
-D BUILD_DRIVERS:BOOL=ON
-D DRIVERS_TYPE:STRING=Shared
- name: TinyORM cmake build ✨ (manual-msvc-${{ matrix.build-type.key }})
working-directory: >-
../TinyORM-builds-cmake/Drivers-manual-msvc-${{ matrix.build-type.key }}
run: |
cmake.exe --build . --target all --parallel ${{ env.TinyParallel }}
- name: Ccache print statistics
run: |
ccache.exe --show-stats -vv
# Build and execute the HelloWorld-TinyDrivers console application
- name: HelloWorld-TinyDrivers prepare Manual method (vcpkg.json)
working-directory: HelloWorld-TinyDrivers
run: |
Copy-Item -Path ./vcpkg.json.Manual.example -Destination ./vcpkg.json
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct (no need to use PCH for one TU)
- name: HelloWorld-TinyDrivers cmake configure (manual-msvc-${{ matrix.build-type.key }})
working-directory: HelloWorld-TinyDrivers
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/Drivers-manual-msvc-${{ matrix.build-type.key }}'
-G Ninja
-D CMAKE_PREFIX_PATH:PATH='${{ runner.workspace }}/TinyORM-builds-cmake/Drivers-manual-msvc-${{ matrix.build-type.key }}'
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
-D CMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=ON
-D CMAKE_BUILD_TYPE:STRING=${{ matrix.build-type.name }}
-D VCPKG_APPLOCAL_DEPS:BOOL=OFF
-D RESOLVE_TINYORM:STRING=Manual
- name: HelloWorld-TinyDrivers cmake build ✨ (manual-msvc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/Drivers-manual-msvc-${{ matrix.build-type.key }}
run: |
cmake.exe --build . --target all --parallel ${{ env.TinyParallel }}
- name: HelloWorld-TinyDrivers execute (MySQL) 🏁
working-directory: >-
../HelloWorld-builds-cmake/Drivers-manual-msvc-${{ matrix.build-type.key }}
run: |
$env:Path = '..\..\TinyORM-builds-cmake\Drivers-manual-msvc-${{ matrix.build-type.key }};' + $env:Path
.\HelloWorld-TinyDrivers.exe
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 }}
# FetchContent method (with install or deployment)
# ---
- name: 🪡 FetchContent method (with install or deployment) 🪡
run: |
Write-Output 'no-op'
- name: HelloWorld-TinyDrivers prepare FetchContent method (vcpkg.json)
working-directory: HelloWorld-TinyDrivers
run: |
Copy-Item -Path ./vcpkg.json.FetchContent.example -Destination ./vcpkg.json
- name: HelloWorld-TinyDrivers prepare FetchContent method (update GIT_TAG)
working-directory: HelloWorld-TinyDrivers
run: |
$toolsPath = Resolve-Path -Path '${{ env.TinyORMPath }}/tools/private'
$gitTag = '${{ github.sha }}'
& "$toolsPath/Edit-FetchContentGitTag.ps1" -CMakeLists ./CMakeLists.txt -GitTag $gitTag
- name: Ccache clear statistics
run: |
ccache.exe --zero-stats
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct (Windows ccache doesn't work well with PCH)
- name: HelloWorld-TinyDrivers cmake configure (fetchcontent-msvc-${{ matrix.build-type.key }})
working-directory: HelloWorld-TinyDrivers
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/Drivers-fetchcontent-msvc-${{ matrix.build-type.key }}'
-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_BUILD_TYPE:STRING=${{ matrix.build-type.name }}
-D CMAKE_INSTALL_PREFIX:PATH='${{ runner.workspace }}/HelloWorld-TinyDrivers-FetchContent-Install/${{ matrix.build-type.name }}'
-D CMAKE_EXPORT_PACKAGE_REGISTRY:BOOL=OFF
-D VCPKG_APPLOCAL_DEPS:BOOL=OFF
-D VERBOSE_CONFIGURE:BOOL=ON
-D BUILD_TREE_DEPLOY:BOOL=OFF
-D MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=OFF
-D STRICT_MODE:BOOL=OFF
-D MYSQL_PING:BOOL=OFF
-D BUILD_TESTS:BOOL=OFF
-D ORM:BOOL=ON
-D TOM:BOOL=OFF
-D TOM_EXAMPLE:BOOL=OFF
-D BUILD_DRIVERS:BOOL=ON
-D DRIVERS_TYPE:STRING=Shared
-D RESOLVE_TINYORM:STRING=FetchContent
# Also install it, to test the deployment process
- name: HelloWorld-TinyDrivers cmake build and install ✨ (fetchcontent-msvc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/Drivers-fetchcontent-msvc-${{ matrix.build-type.key }}
run: |
cmake.exe --build . --target install --parallel ${{ env.TinyParallel }}
- name: Ccache print statistics
run: |
ccache.exe --show-stats -vv
- name: HelloWorld-TinyDrivers execute (MySQL) 🏁
working-directory: ../HelloWorld-TinyDrivers-FetchContent-Install/${{ matrix.build-type.name }}/bin
run: |
.\HelloWorld-TinyDrivers.exe
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 }}