Skip to content

Vcpkg Windows

Vcpkg Windows #58

Workflow file for this run

name: Vcpkg Windows
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:
vcpkg-windows:
name: Vcpkg Windows
# Self-hosted runner is Windows 11 (Release Preview channel - 23H2)
runs-on: [ self-hosted, windows ]
strategy:
matrix:
build-type:
- key: debug
name: Debug
- key: release
name: Release
qt:
# GitHub Free Plan is not enough for this (no money 💵)
# - key: qt5
# name: Qt5
# version: 5.15.2
# # For vcpkg classic mode (install tests)
# vcpkg-qt: qt5-base
# vcpkg-qt-features: qt5-base[core]
# vcpkg-tinyorm: tinyorm-qt5
# vcpkg-tinyorm-features: tinyorm-qt5[core,tom-example]
- key: qt6
name: Qt6
version: 6.7.0
# For vcpkg classic mode (install tests)
vcpkg-qt: qtbase
vcpkg-qt-features: qtbase[core,sql-sqlite]
vcpkg-tinyorm: tinyorm
vcpkg-tinyorm-features: tinyorm[core,sql-sqlite,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
# Starts with the merydeye-
$isSelfHostedRunner = '${{ runner.name }}'.StartsWith('merydeye-', $true, $null)
"TinyIsSelfHostedRunner=$isSelfHostedRunner" >> $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
$parallel = $isSelfHostedRunner ? 10 : 2
"TinyParallel=$parallel" >> $env:GITHUB_ENV
$tinyormPath = Resolve-Path -Path ./main
"TinyORMPath=$tinyormPath" >> $env:GITHUB_ENV
- name: Ninja install latest version
if: env.TinyIsSelfHostedRunner == 'true'
uses: seanmiddleditch/gha-setup-ninja@master
with:
destination: ${{ env.TinyRunnerWorkPath }}/ninja-build
- name: CMake and Ninja install latest versions
if: env.TinyIsSelfHostedRunner == 'false'
uses: lukka/get-cmake@latest
with:
useLocalCache: true
useCloudCache: false
- 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
if: env.TinyIsSelfHostedRunner == 'true'
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'
$portfileQt5Path = Resolve-Path -Path './cmake/vcpkg/ports/tinyorm-qt5/portfile.cmake'
$vcpkgRef = '${{ github.sha }}'
Edit-VcpkgRefAndHash -Project '${{ github.repository }}' -Ref $vcpkgRef `
-PortFile $portfileQt6Path, $portfileQt5Path `
-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: env.TinyIsSelfHostedRunner == 'true' && 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 ${{ matrix.qt.vcpkg-qt }}
${{ matrix.qt.vcpkg-tinyorm }}
- 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 project
- name: HelloWorld checkout
uses: actions/checkout@v4
with:
repository: silverqx/TinyORM-HelloWorld
path: HelloWorld
- name: HelloWorld move HelloWorld.sqlite3 (to parent folder)
working-directory: HelloWorld
run: |
Copy-Item -Path ./HelloWorld.sqlite3 -Destination '${{ runner.workspace }}' -Force
- name: TinyORM create folder for build trees
run: |
$buildTreesPath = '../TinyORM-builds-cmake'
if (-not (Test-Path $buildTreesPath)) {
New-Item -Type Directory $buildTreesPath
}
- name: HelloWorld 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 prepare VcpkgManifest method (vcpkg.json)
working-directory: HelloWorld
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 cmake configure (vcpkgmanifest-msvc-${{ matrix.build-type.key }})
working-directory: HelloWorld
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/build-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 cmake build ✨ (vcpkgmanifest-msvc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/build-vcpkgmanifest-msvc-${{ matrix.build-type.key }}
run: |
cmake.exe --build . --target all --parallel ${{ env.TinyParallel }}
# Related issue: https://github.com/microsoft/vcpkg/issues/33539
- name: HelloWorld finish VCPKG_APPLOCAL_DEPS (Debug)
if: matrix.qt.key == 'qt6' && matrix.build-type.key == 'debug'
working-directory: >-
../HelloWorld-builds-cmake/build-vcpkgmanifest-msvc-${{ matrix.build-type.key }}
run: |
Copy-Item -Path ./vcpkg_installed/x64-windows/debug/bin/sqlite3.dll -Destination .
Copy-Item -Path ./vcpkg_installed/x64-windows/debug/Qt6 -Destination . -Recurse -Force
- name: HelloWorld finish VCPKG_APPLOCAL_DEPS (Release)
if: matrix.qt.key == 'qt6' && matrix.build-type.key == 'release'
working-directory: >-
../HelloWorld-builds-cmake/build-vcpkgmanifest-msvc-${{ matrix.build-type.key }}
run: |
Copy-Item -Path ./vcpkg_installed/x64-windows/bin/sqlite3.dll -Destination .
Copy-Item -Path ./vcpkg_installed/x64-windows/Qt6 -Destination . -Recurse -Force
# Qt5 has a problem too, it's deployed but to the wrong folder, the Release build is ok
- name: HelloWorld finish VCPKG_APPLOCAL_DEPS (Debug)
if: matrix.qt.key == 'qt5' && matrix.build-type.key == 'debug'
working-directory: >-
../HelloWorld-builds-cmake/build-vcpkgmanifest-msvc-${{ matrix.build-type.key }}
run: |
if (-not (Test-Path ./debug)) {
New-Item -type Directory ./debug
}
Copy-Item -Path ./plugins -Destination ./debug -Recurse -Force
- name: HelloWorld execute (SQLite) 🏁
working-directory: >-
../HelloWorld-builds-cmake/build-vcpkgmanifest-msvc-${{ matrix.build-type.key }}
run: |
.\HelloWorld.exe
env:
TINYORM_HELLOWORLD_DB_SQLITE_DATABASE: ../../HelloWorld.sqlite3
# The FetchContent and Manual methods below need Qt installed and to be accessible on the system
- name: Qt v${{ matrix.qt.version }} install base components
if: env.TinyIsSelfHostedRunner == 'false'
uses: jurplel/install-qt-action@v3
with:
archives: qtbase
version: ${{ matrix.qt.version }}
arch: win64_msvc2019_64
cache: true
setup-python: false
extra: --external 7z.exe
dir: ${{ env.TinyRunnerWorkPath }}
- name: ${{ matrix.qt.name }} prepare environment
if: env.TinyIsSelfHostedRunner == 'true'
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
- name: Ccache prepare environment
if: env.TinyIsSelfHostedRunner == 'true'
run: |
$ccacheDirPath = Join-Path -Path '${{ runner.workspace }}' -ChildPath ccache
"CCACHE_DIR=$ccacheDirPath" >> $env:GITHUB_ENV
- name: Ccache initialize
if: env.TinyIsSelfHostedRunner == 'false'
id: ccache-initialize-cache
run: |
Write-Output '::group::Install'
choco install ccache --yes
Write-Output '::endgroup::'
Write-Output '::group::get-config cache_dir'
$cachePath = ccache.exe --get-config cache_dir
"CachePath=$cachePath" >> $env:GITHUB_OUTPUT
"ImageOS=$env:ImageOS" >> $env:GITHUB_OUTPUT
Write-Output '::endgroup::'
- name: Ccache restore cache 🕺
if: env.TinyIsSelfHostedRunner == 'false'
uses: actions/cache@v3
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: vcpkg-windows-${{ matrix.qt.key }}-${{ matrix.build-type.key }}
cache_path: ${{ steps.ccache-initialize-cache.outputs.CachePath }}
image_os: ${{ steps.ccache-initialize-cache.outputs.ImageOS }}
# I'm managing the ccache configuration manually on self-hosted runners using the ccache.conf
# because it's used by more actions.
- name: Ccache prepare configuration 🥳
if: env.TinyIsSelfHostedRunner == 'false'
run: |
# ~ 70 * 3 + 100
ccache.exe --set-config max_size=500M
ccache.exe --set-config sloppiness=pch_defines,time_macros
- 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::'
# 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)
- name: TinyORM cmake configure (manual-msvc-${{ matrix.build-type.key }})
working-directory: ${{ env.TinyORMPath }}
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/TinyORM-builds-cmake/build-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=OFF
-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=OFF
- name: TinyORM cmake build ✨ (manual-msvc-${{ matrix.build-type.key }})
working-directory: >-
../TinyORM-builds-cmake/build-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 console application
- name: HelloWorld prepare Manual method (vcpkg.json)
working-directory: HelloWorld
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 cmake configure (manual-msvc-${{ matrix.build-type.key }})
working-directory: HelloWorld
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/build-manual-msvc-${{ matrix.build-type.key }}'
-G Ninja
-D CMAKE_PREFIX_PATH:PATH='${{ runner.workspace }}/TinyORM-builds-cmake/build-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 cmake build ✨ (manual-msvc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/build-manual-msvc-${{ matrix.build-type.key }}
run: |
cmake.exe --build . --target all --parallel ${{ env.TinyParallel }}
- name: HelloWorld execute (SQLite) 🏁
working-directory: >-
../HelloWorld-builds-cmake/build-manual-msvc-${{ matrix.build-type.key }}
run: |
$env:Path = '..\..\TinyORM-builds-cmake\build-manual-msvc-${{ matrix.build-type.key }};' + $env:Path
.\HelloWorld.exe
env:
TINYORM_HELLOWORLD_DB_SQLITE_DATABASE: ../../HelloWorld.sqlite3
# FetchContent method (with install or deployment)
# ---
- name: 🪡 FetchContent method (with install or deployment) 🪡
run: |
Write-Output 'no-op'
- name: HelloWorld prepare FetchContent method (vcpkg.json)
working-directory: HelloWorld
run: |
Copy-Item -Path ./vcpkg.json.FetchContent.example -Destination ./vcpkg.json
- name: HelloWorld prepare FetchContent method (update GIT_TAG)
working-directory: HelloWorld
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 cmake configure (fetchcontent-msvc-${{ matrix.build-type.key }})
working-directory: HelloWorld
run: >-
cmake.exe
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/build-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-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=OFF
-D RESOLVE_TINYORM:STRING=FetchContent
# Also install it, to test the deployment process
- name: HelloWorld cmake build and install ✨ (fetchcontent-msvc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/build-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 execute (SQLite) 🏁
working-directory: ../HelloWorld-FetchContent-Install/${{ matrix.build-type.name }}/bin
run: |
.\HelloWorld.exe
env:
TINYORM_HELLOWORLD_DB_SQLITE_DATABASE: ../../../HelloWorld.sqlite3
# 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, ...
- name: Run vcpkg-windows-drivers.yml workflows
if: strategy.job-index == 0
working-directory: ${{ env.TinyORMPath }}
run: |
gh workflow run vcpkg-windows-drivers.yml --ref ${{ github.ref_name }}
env:
GH_TOKEN: ${{ github.token }}