diff --git a/.github/workflows/msys2-ucrt64-drivers.yml b/.github/workflows/msys2-ucrt64-drivers.yml new file mode 100644 index 000000000..cd079b3d7 --- /dev/null +++ b/.github/workflows/msys2-ucrt64-drivers.yml @@ -0,0 +1,262 @@ +# MySQL +# --- +# Both use the default unencrypted database connections because maria client can't connect +# to the MySQL >= 8.0.34 or >=8.1, there is some problem in TLS 1.2 and 1.3 connection, it can't +# select correct cipher. I will revert this back in the future when it will be fixed. + +name: MSYS2 UCRT64 GCC/Clang TinyDrivers + +on: + 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: + + build: + name: cmake build / ctest + + # Self-hosted runner is Windows 11 (Release Preview channel - 23H2) + runs-on: [ self-hosted, windows ] + + strategy: + matrix: + drivers-type: [ Shared, Loadable ] + + build-type: + - key: debug + name: Debug + + - key: release + name: Release + + compiler: + - key: clang + command: clang++.exe + + - key: gcc + command: g++.exe + + # Used by the msys2.cmd script + env: + MSYS2_ROOT: C:\msys64 + + steps: + - uses: actions/checkout@v4 + with: + path: main + + - name: TinyORM prepare environment + run: | + $runnerWorkPath = Resolve-Path -Path '${{ runner.workspace }}/..' + "TinyRunnerWorkPath=$runnerWorkPath" >> $env:GITHUB_ENV + + $parallel = ${{ matrix.compiler.key == 'gcc' && 3 || 9 }} + "TinyParallel=$parallel" >> $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, u means ucrt64. + $tinyormBuildFolder = 'Drivers-msys2-u-${{ matrix.compiler.key }}-' + + '${{ matrix.drivers-type }}-${{ matrix.build-type.key }}' + "TinyORMBuildFolder=$tinyormBuildFolder" >> $env:GITHUB_ENV + + $tinyormBuildTree = Join-Path -Path '${{ runner.workspace }}' TinyORM-builds-cmake ` + $tinyormBuildFolder + "TinyORMBuildTree=$tinyormBuildTree" >> $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 }} + + # This is a little useless because mysql.exe isn't reachable from the MSYS2 shell but I leave it + # here as it for sure prints a MySQL version on the host self-hosted runner instance. + - name: Print MySQL database version + run: | + mysql.exe --version + + # I will not use the msys2/setup-msys action here as I will manage it manually on the host + # machine, it would be a waste of resources because everything is already installed and + # up to date. + + - name: MSYS2 UCRT64 prepare environment + run: | + 'E:\actions-runners\bin' >> $env:GITHUB_PATH + + # Don't use the default CCACHE_DIR path on self-hosted runners and use a separate ccache folder + # for MSYS2 and compiler. + - name: Ccache prepare environment + run: | + $ccacheDirPath = Join-Path '${{ runner.workspace }}' ccache_msys2_${{ matrix.compiler.key }} + "CCACHE_DIR=$ccacheDirPath" >> $env:GITHUB_ENV + + - name: Ccache print version and configuration + shell: msys2 {0} + run: | + echo '::group::Print version' + ccache.exe --version + echo '::endgroup::' + + echo '::group::Print ccache config' + ccache.exe --show-config + echo '::endgroup::' + + - name: vcpkg prepare environment + shell: msys2 {0} + run: | + echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV + echo 'VCPKG_DEFAULT_TRIPLET=x64-mingw-dynamic' >> $GITHUB_ENV + echo 'VCPKG_DEFAULT_HOST_TRIPLET=x64-mingw-dynamic' >> $GITHUB_ENV + echo 'VCPKG_MAX_CONCURRENCY=${{ env.TinyParallel }}' >> $GITHUB_ENV + + - name: CMake print version + shell: msys2 {0} + run: | + cmake.exe --version + + - name: vcpkg print version + shell: msys2 {0} + run: | + "$VCPKG_INSTALLATION_ROOT/vcpkg.exe" --version + + - name: TinyORM create build folder (${{ env.TinyORMBuildFolder }}) + run: | + if (-not (Test-Path '${{ env.TinyORMBuildTree }}')) { + New-Item -Type Directory '${{ env.TinyORMBuildTree }}' + } + + - name: Ccache clear statistics + shell: msys2 {0} + 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.TinyORMBuildFolder }}) + shell: msys2 {0} + working-directory: ${{ env.TinyORMPath }} + run: >- + cmake.exe + -S . + -B '${{ env.TinyORMBuildTree }}' + -G Ninja + -D CMAKE_CXX_COMPILER_LAUNCHER:FILEPATH='/ucrt64/bin/ccache.exe' + -D CMAKE_CXX_COMPILER:FILEPATH="/ucrt64/bin/${{ 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=${{ matrix.build-type.name }} + -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=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.TinyORMBuildFolder }}) + shell: msys2 {0} + working-directory: ${{ env.TinyORMBuildTree }} + run: | + cmake.exe --build . --target all --parallel ${{ env.TinyParallel }} + + - name: Ccache print statistics + shell: msys2 {0} + run: | + ccache.exe --show-stats -vv + + # Used migrate:fresh instead (is safer) + - name: Create and Seed tables for unit tests 🎉 + shell: msys2 {0} + working-directory: ${{ env.TinyORMBuildTree }}/tests/testdata_tom + run: | + export PATH=../..${PATH:+:}"$PATH" + + ./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_MSYS2 }} + DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF_MSYS2 }} + TOM_TESTDATA_ENV: ${{ vars.TOM_TESTDATA_ENV }} + + - name: TinyORM execute ctest 🔥 + shell: msys2 {0} + working-directory: ${{ env.TinyORMBuildTree }} + run: | + ctest.exe --output-on-failure + 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_MSYS2 }} + DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF_MSYS2 }} + TOM_TESTS_ENV: ${{ vars.TOM_TESTS_ENV }} + + - name: Tom example test some commands (MySQL) 🚀 + shell: msys2 {0} + working-directory: ${{ env.TinyORMBuildTree }}/examples/tom + run: | + export PATH=../..${PATH:+:}"$PATH" + + ./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_MSYS2 }} + DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME_SELF_MSYS2 }} + TOM_EXAMPLE_ENV: ${{ vars.TOM_EXAMPLE_ENV }}