Skip to content

workflows testing

workflows testing #27

Workflow file for this run

# OS settings notes:
# ---
# Set time zone to 'Etc/UTC' (this was the default)
name: Vcpkg Linux
on:
push:
branches:
- main
- gh-actions
- silverqx-develop
# 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-linux:
name: Vcpkg Linux
# Self-hosted runner is Ubuntu 22.04 too
runs-on: [self-hosted, linux]
# runs-on: ubuntu-22.04
strategy:
matrix:
build-type:
- key: debug
name: Debug
- key: release
name: Release
qt:
# - key: qt5
# name: Qt5
# version: 5.15.2
# apt: [qtbase5-dev]
# vcpkg-qt: qt5-base
# vcpkg-qt-features: qt5-base[core]
# vcpkg-tinyorm: tinyorm-qt5
# vcpkg-tinyorm-features: tinyorm-qt5[core]
- key: qt6
name: Qt6
version: 6.7.0
apt: [qt6-base-dev, libqt6sql6-sqlite]
vcpkg-qt: qtbase
vcpkg-qt-features: qtbase[core,sql-sqlite]
vcpkg-tinyorm: tinyorm
vcpkg-tinyorm-features: tinyorm[core,sql-sqlite]
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=$(realpath '${{ runner.workspace }}/..')
echo "TinyRunnerWorkPath=$runnerWorkPath" >> $GITHUB_ENV
# Starts with the merydeye-
[[ "${{ runner.name }}" == 'merydeye-'* ]] && isSelfHostedRunner='true' || isSelfHostedRunner='false'
echo "TinyIsSelfHostedRunner=$isSelfHostedRunner" >> $GITHUB_ENV
[[ "$isSelfHostedRunner" == 'true' ]] && parallel=4 || parallel=2
echo "TinyParallel=$parallel" >> $GITHUB_ENV
tinyormPath=$(realpath ./main)
echo "TinyORMPath=$tinyormPath" >> $GITHUB_ENV
- name: apt update
if: env.TinyIsSelfHostedRunner == 'false'
run: |
sudo apt update
- name: apt install g++-12
if: env.TinyIsSelfHostedRunner == 'false'
run: |
sudo apt install --yes g++-12
# Qt5 build dependencies: https://wiki.qt.io/Building_Qt_5_from_Git
- name: apt install Qt5 build dependencies
if: env.TinyIsSelfHostedRunner == 'false' && matrix.qt.key == 'qt5'
run: >-
sudo apt install --yes '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev
libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
- 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: vcpkg prepare environment
run: |
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV
# The x64-linux is correct
echo 'VCPKG_DEFAULT_TRIPLET=x64-linux' >> $GITHUB_ENV
echo 'VCPKG_MAX_CONCURRENCY=${{ env.TinyParallel }}' >> $GITHUB_ENV
vcpkgPath=$(realpath '${{ env.TinyORMPath }}/cmake/vcpkg')
portsPath="$vcpkgPath/ports"
echo "VCPKG_OVERLAY_PORTS=$portsPath" >> $GITHUB_ENV
tripletsPath="$vcpkgPath/triplets"
echo "VCPKG_OVERLAY_TRIPLETS=$tripletsPath" >> $GITHUB_ENV
# Binary caching
echo 'VCPKG_BINARY_SOURCES=clear;x-gha,readwrite' >> $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: vcpkg add on the $PATH
if: env.TinyIsSelfHostedRunner == 'true'
run: |
echo "$VCPKG_INSTALLATION_ROOT" >> $GITHUB_PATH
- name: CMake print version
run: |
cmake --version
- name: Print SQLite database version
run: |
sqlite3 --version
- name: vcpkg print version
run: |
vcpkg --version
# Will be used in the classic method (vcpkg install tinyorm) and VcpkgManifest method
# I will not write bash scripts for this, would be a pain 🫤
- name: vcpkg prepare TinyORM ports (update REF and SHA512)
shell: pwsh -NoProfile -Command "& '{0}'"
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: |
cd "$VCPKG_INSTALLATION_ROOT"
git switch master
git fetch --tags origin
git 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 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 install ${{ matrix.qt.vcpkg-qt-features }}
- name: vcpkg install ${{ matrix.qt.vcpkg-tinyorm }} (classic mode)
if: matrix.build-type.key == 'debug'
run: |
vcpkg 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: |
cp --target-directory='${{ runner.workspace }}' ./HelloWorld.sqlite3
- name: TinyORM create folder for build trees
run: |
mkdir --parents '../TinyORM-builds-cmake'
- name: HelloWorld create folder for build trees
run: |
mkdir --parents '../HelloWorld-builds-cmake'
# VcpkgManifest method (no install or deployment)
# ---
- name: 🪡 VcpkgManifest method (no install or deployment) 🪡
run: |
echo 'no-op'
- name: HelloWorld prepare VcpkgManifest method (vcpkg.json)
working-directory: HelloWorld
run: |
cp ./vcpkg.json.VcpkgManifest.${{ matrix.qt.name }}.example ./vcpkg.json
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct (no need to use PCH for one TU)
# VCPKG_APPLOCAL_DEPS=OFF is correct as everything is linked statically on Linux
# Don't use ccache for the VcpkgManifest method as the vcpkg has its own binary caching
- name: HelloWorld cmake configure (vcpkgmanifest-gcc-${{ matrix.build-type.key }})
working-directory: HelloWorld
run: >-
cmake
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/build-vcpkgmanifest-gcc-${{ matrix.build-type.key }}'
-G Ninja
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$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=VcpkgManifest
- name: HelloWorld cmake build ✨ (vcpkgmanifest-gcc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/build-vcpkgmanifest-gcc-${{ matrix.build-type.key }}
run: |
cmake --build . --target all --parallel ${{ env.TinyParallel }}
- name: HelloWorld execute (SQLite) 🏁
working-directory: >-
../HelloWorld-builds-cmake/build-vcpkgmanifest-gcc-${{ matrix.build-type.key }}
run: |
./HelloWorld
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: ${{ matrix.qt.name }} prepare environment
if: env.TinyIsSelfHostedRunner == 'true'
run: |
echo '/opt/Qt/${{ matrix.qt.version }}/bin' >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=/opt/Qt/${{ matrix.qt.version }}/gcc_64/lib${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" >> $GITHUB_ENV
# The CMAKE_PREFIX_PATH must be defined on the GitHub Actions, this is some kind of a bug
# because the CMake can't find the Qt, but if I export the PATH directly in the step
# it works but doesn't work using the GITHUB_PATH like define two line above. 🫤
echo "CMAKE_PREFIX_PATH=/opt/Qt/${{ matrix.qt.version }}/gcc_64${CMAKE_PREFIX_PATH:+:}$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
- name: apt install Qt v${{ matrix.qt.version }} base (${{ join(matrix.compiler.apt, ', ') }})
if: env.TinyIsSelfHostedRunner == 'false'
run: |
sudo apt install --yes ${{ join(matrix.qt.apt, ' ') }}
# 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=$(realpath '${{ runner.workspace }}/ccache')
echo "CCACHE_DIR=$ccacheDirPath" >> $GITHUB_ENV
- name: Ccache initialize download
if: env.TinyIsSelfHostedRunner == 'false'
id: downloads-initialize-ccache
run: |
filename=$(basename "$URL_CCACHE_LINUX_X64")
echo "Filename=$filename" >> $GITHUB_OUTPUT
filepath="${{ runner.temp }}/$filename"
echo "Filepath=$filepath" >> $GITHUB_OUTPUT
hash=$(wget "$URL_CACHE_HASH_LINUX" -O- --no-verbose --quiet)
echo "Hash=$hash" >> $GITHUB_OUTPUT
env:
URL_CACHE_HASH_LINUX: ${{ secrets.URL_CACHE_HASH_LINUX }}
URL_CCACHE_LINUX_X64: ${{ secrets.URL_CCACHE_LINUX_X64 }}
- name: Ccache restore cache (download)
if: env.TinyIsSelfHostedRunner == 'false'
uses: actions/cache@v3
id: downloads-cache-ccache
with:
path: ${{ env.archive_filepath }}
key: ${{ runner.os }}-caches-${{ env.cache_name }}-${{ env.cache_hash }}
env:
archive_filepath: ${{ steps.downloads-initialize-ccache.outputs.Filepath }}
cache_hash: ${{ steps.downloads-initialize-ccache.outputs.Hash }}
cache_name: ccache
- name: Ccache download
if: env.TinyIsSelfHostedRunner == 'false' && steps.downloads-cache-ccache.outputs.cache-hit != 'true'
run: |
wget "$URL_CCACHE_LINUX_X64" --output-document="$archive_filepath" --no-verbose
env:
archive_filepath: ${{ steps.downloads-initialize-ccache.outputs.Filepath }}
URL_CCACHE_LINUX_X64: ${{ secrets.URL_CCACHE_LINUX_X64 }}
- name: Ccache install
if: env.TinyIsSelfHostedRunner == 'false'
run: |
echo '::group::Extract archive'
tar xJvf "$archive_filepath" --directory '${{ runner.temp }}'
echo '::endgroup::'
echo '::group::Install'
extractedFolder=$(basename --suffix='.tar.xz' "$archive_filename")
cd "${{ runner.temp }}/$extractedFolder"
sudo make install
echo '::endgroup::'
echo '::group::Print version'
ccache --version
echo '::endgroup::'
env:
archive_filename: ${{ steps.downloads-initialize-ccache.outputs.Filename }}
archive_filepath: ${{ steps.downloads-initialize-ccache.outputs.Filepath }}
- name: Ccache initialize
if: env.TinyIsSelfHostedRunner == 'false'
id: ccache-initialize-cache
run: |
cachePath=$(ccache --get-config cache_dir)
echo "CachePath=$cachePath" >> $GITHUB_OUTPUT
echo "ImageOS=$ImageOS" >> $GITHUB_OUTPUT
# This is not needed on the self-hosted runner
- 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:
# Distinguish also by debug/release build type
cache_name: vcpkg-linux-${{ matrix.qt.key }}-${{ matrix.build-type.key }}
cache_path: ${{ steps.ccache-initialize-cache.outputs.CachePath }}
image_os: ${{ steps.ccache-initialize-cache.outputs.ImageOS }}
- name: Ccache prepare configuration 🥳
run: |
# ~ 490 * 3 + 100
ccache --set-config max_size=1600M
ccache --set-config sloppiness=pch_defines,time_macros
- name: Ccache print version and configuration
run: |
echo '::group::Print version'
ccache --version
echo '::endgroup::'
echo '::group::Print ccache config'
ccache --show-config
echo '::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: |
echo 'no-op'
- name: Ccache clear statistics
run: |
ccache --zero-stats
# CMAKE_DISABLE_PRECOMPILE_HEADERS=OFF is correct (I want to use PCH here)
- name: TinyORM cmake configure (manual-gcc-${{ matrix.build-type.key }})
working-directory: ${{ env.TinyORMPath }}
run: >-
cmake
-S .
-B '${{ runner.workspace }}/TinyORM-builds-cmake/build-manual-gcc-${{ matrix.build-type.key }}'
-G Ninja
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=/usr/local/bin/ccache
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
-D CMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=OFF
-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 MATCH_EQUAL_EXPORTED_BUILDTREE:BOOL=ON
-D MYSQL_PING:BOOL=OFF
-D BUILD_TESTS:BOOL=OFF
-D ORM:BOOL=ON
-D TOM:BOOL=OFF
-D TOM_EXAMPLE:BOOL=OFF
- name: TinyORM cmake build ✨ (manual-gcc-${{ matrix.build-type.key }})
working-directory: >-
../TinyORM-builds-cmake/build-manual-gcc-${{ matrix.build-type.key }}
run: |
cmake --build . --target all --parallel ${{ env.TinyParallel }}
- name: Ccache print statistics
run: |
ccache --show-stats -vv
# Build and execute the HelloWorld console application
- name: HelloWorld prepare Manual method (vcpkg.json)
working-directory: HelloWorld
run: |
cp ./vcpkg.json.Manual.example ./vcpkg.json
# CMAKE_DISABLE_PRECOMPILE_HEADERS=ON is correct (no need to use PCH for one TU)
- name: HelloWorld cmake configure (manual-gcc-${{ matrix.build-type.key }})
working-directory: HelloWorld
run: >-
cmake
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/build-manual-gcc-${{ matrix.build-type.key }}'
-G Ninja
-D CMAKE_PREFIX_PATH:PATH='${{ runner.workspace }}/TinyORM-builds-cmake/build-manual-gcc-${{ matrix.build-type.key }}'
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$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-gcc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/build-manual-gcc-${{ matrix.build-type.key }}
run: |
cmake --build . --target all --parallel ${{ env.TinyParallel }}
- name: HelloWorld execute (SQLite) 🏁
working-directory: >-
../HelloWorld-builds-cmake/build-manual-gcc-${{ matrix.build-type.key }}
run: |
buildFolder='../../TinyORM-builds-cmake/build-manual-gcc-${{ matrix.build-type.key }}'
export LD_LIBRARY_PATH="$buildFolder"${LD_LIBRARY_PATH:+:}"$LD_LIBRARY_PATH"
./HelloWorld
env:
TINYORM_HELLOWORLD_DB_SQLITE_DATABASE: ../../HelloWorld.sqlite3
# FetchContent method (with install or deployment)
# ---
- name: 🪡 FetchContent method (with install or deployment) 🪡
run: |
echo 'no-op'
- name: HelloWorld prepare FetchContent method (vcpkg.json)
working-directory: HelloWorld
run: |
cp ./vcpkg.json.FetchContent.example ./vcpkg.json
# I will not write bash scripts for this, would be a pain 🫤
- name: HelloWorld prepare FetchContent method (update GIT_TAG)
shell: pwsh -NoProfile -Command "& '{0}'"
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 --zero-stats
# CMAKE_DISABLE_PRECOMPILE_HEADERS=OFF is correct (I want to use PCH here)
- name: HelloWorld cmake configure (fetchcontent-gcc-${{ matrix.build-type.key }})
working-directory: HelloWorld
run: >-
cmake
-S .
-B '${{ runner.workspace }}/HelloWorld-builds-cmake/build-fetchcontent-gcc-${{ matrix.build-type.key }}'
-G Ninja
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=/usr/local/bin/ccache
-D CMAKE_TOOLCHAIN_FILE:FILEPATH="$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake"
-D CMAKE_DISABLE_PRECOMPILE_HEADERS:BOOL=OFF
-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 MYSQL_PING:BOOL=OFF
-D BUILD_TESTS:BOOL=OFF
-D ORM:BOOL=ON
-D TOM:BOOL=OFF
-D TOM_EXAMPLE:BOOL=OFF
-D RESOLVE_TINYORM:STRING=FetchContent
# Also install it, to test the deployment process
- name: HelloWorld cmake build and install ✨ (fetchcontent-gcc-${{ matrix.build-type.key }})
working-directory: >-
../HelloWorld-builds-cmake/build-fetchcontent-gcc-${{ matrix.build-type.key }}
run: |
cmake --build . --target install --parallel ${{ env.TinyParallel }}
- name: Ccache print statistics
run: |
ccache --show-stats -vv
- name: HelloWorld execute (SQLite) 🏁
working-directory: ../HelloWorld-FetchContent-Install/${{ matrix.build-type.name }}/bin
run: |
export LD_LIBRARY_PATH='../lib'${LD_LIBRARY_PATH:+:}"$LD_LIBRARY_PATH"
./HelloWorld
env:
TINYORM_HELLOWORLD_DB_SQLITE_DATABASE: ../../../HelloWorld.sqlite3