Linux GCC/Clang Qt5.15 #385
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 and PostgreSQL | |
# --- | |
# Both use the default unencrypted database connections. | |
name: Linux GCC/Clang Qt5.15 | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- gh-actions | |
jobs: | |
build: | |
name: cmake build / ctest | |
runs-on: ubuntu-24.04 | |
env: | |
# Settings (constant variables) | |
# This number must also be changed in the matrix as env context can't be used in the matrix | |
TINY_LLVM_VERSION: 18 | |
TINY_LLVM_APT_NAME: noble | |
# First value is a compressed data size | |
# gcc: ~ 115 * 3 + 100 ; clang: ~ 90 * 3 + 100 | |
TINY_CCACHE_MAX_SIZE_GCC: 450M | |
TINY_CCACHE_MAX_SIZE_CLANG: 380M | |
# Clang and vcpkg use $(nproc) (max. available cores) | |
TINY_PARALLEL_GCC: 2 | |
strategy: | |
matrix: | |
compiler: | |
- key: clang | |
name: clang18 | |
apt: [ clang-18, lld-18 ] | |
command: clang++-18 | |
- key: gcc | |
name: gcc12 | |
apt: [ g++-12 ] | |
command: g++-12 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: TinyORM prepare environment | |
run: | | |
runnerWorkPath=$(realpath "$RUNNER_WORKSPACE/..") | |
echo "TinyRunnerWorkPath=$runnerWorkPath" >> $GITHUB_ENV | |
sqlitePath="$runnerWorkPath/SQLite/$DB_SQLITE_DATABASE" | |
echo "TinySQLitePath=$sqlitePath" >> $GITHUB_ENV | |
[[ '${{ matrix.compiler.key }}' == 'gcc' ]] && ccacheMaxSize="$TINY_CCACHE_MAX_SIZE_GCC" \ | |
|| ccacheMaxSize="$TINY_CCACHE_MAX_SIZE_CLANG" | |
echo "TinyCcacheMaxSize=$ccacheMaxSize" >> $GITHUB_ENV | |
[[ '${{ matrix.compiler.key }}' == 'gcc' ]] && parallel=$TINY_PARALLEL_GCC \ | |
|| parallel=$(nproc) | |
echo "TinyParallel=$parallel" >> $GITHUB_ENV | |
echo "TinyParallelVcpkg=$(nproc)" >> $GITHUB_ENV | |
tinyormBuildName='${{ matrix.compiler.name }}-cmake-debug' | |
echo "TinyORMBuildName=$tinyormBuildName" >> $GITHUB_ENV | |
tinyormBuildTree="$RUNNER_WORKSPACE/TinyORM-builds-cmake/build-$tinyormBuildName" | |
echo "TinyORMBuildTree=$tinyormBuildTree" >> $GITHUB_ENV | |
env: | |
DB_SQLITE_DATABASE: ${{ secrets.DB_SQLITE_DATABASE }} | |
- name: PostgreSQL service start | |
run: | | |
sudo systemctl start postgresql.service | |
- name: PostgreSQL service check status | |
run: | | |
sudo systemctl status postgresql.service | |
pg_isready | |
- name: PostgreSQL create TinyORM user | |
run: >- | |
sudo --user=postgres -- | |
psql --command="create user \"$DB_PGSQL_USERNAME\" | |
with createdb password '$DB_PGSQL_PASSWORD';" | |
env: | |
DB_PGSQL_PASSWORD: ${{ secrets.DB_PGSQL_PASSWORD }} | |
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }} | |
- name: PostgreSQL create TinyORM database | |
run: | | |
sudo --user=postgres -- createdb --owner=$DB_PGSQL_USERNAME $DB_PGSQL_DATABASE | |
env: | |
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }} | |
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }} | |
- name: MySQL initialize crystal_mysqld.cnf configuration | |
working-directory: .github/resources/linux | |
run: | | |
sudo mv --target-directory=/etc/mysql/mysql.conf.d/ ./crystal_mysqld.cnf | |
- name: MySQL initialize crystal_client.cnf configuration (global) | |
working-directory: .github/resources/linux | |
run: >- | |
cat ./crystal_client.template.cnf | | |
sed "s/{MYSQL_HOST}/$DB_MYSQL_HOST/" | | |
sudo tee /etc/mysql/conf.d/crystal_client.cnf > /dev/null | |
env: | |
DB_MYSQL_HOST: ${{ secrets.DB_MYSQL_HOST }} | |
- name: MySQL service start | |
run: | | |
sudo systemctl start mysql.service | |
- name: MySQL change ${{ secrets.DB_MYSQL_ROOT_USERNAME }} password | |
run: >- | |
echo " | |
alter user '$DB_MYSQL_ROOT_USERNAME'@'localhost' | |
identified with caching_sha2_password by '$DB_MYSQL_ROOT_PASSWORD';" | | |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD_DEFAULT" | |
env: | |
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }} | |
DB_MYSQL_ROOT_PASSWORD_DEFAULT: ${{ secrets.DB_MYSQL_ROOT_PASSWORD_DEFAULT }} | |
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }} | |
- name: MySQL populate time zone tables π | |
run: >- | |
mysql_tzinfo_to_sql /usr/share/zoneinfo | | |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD" mysql | |
sudo systemctl restart mysql.service | |
env: | |
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }} | |
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }} | |
- name: MySQL service check status | |
run: | | |
echo '::group::Service status' | |
systemctl status mysql.service | |
echo '::endgroup::' | |
echo '::group::Service is-active check' | |
systemctl is-active --quiet mysql.service | |
echo '::endgroup::' | |
echo '::group::Ping' | |
mysqladmin --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD" ping | |
echo '::endgroup::' | |
env: | |
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }} | |
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }} | |
- name: MySQL create TinyORM database | |
run: >- | |
echo " | |
create database if not exists \`$DB_MYSQL_DATABASE\` | |
default character set $DB_MYSQL_CHARSET | |
default collate $DB_MYSQL_COLLATION;" | | |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD" | |
env: | |
DB_MYSQL_CHARSET: ${{ secrets.DB_MYSQL_CHARSET }} | |
DB_MYSQL_COLLATION: ${{ secrets.DB_MYSQL_COLLATION }} | |
DB_MYSQL_DATABASE: ${{ secrets.DB_MYSQL_DATABASE }} | |
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }} | |
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }} | |
- name: MySQL create TinyORM user | |
run: >- | |
echo " | |
create user '$DB_MYSQL_USERNAME'@'%' | |
identified with caching_sha2_password by '$DB_MYSQL_PASSWORD'; | |
grant all privileges on \`tinyorm\\_%\`.* to '$DB_MYSQL_USERNAME'@'%'; | |
grant select on \`mysql\`.\`time_zone_name\` to '$DB_MYSQL_USERNAME'@'%'; | |
flush privileges;" | | |
mysql --user="$DB_MYSQL_ROOT_USERNAME" --password="$DB_MYSQL_ROOT_PASSWORD" | |
env: | |
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }} | |
DB_MYSQL_ROOT_PASSWORD: ${{ secrets.DB_MYSQL_ROOT_PASSWORD }} | |
DB_MYSQL_ROOT_USERNAME: ${{ secrets.DB_MYSQL_ROOT_USERNAME }} | |
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }} | |
- name: SQLite create TinyORM database | |
run: | | |
mkdir --parents "$(dirname "$TinySQLitePath")" | |
touch "$TinySQLitePath" | |
- name: Print MySQL, PostgreSQL, and SQLite database versions | |
run: | | |
echo '::group::MySQL version' | |
mysql --version | |
echo '::endgroup::' | |
echo '::group::PostgreSQL version' | |
pg_config --version | |
echo '::endgroup::' | |
echo '::group::SQLite version' | |
sqlite3 --version | |
echo '::endgroup::' | |
- name: add-apt-repository Clang ${{ env.TINY_LLVM_VERSION }} | |
if: matrix.compiler.key == 'clang' | |
run: >- | |
wget -O- https://apt.llvm.org/llvm-snapshot.gpg.key | | |
sudo tee /etc/apt/trusted.gpg.d/llvm-${{ env.TINY_LLVM_VERSION }}.asc > /dev/null | |
sudo add-apt-repository --yes | |
--sourceslist 'deb http://apt.llvm.org/${{ env.TINY_LLVM_APT_NAME }}/ | |
llvm-toolchain-${{ env.TINY_LLVM_APT_NAME }}-${{ env.TINY_LLVM_VERSION }} main' | |
- name: apt update | |
run: | | |
sudo apt update | |
- name: apt install ${{ join(matrix.compiler.apt, ', ') }}, Qt 5.15 base, and ccache | |
run: >- | |
sudo apt install --yes ${{ join(matrix.compiler.apt, ' ') }} | |
qtbase5-dev libqt5sql5-mysql libqt5sql5-sqlite libqt5sql5-psql ccache | |
# No need to use lukka/get-cmake, these images always have latest version | |
- name: Ninja install latest version | |
uses: seanmiddleditch/gha-setup-ninja@master | |
with: | |
destination: ${{ env.TinyRunnerWorkPath }}/ninja-build | |
- name: Ccache initialize | |
id: ccache-initialize-cache | |
run: | | |
cachePath=$(ccache --get-config cache_dir) | |
echo "CachePath=$cachePath" >> $GITHUB_OUTPUT | |
echo "ImageOS=$ImageOS" >> $GITHUB_OUTPUT | |
- name: Ccache restore cache πΊ | |
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: ${{ matrix.compiler.name }}-qt5 | |
cache_path: ${{ steps.ccache-initialize-cache.outputs.CachePath }} | |
image_os: ${{ steps.ccache-initialize-cache.outputs.ImageOS }} | |
- name: Ccache prepare configuration π₯³ | |
run: | | |
ccache --set-config max_size="$TinyCcacheMaxSize" | |
ccache --set-config sloppiness=pch_defines,time_macros | |
ccache --show-config | |
- 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::' | |
- name: vcpkg prepare environment | |
run: | | |
echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV | |
echo 'VCPKG_DEFAULT_TRIPLET=x64-linux-dynamic' >> $GITHUB_ENV | |
echo "VCPKG_MAX_CONCURRENCY=$TinyParallelVcpkg" >> $GITHUB_ENV | |
- name: CMake print version | |
run: | | |
cmake --version | |
- name: Ccache clear statistics | |
run: | | |
ccache --zero-stats | |
- name: TinyORM cmake configure (${{ env.TinyORMBuildName }}) | |
run: >- | |
cmake --log-level=DEBUG --log-context | |
-S . | |
-B "$TinyORMBuildTree" | |
-G Ninja | |
-D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache | |
-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=Debug | |
-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=OFF | |
-D STRICT_MODE:BOOL=OFF | |
-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=OFF | |
- name: TinyORM cmake build β¨ (${{ env.TinyORMBuildName }}) | |
working-directory: ${{ env.TinyORMBuildTree }} | |
run: | | |
cmake --build . --target all --parallel $TinyParallel | |
- name: Ccache print statistics | |
run: | | |
ccache --show-stats --verbose | |
- name: TinyORM add on the $LD_LIBRARY_PATH | |
run: | | |
echo "LD_LIBRARY_PATH=$TinyORMBuildTree${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" >> $env:GITHUB_ENV | |
- name: Create and Seed tables for unit tests π | |
working-directory: ${{ env.TinyORMBuildTree }}/tests/testdata_tom | |
run: >- | |
./tom_testdata migrate | |
--database=tinyorm_testdata_tom_mysql,tinyorm_testdata_tom_postgres,tinyorm_testdata_tom_sqlite | |
--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 }} | |
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }} | |
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }} | |
DB_PGSQL_CHARSET: ${{ secrets.DB_PGSQL_CHARSET }} | |
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }} | |
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST }} | |
DB_PGSQL_PASSWORD: ${{ secrets.DB_PGSQL_PASSWORD }} | |
DB_PGSQL_SEARCHPATH: ${{ secrets.DB_PGSQL_SEARCHPATH }} | |
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }} | |
DB_SQLITE_DATABASE: ${{ env.TinySQLitePath }} | |
TOM_TESTDATA_ENV: ${{ vars.TOM_TESTDATA_ENV }} | |
- name: TinyORM execute ctest π₯ | |
working-directory: ${{ env.TinyORMBuildTree }} | |
run: | | |
ctest --output-on-failure --parallel $(($TinyParallel + $(nproc) / 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 }} | |
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }} | |
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }} | |
DB_PGSQL_CHARSET: ${{ secrets.DB_PGSQL_CHARSET }} | |
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }} | |
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST }} | |
DB_PGSQL_PASSWORD: ${{ secrets.DB_PGSQL_PASSWORD }} | |
DB_PGSQL_SEARCHPATH: ${{ secrets.DB_PGSQL_SEARCHPATH }} | |
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }} | |
DB_SQLITE_DATABASE: ${{ env.TinySQLitePath }} | |
TOM_TESTS_ENV: ${{ vars.TOM_TESTS_ENV }} | |
- name: Tom example test some commands (MySQL) π | |
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom | |
run: | | |
./tom migrate:fresh --database=tinyorm_tom_mysql --no-ansi | |
./tom migrate:uninstall --reset --database=tinyorm_tom_mysql --no-ansi | |
./tom migrate:install --database=tinyorm_tom_mysql --no-ansi | |
./tom migrate --database=tinyorm_tom_mysql --seed --no-ansi | |
./tom migrate:status --database=tinyorm_tom_mysql --no-ansi | |
./tom migrate:refresh --database=tinyorm_tom_mysql --seed --no-ansi | |
./tom migrate:reset --database=tinyorm_tom_mysql --no-ansi | |
./tom 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 }} | |
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }} | |
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }} | |
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }} | |
- name: Tom example test some commands (PostgreSQL) π | |
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom | |
run: | | |
./tom migrate:fresh --database=tinyorm_tom_postgres --no-ansi | |
./tom migrate:uninstall --reset --database=tinyorm_tom_postgres --no-ansi | |
./tom migrate:install --database=tinyorm_tom_postgres --no-ansi | |
./tom migrate --database=tinyorm_tom_postgres --seed --no-ansi | |
./tom migrate:status --database=tinyorm_tom_postgres --no-ansi | |
./tom migrate:refresh --database=tinyorm_tom_postgres --seed --no-ansi | |
./tom migrate:reset --database=tinyorm_tom_postgres --no-ansi | |
./tom migrate:uninstall --database=tinyorm_tom_postgres --no-ansi | |
env: | |
DB_PGSQL_CHARSET: ${{ secrets.DB_PGSQL_CHARSET }} | |
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }} | |
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST }} | |
DB_PGSQL_PASSWORD: ${{ secrets.DB_PGSQL_PASSWORD }} | |
DB_PGSQL_SEARCHPATH: ${{ secrets.DB_PGSQL_SEARCHPATH }} | |
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }} | |
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }} | |
- name: Tom example test some commands (SQLite) π | |
working-directory: ${{ env.TinyORMBuildTree }}/examples/tom | |
run: | | |
./tom migrate:fresh --database=tinyorm_tom_sqlite --no-ansi | |
./tom migrate:uninstall --reset --database=tinyorm_tom_sqlite --no-ansi | |
./tom migrate:install --database=tinyorm_tom_sqlite --no-ansi | |
./tom migrate --database=tinyorm_tom_sqlite --seed --no-ansi | |
./tom migrate:status --database=tinyorm_tom_sqlite --no-ansi | |
./tom migrate:refresh --database=tinyorm_tom_sqlite --seed --no-ansi | |
./tom migrate:reset --database=tinyorm_tom_sqlite --no-ansi | |
./tom migrate:uninstall --database=tinyorm_tom_sqlite --no-ansi | |
env: | |
DB_SQLITE_DATABASE: ${{ env.TinySQLitePath }} | |
TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }} |