Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Windows MSVC and MinGW-w64 tests in GitHub Actions CI #514

Merged
merged 3 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 38 additions & 44 deletions .github/workflows/ci-lazypg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ jobs:
- os: macos-14
cc: clang
pg: 17
# - os: windows-latest
# cc: msvc
# - os: windows-latest
# cc: mingw
- os: windows-latest
cc: msvc
- os: windows-latest
cc: mingw
java: [11, 17, 21, 23]
exclude:
- oscc: {os: windows-latest}
java: 17
- oscc: {os: windows-latest}
java: 23

steps:

Expand Down Expand Up @@ -86,7 +91,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 }}
Expand All @@ -111,6 +117,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: |
Expand Down Expand Up @@ -170,6 +185,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
Expand All @@ -182,46 +213,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 \
Expand Down
2 changes: 1 addition & 1 deletion CI/integration
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading