Skip to content

Commit 39504d2

Browse files
committed
Merge trackjdk/REL1_6_STABLE/JEP472 into REL1_6_STABLE
Completes pull request #511.
2 parents 9de9217 + c5f9ae4 commit 39504d2

File tree

5 files changed

+910
-1573
lines changed

5 files changed

+910
-1573
lines changed

.github/workflows/ci-lazypg.yml

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
# This workflow will build and test PL/Java against a version of PostgreSQL
2+
# lazily obtained (either preinstalled in the GitHub Actions runner environment,
3+
# or obtained from a package repository if the runner does not provide one).
4+
# Arrange for the matrix to include a pg version, for cases where one must be
5+
# installed.
6+
7+
name: CI lazy getting PostgreSQL
8+
9+
permissions:
10+
contents: read
11+
12+
on:
13+
push:
14+
branches: [ master, REL1_6_STABLE ]
15+
pull_request:
16+
branches: [ master, REL1_6_STABLE ]
17+
18+
jobs:
19+
build:
20+
if: true
21+
22+
runs-on: ${{ matrix.oscc.os }}
23+
continue-on-error: true
24+
strategy:
25+
matrix:
26+
oscc:
27+
- os: ubuntu-latest
28+
cc: gcc
29+
- os: macos-13
30+
cc: clang
31+
pg: 17
32+
- os: macos-14
33+
cc: clang
34+
pg: 17
35+
# - os: windows-latest
36+
# cc: msvc
37+
# - os: windows-latest
38+
# cc: mingw
39+
java: [11, 17, 21, 23]
40+
41+
steps:
42+
43+
- name: Check for JDK preinstalled
44+
id: jdkcheck
45+
shell: bash
46+
env:
47+
JAVAVER: ${{ matrix.java }}
48+
run: |
49+
if
50+
candidate="JAVA_HOME_${JAVAVER}_${RUNNER_ARCH}"
51+
echo -n "Environment contains $candidate? "
52+
[[ -n ${!candidate+set} ]]
53+
then
54+
echo yes
55+
echo >>"$GITHUB_ENV" "JAVA_HOME=${!candidate}"
56+
echo >>"$GITHUB_OUTPUT" java_found=true
57+
elif
58+
candidate="JAVA_HOME_${JAVAVER}_$(tr A-Z a-z <<<${RUNNER_ARCH})"
59+
echo -ne 'no\n'"Environment contains $candidate? "
60+
[[ -n ${!candidate+set} ]]
61+
then
62+
echo yes
63+
echo >>"$GITHUB_ENV" "JAVA_HOME=${!candidate}"
64+
echo >>"$GITHUB_OUTPUT" java_found=true
65+
else
66+
echo -e 'no\n'"only: ${!JAVA_HOME_*}"
67+
echo >>"$GITHUB_OUTPUT" java_found=false
68+
fi
69+
70+
- name: Fetch a JDK
71+
if: ${{ 'false' == steps.jdkcheck.outputs.java_found }}
72+
uses: actions/setup-java@7a6d8a8234af8eb26422e24e3006232cccaa061b
73+
with:
74+
distribution: temurin
75+
java-version: ${{ matrix.java }}
76+
77+
- name: Compute absolute paths for java and jshell
78+
shell: bash
79+
run: |
80+
if [[ $RUNNER_OS == Windows ]]
81+
then
82+
echo >>"$GITHUB_ENV" "ABS_JAVA=$JAVA_HOME"'\bin\java'
83+
echo >>"$GITHUB_ENV" "ABS_JSHELL=$JAVA_HOME"'\bin\jshell'
84+
else
85+
echo >>"$GITHUB_ENV" "ABS_JAVA=$JAVA_HOME/bin/java"
86+
echo >>"$GITHUB_ENV" "ABS_JSHELL=$JAVA_HOME/bin/jshell"
87+
fi
88+
89+
- name: Set PGCONFIG in environment, installing PostgreSQL if needed
90+
shell: bash
91+
env:
92+
PGVER: ${{ matrix.oscc.pg }}
93+
run: |
94+
if [[ $RUNNER_OS == Linux ]]
95+
then
96+
echo >>"$GITHUB_ENV" PGCONFIG=pg_config
97+
elif [[ $RUNNER_OS == Windows ]]
98+
then
99+
echo >>"$GITHUB_ENV" PGCONFIG="$PGBIN"'\pg_config'
100+
elif [[ $RUNNER_OS == macOS ]]
101+
then
102+
echo '::group::brew update'
103+
brew update
104+
echo '::endgroup::'
105+
echo "::group::brew install postgresql@$PGVER"
106+
# HOMEBREW_GITHUB_ACTIONS will suppress the formula's initdb
107+
HOMEBREW_GITHUB_ACTIONS=1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 \
108+
brew install postgresql@"$PGVER"
109+
echo '::endgroup::'
110+
pfx=$(brew --prefix postgresql@"$PGVER")
111+
echo >>"$GITHUB_ENV" PGCONFIG="$pfx/bin/pg_config"
112+
fi
113+
114+
- name: Report Java, Maven, and PostgreSQL versions
115+
shell: bash
116+
run: |
117+
"$ABS_JAVA" -version
118+
mvn --version
119+
"$PGCONFIG"
120+
121+
- name: Obtain PG development files (Ubuntu, PGDG)
122+
if: ${{ 'Linux' == runner.os }}
123+
run: |
124+
pgver=$("$PGCONFIG" --version)
125+
pgver=${pgver##PostgreSQL }
126+
pgver=${pgver%% *}
127+
pgver=${pgver%.*}
128+
echo '::group::Install PGDG key and repo'
129+
curl -s -S https://www.postgresql.org/media/keys/ACCC4CF8.asc |
130+
gpg --dearmor |
131+
sudo dd of=/etc/apt/trusted.gpg.d/apt.postgresql.org.gpg
132+
echo \
133+
deb \
134+
http://apt.postgresql.org/pub/repos/apt \
135+
"$(lsb_release -cs)-pgdg" \
136+
main |
137+
sudo tee /etc/apt/sources.list.d/pgdg.list
138+
echo '::endgroup::'
139+
echo '::group::apt-get update'
140+
sudo apt-get update
141+
echo '::endgroup::'
142+
echo "::group::apt-get install postgresql-server-dev-$pgver"
143+
sudo apt-get install postgresql-server-dev-"$pgver" libkrb5-dev
144+
echo '::endgroup::'
145+
146+
- name: Confirm PostgreSQL development files are present
147+
shell: python
148+
run: |
149+
from os import getenv
150+
from os.path import join
151+
from re import sub
152+
from subprocess import check_output
153+
154+
pgconfig = getenv('PGCONFIG')
155+
156+
def ask_pg_config(what):
157+
return check_output([pgconfig, '--'+what]).splitlines()[0]
158+
159+
pgch = join(ask_pg_config('includedir-server'), b'pg_config.h')
160+
161+
with open(pgch, 'r') as f:
162+
line = [ln for ln in f if ln.startswith('#define PG_VERSION_STR ')][0]
163+
164+
vers = sub(r'#define PG_VERSION_STR "(.*)"\n', r'\1', line)
165+
166+
print('PostgreSQL development files are present:', vers, sep='\n')
167+
168+
- name: Check out PL/Java
169+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
170+
with:
171+
path: pljava
172+
173+
- name: Build PL/Java (Linux, macOS)
174+
if: ${{ 'Windows' != runner.os }}
175+
working-directory: pljava
176+
run: |
177+
mvn clean install --batch-mode \
178+
-Dpgsql.pgconfig="$PGCONFIG" \
179+
-Psaxon-examples -Ppgjdbc \
180+
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
181+
182+
- name: Build PL/Java (Windows MinGW-w64)
183+
if: ${{ 'Windows' == runner.os && 'mingw' == matrix.oscc.cc }}
184+
working-directory: pljava
185+
#
186+
# GitHub Actions will allow 'bash' as a shell choice, even on a Windows
187+
# runner, in which case it's the bash from Git for Windows. That isn't the
188+
# same as the msys64\usr\bin\bash that we want; what's more, while both
189+
# rely on a cygwin DLL, they don't rely on the same one, and an attempt
190+
# to exec one from the other leads to a "fatal error - cygheap base
191+
# mismatch". So, the bash we want has to be started by something other
192+
# than the bash we've got. In this case, set shell: to a command that
193+
# will use cmd to start the right bash.
194+
#
195+
# Some of the MinGW magic is set up by the bash profile run at "login", so
196+
# bash must be started with -l. That profile ends with a cd $HOME, so to
197+
# avoid changing the current directory, set HOME=. first (credit for that:
198+
# https://superuser.com/a/806371). As set above, . is really the pljava
199+
# working-directory, so the bash script should start by resetting HOME to
200+
# the path of its parent.
201+
#
202+
# The runner is provisioned with a very long PATH that includes separate
203+
# bin directories for pre-provisioned packages. The MinGW profile replaces
204+
# that with a much shorter path, so mvn and pg_config below must be given
205+
# as absolute paths (using M2 and PGBIN supplied in the environment) or
206+
# they won't be found. As long as mvn itself can be found, it is able
207+
# to find java without difficulty, using the JAVA_HOME that is also in
208+
# the environment.
209+
#
210+
# Those existing variables in the environment are all spelled in Windows
211+
# style with drive letters, colons, and backslashes, rather than the MinGW
212+
# unixy style, but the mingw bash doesn't seem to object.
213+
#
214+
# If you use the runner-supplied bash to examine the environment, you will
215+
# see MSYSTEM=MINGW64 already in it, but that apparently is something the
216+
# runner-supplied bash does. It must be set here before invoking the MinGW
217+
# bash directly.
218+
#
219+
env:
220+
HOME: .
221+
MSYSTEM: MINGW64
222+
shell: 'cmd /C "c:\msys64\usr\bin\bash -l "{0}""'
223+
run: |
224+
HOME=$( (cd .. && pwd) )
225+
"$M2"/mvn clean install --batch-mode \
226+
-Dpgsql.pgconfig="$PGCONFIG" \
227+
-Psaxon-examples -Ppgjdbc \
228+
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
229+
230+
- name: Install and test PL/Java
231+
working-directory: pljava
232+
shell: bash
233+
run: |
234+
packageJar=$(find pljava-packaging -name pljava-pg*.jar -print)
235+
236+
mavenRepo="$HOME/.m2/repository"
237+
238+
saxonVer=$(
239+
find "$mavenRepo/net/sf/saxon/Saxon-HE" \
240+
-name 'Saxon-HE-*.jar' -print |
241+
sort |
242+
tail -n 1
243+
)
244+
saxonVer=${saxonVer%/*}
245+
saxonVer=${saxonVer##*/}
246+
247+
jdbcJar=$(
248+
find "$mavenRepo/org/postgresql/postgresql" \
249+
-name 'postgresql-*.jar' -print |
250+
sort |
251+
tail -n 1
252+
)
253+
254+
#
255+
# The runner on a Unix-like OS is running as a non-privileged user, but
256+
# has passwordless sudo available (needed to install the PL/Java files
257+
# into the system directories where the supplied PostgreSQL lives). By
258+
# contrast, on Windows the runner has admin privilege, and can install
259+
# the files without any fuss (but later below, pg_ctl will have to be
260+
# used when starting PostgreSQL; pg_ctl has a Windows-specific ability
261+
# to drop admin privs so postgres will not refuse to start).
262+
#
263+
# The Git for Windows bash environment includes a find command, and the
264+
# things found have unixy paths returned. Make them Windowsy here, with
265+
# a hardcoded assumption they start with /c which should become c: (as
266+
# appears to be the case in the Windows runner currently).
267+
#
268+
echo '::group::Install files from the package jar'
269+
if [[ $RUNNER_OS == Windows ]]
270+
then
271+
pathSep=';'
272+
"$ABS_JAVA" -Dpgconfig="$PGCONFIG" -jar "$packageJar"
273+
function toWindowsPath() {
274+
local p
275+
p="c:${1#/c}"
276+
printf "%s" "${p//\//\\}"
277+
}
278+
jdbcJar="$(toWindowsPath "$jdbcJar")"
279+
mavenRepo="$(toWindowsPath "$mavenRepo")"
280+
else
281+
pathSep=':'
282+
sudo "$ABS_JAVA" -Dpgconfig="$PGCONFIG" -jar "$packageJar"
283+
fi
284+
echo '::endgroup::'
285+
286+
"$ABS_JSHELL" \
287+
-execution local \
288+
"-J--class-path=$packageJar$pathSep$jdbcJar" \
289+
"--class-path=$packageJar" \
290+
"-J--add-modules=java.sql.rowset,jdk.httpserver" \
291+
"-J-Dpgconfig=$PGCONFIG" \
292+
"-J-DmavenRepo=$mavenRepo" \
293+
"-J-DsaxonVer=$saxonVer" \
294+
CI/integration

0 commit comments

Comments
 (0)