From 4f5d9d8ec363520b87b6e702ea7abb60965daf61 Mon Sep 17 00:00:00 2001 From: Chapman Flack Date: Fri, 7 Mar 2025 21:08:13 -0500 Subject: [PATCH 1/3] Enable CI for Windows MSVC in GitHub Actions The Windows runner comes with an MSVC-built PostgreSQL preinstalled (probably the Chocolatey one, which relies on the EnterpriseDB installer). The fussiest part of configuration is finding the Visual Studio .bat file that sets all the environment variables needed for the build to succeed, but there is an action ilammy/msvc-dev-cmd that takes care of finding and running that, capturing its changes to the environment, and replicating those in the environment of the subsequent steps. For some reason java.home on Windows has the JVM shared object under bin\server and not lib/server as on Linux. --- .github/workflows/ci-lazypg.yml | 38 +++++++++++++++++++++++---------- CI/integration | 2 +- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-lazypg.yml b/.github/workflows/ci-lazypg.yml index c11ac9104..db7d55865 100644 --- a/.github/workflows/ci-lazypg.yml +++ b/.github/workflows/ci-lazypg.yml @@ -24,19 +24,19 @@ jobs: strategy: matrix: oscc: - - os: ubuntu-latest - cc: gcc - - os: macos-13 - cc: clang - pg: 17 - - os: macos-14 - cc: clang - pg: 17 -# - os: windows-latest -# cc: msvc +# - os: ubuntu-latest +# cc: gcc +# - os: macos-13 +# cc: clang +# pg: 17 +# - os: macos-14 +# cc: clang +# pg: 17 + - os: windows-latest + cc: msvc # - os: windows-latest # cc: mingw - java: [11, 17, 21, 23] + java: [21] steps: @@ -170,6 +170,22 @@ jobs: with: path: pljava + - name: Set plethora of MSVC environment variables (Windows MSVC) + if: ${{ 'Windows' == runner.os && 'msvc' == matrix.oscc.cc }} + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 + + - name: Build PL/Java (Windows MSVC) + if: ${{ 'Windows' == runner.os && 'msvc' == matrix.oscc.cc }} + working-directory: pljava + # shell: cmd because of the issue described for ilammy/msvc-dev-cmd + # with Actions bash prepending stuff to the just-carefully-created PATH + shell: cmd + run: | + mvn clean install --batch-mode ^ + -Dpgsql.pgconfig="%PGCONFIG%" ^ + -Psaxon-examples -Ppgjdbc ^ + -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + - name: Build PL/Java (Linux, macOS) if: ${{ 'Windows' != runner.os }} working-directory: pljava diff --git a/CI/integration b/CI/integration index 21ac72516..fd8da7676 100644 --- a/CI/integration +++ b/CI/integration @@ -123,7 +123,7 @@ Path libjvm = ( ? Stream.of("libjli.dylib", "jli/libjli.dylib") .map(s -> javaLibDir.resolve(s)) .filter(Files::exists).findFirst().get() - : javaLibDir.resolve(s_isWindows ? "jvm.dll" : "server/libjvm.so") + : javaLibDir.resolve(s_isWindows ? "server\\jvm.dll" : "server/libjvm.so") ); // Use deprecated major() here because feature() first appears in Java 10 From 4752abf64bbb0f8ed0b5f28ce417d869a4222b03 Mon Sep 17 00:00:00 2001 From: Chapman Flack Date: Fri, 7 Mar 2025 22:40:49 -0500 Subject: [PATCH 2/3] Also enable MinGW-w64 test with PG from pacman MSYS2 is preinstalled on the runner but apparently not with gcc. Have pacman install that also, and prepend the c:\msys64\mingw64\bin directory to the PATH. Using msys2bash, it has to be prepended in the form /c/msys64/mingw64/bin, which gets transformed correctly into the Windows environment variable. The gcc that is installed on the runner is in /c/mingw64/bin rather than /c/msys64/mingw64/bin where pacman puts it. A lot of cycles and bandwidth would be saved if that one could be used. PL/Java can be successfully built that way, but on loading it into the backend, "server process (PID 2116) was terminated by exception 0xC0000005". So it seems that building to load into a pacman PostgreSQL backend must be done using the pacman gcc. --- .github/workflows/ci-lazypg.yml | 59 +++++++++------------------------ 1 file changed, 16 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci-lazypg.yml b/.github/workflows/ci-lazypg.yml index db7d55865..adcdf9a02 100644 --- a/.github/workflows/ci-lazypg.yml +++ b/.github/workflows/ci-lazypg.yml @@ -32,10 +32,10 @@ jobs: # - os: macos-14 # cc: clang # pg: 17 - - os: windows-latest - cc: msvc # - os: windows-latest -# cc: mingw +# cc: msvc + - os: windows-latest + cc: mingw java: [21] steps: @@ -86,7 +86,8 @@ jobs: echo >>"$GITHUB_ENV" "ABS_JSHELL=$JAVA_HOME/bin/jshell" fi - - name: Set PGCONFIG in environment, installing PostgreSQL if needed + - name: Set PGCONFIG in environment, getting PostgreSQL if needed (!mingw) + if: ${{ 'mingw' != matrix.oscc.cc }} shell: bash env: PGVER: ${{ matrix.oscc.pg }} @@ -111,6 +112,15 @@ jobs: echo >>"$GITHUB_ENV" PGCONFIG="$pfx/bin/pg_config" fi + - name: Set PGCONFIG in environment, getting gcc and PostgreSQL (mingw) + if: ${{ 'mingw' == matrix.oscc.cc }} + shell: C:\shells\msys2bash.cmd {0} + run: | + pacman -S --noconfirm \ + mingw-w64-x86_64-gcc \ + mingw-w64-x86_64-postgresql + echo >>"$GITHUB_ENV" PGCONFIG='c:\msys64\mingw64\bin\pg_config' + - name: Report Java, Maven, and PostgreSQL versions shell: bash run: | @@ -198,46 +208,9 @@ jobs: - name: Build PL/Java (Windows MinGW-w64) if: ${{ 'Windows' == runner.os && 'mingw' == matrix.oscc.cc }} working-directory: pljava - # - # GitHub Actions will allow 'bash' as a shell choice, even on a Windows - # runner, in which case it's the bash from Git for Windows. That isn't the - # same as the msys64\usr\bin\bash that we want; what's more, while both - # rely on a cygwin DLL, they don't rely on the same one, and an attempt - # to exec one from the other leads to a "fatal error - cygheap base - # mismatch". So, the bash we want has to be started by something other - # than the bash we've got. In this case, set shell: to a command that - # will use cmd to start the right bash. - # - # Some of the MinGW magic is set up by the bash profile run at "login", so - # bash must be started with -l. That profile ends with a cd $HOME, so to - # avoid changing the current directory, set HOME=. first (credit for that: - # https://superuser.com/a/806371). As set above, . is really the pljava - # working-directory, so the bash script should start by resetting HOME to - # the path of its parent. - # - # The runner is provisioned with a very long PATH that includes separate - # bin directories for pre-provisioned packages. The MinGW profile replaces - # that with a much shorter path, so mvn and pg_config below must be given - # as absolute paths (using M2 and PGBIN supplied in the environment) or - # they won't be found. As long as mvn itself can be found, it is able - # to find java without difficulty, using the JAVA_HOME that is also in - # the environment. - # - # Those existing variables in the environment are all spelled in Windows - # style with drive letters, colons, and backslashes, rather than the MinGW - # unixy style, but the mingw bash doesn't seem to object. - # - # If you use the runner-supplied bash to examine the environment, you will - # see MSYSTEM=MINGW64 already in it, but that apparently is something the - # runner-supplied bash does. It must be set here before invoking the MinGW - # bash directly. - # - env: - HOME: . - MSYSTEM: MINGW64 - shell: 'cmd /C "c:\msys64\usr\bin\bash -l "{0}""' + shell: C:\shells\msys2bash.cmd {0} run: | - HOME=$( (cd .. && pwd) ) + PATH='/c/msys64/mingw64/bin:'"$PATH" "$M2"/mvn clean install --batch-mode \ -Dpgsql.pgconfig="$PGCONFIG" \ -Psaxon-examples -Ppgjdbc \ From 00507e23cff6a3e00106f77f692afe181b604254 Mon Sep 17 00:00:00 2001 From: Chapman Flack Date: Sat, 8 Mar 2025 11:26:07 -0500 Subject: [PATCH 3/3] Re-enable the whole CI matrix Use exclude: to test fewer Java versions on the Windows runners, which seem to be extra slow. --- .github/workflows/ci-lazypg.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-lazypg.yml b/.github/workflows/ci-lazypg.yml index adcdf9a02..fbff5f858 100644 --- a/.github/workflows/ci-lazypg.yml +++ b/.github/workflows/ci-lazypg.yml @@ -24,19 +24,24 @@ jobs: strategy: matrix: oscc: -# - os: ubuntu-latest -# cc: gcc -# - os: macos-13 -# cc: clang -# pg: 17 -# - os: macos-14 -# cc: clang -# pg: 17 -# - os: windows-latest -# cc: msvc + - os: ubuntu-latest + cc: gcc + - os: macos-13 + cc: clang + pg: 17 + - os: macos-14 + cc: clang + pg: 17 + - os: windows-latest + cc: msvc - os: windows-latest cc: mingw - java: [21] + java: [11, 17, 21, 23] + exclude: + - oscc: {os: windows-latest} + java: 17 + - oscc: {os: windows-latest} + java: 23 steps: