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

Use java 17 #3155

Open
wants to merge 4 commits into
base: release/42.4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 41 additions & 23 deletions .github/workflows/main.yml
Expand Up @@ -65,23 +65,23 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 50
- name: 'Set up JDK 11'
uses: actions/setup-java@v2
- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
java-version: 17
- uses: burrunan/gradle-cache-action@v1
name: Run CheckerFramework
env:
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
with:
read-only: ${{ matrix.os == 'self-hosted' }}
job-id: checker-jdk11
job-id: checker-jdk17
arguments: --scan --no-parallel --no-daemon -PenableCheckerframework classes

source-distribution-check:
name: 'Source distribution (JDK 11)'
name: 'Source distribution (JDK 17)'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -90,18 +90,18 @@ jobs:
- name: Start PostgreSQL
working-directory: docker/postgres-server
run: docker-compose up -d && docker-compose logs
- name: 'Set up JDK 11'
uses: actions/setup-java@v2
- name: 'Set up JDK 17'
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 11
java-version: 17
- uses: burrunan/gradle-cache-action@v1
name: Prepare source distribution
env:
S3_BUILD_CACHE_ACCESS_KEY_ID: ${{ secrets.S3_BUILD_CACHE_ACCESS_KEY_ID }}
S3_BUILD_CACHE_SECRET_KEY: ${{ secrets.S3_BUILD_CACHE_SECRET_KEY }}
with:
job-id: source-release-jdk11
job-id: source-release-jdk17
arguments: --scan --no-parallel --no-daemon sourceDistribution -Ppgjdbc.version=1.0 -Prelease
- name: Verify source distribution
working-directory: pgjdbc/build/distributions
Expand Down Expand Up @@ -157,23 +157,35 @@ jobs:
sed -i -r '/- (543[3-4]):\1/d' docker-compose.yml
docker-compose up -d
docker-compose logs
- name: 'Get test node ARCH'
run: echo "::set-output name=arch_name::$(uname -i)"
id: get_arch_name
- name: Set up Java ${{ matrix.java_version }}, ${{ matrix.java_distribution }}
if: ${{ steps.get_arch_name.outputs.arch_name != 'aarch64' }}
uses: actions/setup-java@v2
- name: Set up Java 17 and ${{ matrix.non_ea_java_version }}, ${{ matrix.java_distribution }}, ${{ runner.arch }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java_version }}
# The latest one will be the default, so we use Java 17 for launching Gradle
# oracle-actions/setup-java below requires Java 17, so we must install Java 17 before calling oracle-actions/setup-java
java-version: |
${{ matrix.non_ea_java_version }}
17
distribution: ${{ matrix.java_distribution }}
architecture: x64
- name: 'Setup JDK ${{ matrix.java_version }} on ARM64'
if: ${{ steps.get_arch_name.outputs.arch_name == 'aarch64' }}
uses: AdoptOpenJDK/install-jdk@v1
# Architecture is explicit to workaround https://github.com/actions/setup-java/issues/559
architecture: ${{ runner.arch == 'ARM64' && 'aarch64' || 'x64' }}
- name: Set up Java ${{ matrix.java_version }}, oracle
id: setup_ea_java
if: ${{ matrix.oracle_java_website != '' }}
uses: oracle-actions/setup-java@7a0114d66dbd02646abd345c3395b34c148e6126 # v1.3.2
env:
JAVA_HOME_17_X64: ${{ env.JAVA_HOME_17_AARCH64 || env.JAVA_HOME_17_X64 }}
with:
impl: hotspot # or openj9
version: ${{ matrix.java_version }}
architecture: aarch64
website: ${{ matrix.oracle_java_website }}
release: ${{ matrix.java_version }}
- name: Set up Java 17 ${{ matrix.java_distribution }} as default
# oracle-actions/setup-java above installs EA java by default, so we need to reinstall Java 17 as the default
if: ${{ matrix.oracle_java_website != '' }}
uses: actions/setup-java@v3
with:
java-version: 17
distribution: ${{ matrix.java_distribution }}
# Architecture is explicit to workaround https://github.com/actions/setup-java/issues/559
architecture: ${{ runner.arch == 'ARM64' && 'aarch64' || 'x64' }}
- name: Prepare local properties
run: |
# See https://github.com/actions/runner/issues/409
Expand All @@ -196,6 +208,12 @@ jobs:
arguments: --scan --no-parallel --no-daemon jandex test
properties: |
includeTestTags=${{ matrix.includeTestTags }}
testExtraJvmArgs=${{ matrix.testExtraJvmArgs }}
jdkBuildVersion=17
jdkTestVersion=${{ matrix.java_version == 'EA' && steps.setup_ea_java.outputs.version || matrix.java_version }}
jdkTestVendor=${{ matrix.java_vendor }}
# We provision JDKs with GitHub Actions for caching purposes, so Gradle should rather fail in case JDK is not found
org.gradle.java.installations.auto-download=false

- name: 'Install krb5 for GSS tests'
if: ${{ matrix.gss == 'yes' }}
Expand Down
75 changes: 57 additions & 18 deletions .github/workflows/matrix.js
Expand Up @@ -18,16 +18,20 @@ const matrix = new MatrixBuilder();
matrix.addAxis({
name: 'java_distribution',
values: [
'zulu',
'temurin',
'liberica',
'microsoft',
{value: 'corretto', vendor: 'amazon', weight: 1},
{value: 'liberica', vendor: 'bellsoft', weight: 1},
{value: 'microsoft', vendor: 'microsoft', weight: 1},
{value: 'oracle', vendor: 'oracle', weight: 1},
{value: 'semeru', vendor: 'ibm', weight: 4},
{value: 'temurin', vendor: 'eclipse', weight: 1},
{value: 'zulu', vendor: 'azul', weight: 1},
]
});

// TODO: support different JITs (see https://github.com/actions/setup-java/issues/279)
matrix.addAxis({name: 'jit', title: '', values: ['hotspot']});
// We can't yet use EA here, see https://github.com/oracle-actions/setup-java/issues/65
const eaJava = '22';

// Below versions will be used for testing only
matrix.addAxis({
name: 'java_version',
title: x => 'Java ' + x,
Expand All @@ -36,6 +40,8 @@ matrix.addAxis({
'8',
'11',
'17',
'21',
eaJava,
]
});

Expand Down Expand Up @@ -186,8 +192,8 @@ matrix.addAxis({
]
});

function isLessThan(pg_version, minVersion){
return Number(pg_version) < Number(minVersion);
function lessThan(minVersion) {
return value => Number(value) < Number(minVersion);
}

matrix.setNamePattern([
Expand All @@ -196,16 +202,25 @@ matrix.setNamePattern([
'check_anorm_sbt', 'gss', 'replication', 'slow_tests',
]);

matrix.exclude(row => row.ssl.value === 'yes' && isLessThan(row.pg_version, '9.3'));
matrix.exclude(row => row.scram.value === 'yes' && isLessThan(row.pg_version, '10'));
matrix.exclude(row => row.replication.value === 'yes' && isLessThan(row.pg_version, '9.6'));

// Microsoft Java has no distribution for 8
matrix.exclude({java_distribution: 'microsoft', java_version: '8'});
// We take EA builds from Oracle
matrix.imply({java_version: eaJava}, {java_distribution: {value: 'oracle'}})
matrix.exclude({ssl: {value: 'yes'}, pg_version: lessThan('9.3')});
// matrix.exclude(row => row.ssl.value === 'yes' && isLessThan(row.pg_version, '9.3'));
matrix.exclude({scram: {value: 'yes'}, pg_version: lessThan('10')});
matrix.exclude({replication: {value: 'yes'}, pg_version: lessThan('9.6')});
//org.postgresql.test.jdbc2.ArrayTest fails using simple mode for versions less than 9.0 with malformed Array literal
matrix.exclude({query_mode: {value: 'simple'}, pg_version: lessThan('9.1')});
//matrix.exclude({query_mode: {value: 'simple'}, pg_version: '8.4'});
// Microsoft ships Java 11+
matrix.imply({java_distribution: 'microsoft'}, {java_version: v => v >= 11});
// Oracle ships Java 11+
matrix.imply({java_distribution: 'oracle'}, {java_version: v => v === eaJava || v >= 11});
// TODO: Semeru does not ship Java 21 builds yet
matrix.exclude({java_distribution: {value: 'semeru'}, java_version: '21'})
matrix.exclude({gss: {value: 'yes'}, os: ['windows-latest', 'macos-latest', 'self-hosted']})
if (process.env.GITHUB_REPOSITORY === 'pgjdbc/pgjdbc') {
// PG images below 9.3 are x86_64 only
matrix.exclude(row => row.os === 'self-hosted' && isLessThan(row.pg_version, '9.3'));
matrix.exclude({os: 'self-hosted', pg_version: lessThan('9.3')});
}

// The most rare features should be generated the first
Expand All @@ -214,15 +229,19 @@ if (process.env.GITHUB_REPOSITORY === 'pgjdbc/pgjdbc') {
// Ensure at least one job with "same" hashcode exists
matrix.generateRow({hash: {value: 'same'}});
matrix.generateRow({scram: {value: 'yes'}});
// Ensure there's a row for Java EA. It is at the beginning to increase chances of covering cases like ssl=yes below
matrix.generateRow({java_version: eaJava});
// Ensure we have a job with the minimal and maximal PostgreSQL versions
matrix.generateRow({pg_version: matrix.axisByName.pg_version.values[0]});
matrix.generateRow({pg_version: matrix.axisByName.pg_version.values.slice(-1)[0]});
//Ensure at least one job with "simple" query_mode exists
matrix.generateRow({query_mode: {value: 'simple'}});
// Ensure there will be at least one job with minimal supported Java
matrix.generateRow({java_version: matrix.axisByName.java_version.values[0]});
// Ensure there will be at least one job with the latest Java
matrix.generateRow({java_version: matrix.axisByName.java_version.values.slice(-1)[0]});
// Ensure there will be at least one job with Java 17
matrix.generateRow({java_version: "17"});
// Ensure there will be at least one job with the latest Java (excluding EA)
matrix.generateRow({java_version: matrix.axisByName.java_version.values.slice(-2)[0]});
matrix.generateRow({ssl: {value: 'yes'}});
// Ensure at least one Windows and at least one Linux job is present (macOS is almost the same as Linux)
// matrix.generateRow({os: 'windows-latest'});
Expand All @@ -236,7 +255,26 @@ if (include.length === 0) {
}
include.sort((a, b) => a.name.localeCompare(b.name, undefined, {numeric: true}));
include.forEach(v => {
let gradleArgs = [
`-Duser.country=${v.locale.country}`,
`-Duser.language=${v.locale.language}`,
];
v.extraGradleArgs = gradleArgs.join(' ');
});
include.forEach(v => {
// Arguments passed to all the JVMs via _JAVA_OPTIONS
let jvmArgs = [];
// Extra JVM arguments passed to test execution
let testJvmArgs = [];
jvmArgs.push(`-Duser.country=${v.locale.country}`);
jvmArgs.push(`-Duser.language=${v.locale.language}`);

v.java_distribution = v.java_distribution.value;
v.java_vendor = v.java_distribution.vendor;
if (v.java_distribution === 'oracle') {
v.oracle_java_website = v.java_version === eaJava ? 'jdk.java.net' : 'oracle.com';
}
v.non_ea_java_version = v.java_version === eaJava ? '' : v.java_version;
v.replication = v.replication.value;
v.slow_tests = v.slow_tests.value;
v.xa = v.xa.value;
Expand Down Expand Up @@ -271,7 +309,8 @@ include.forEach(v => {
// Gradle does not work in tr_TR locale, so pass locale to test only: https://github.com/gradle/gradle/issues/17361
jvmArgs.push(`-Duser.country=${v.locale.country}`);
jvmArgs.push(`-Duser.language=${v.locale.language}`);
if (v.jit === 'hotspot' && Math.random() > 0.5) {
let jit = v.java_distribution === 'semeru' ? 'open9j' : 'hotspot';
if (jit === 'hotspot' && Math.random() > 0.5) {
// The following options randomize instruction selection in JIT compiler
// so it might reveal missing synchronization in TestNG code
v.name += ', stress JIT';
Expand Down
31 changes: 25 additions & 6 deletions .github/workflows/matrix_builder.js
Expand Up @@ -18,7 +18,7 @@ class Axis {
}
if (Array.isArray(filter)) {
// e.g. row={os: 'windows'}; filter=[{os: 'linux'}, {os: 'linux'}]
return filter.find(v => Axis.matches(row, v));
return filter.some(v => Axis.matches(row, v));
}
if (typeof filter === 'object') {
// e.g. row={jdk: {name: 'openjdk', version: 8}}; filter={jdk: {version: 8}}
Expand Down Expand Up @@ -68,6 +68,7 @@ class MatrixBuilder {
this.duplicates = {};
this.excludes = [];
this.includes = [];
this.implications = [];
this.failOnUnsatisfiableFilters = false;
}

Expand All @@ -80,13 +81,23 @@ class MatrixBuilder {
}

/**
* Specifies exclude filter (e.g. exclude a forbidden combination)
* Specifies exclude filter (e.g. exclude a forbidden combination).
* @param filter
*/
exclude(filter) {
this.excludes.push(filter);
}

/**
* Adds implication like `antecedent -> consequent`.
* In other words, if `antecedent` holds, then `consequent` must also hold.
* @param antecedent
* @param consequent
*/
imply(antecedent, consequent) {
this.implications.push({antecedent: antecedent, consequent: consequent});
}

addAxis({name, title, values}) {
const axis = new Axis({name, title, values});
this.axes.push(axis);
Expand All @@ -104,8 +115,10 @@ class MatrixBuilder {
* @returns {boolean}
*/
matches(row) {
return (this.excludes.length === 0 || !this.excludes.find(f => Axis.matches(row, f))) &&
(this.includes.length === 0 || this.includes.find(f => Axis.matches(row, f)));
return (this.excludes.length === 0 || !this.excludes.some(f => Axis.matches(row, f))) &&
(this.includes.length === 0 || this.includes.some(f => Axis.matches(row, f))) &&
(this.implications.length === 0 || (
this.implications.every(i => !Axis.matches(row, i.antecedent) || Axis.matches(row, i.consequent))));
}

failOnUnsatisfiableFilters(value) {
Expand All @@ -125,7 +138,7 @@ class MatrixBuilder {
let res;
if (filter) {
// If matching row already exists, no need to generate more
res = this.rows.find(v => Axis.matches(v, filter));
res = this.rows.some(v => Axis.matches(v, filter));
if (res) {
return res;
}
Expand All @@ -152,7 +165,13 @@ class MatrixBuilder {
return title;
}
const computeTitle = this.axisByName[axisName].title;
return computeTitle ? computeTitle(value) : value;
if (computeTitle) {
return computeTitle(value);
}
if (typeof value === 'object' && value.hasOwnProperty('value')) {
return value.value;
}
return value;
}).filter(Boolean).join(", ");
this.rows.push(res);
return res;
Expand Down
21 changes: 18 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -76,10 +76,22 @@ Here are a few important things you should know about contributing code:

In order to build the source code for PgJDBC you will need the following tools:

- A git client
- A JDK for the JDBC version you'd like to build (JDK8 for JDBC 4.2)
- A Git client
- A JDK for the JDBC version you'd like to build (Java 17 for pgjdbc 42.7.1, Java 8 for older pgjdbc releases)
- A running PostgreSQL instance (optional for unit/integration tests)

We use [Gradle's Toolchains for JVM projects](https://docs.gradle.org/current/userguide/toolchains.html)
to separate JDK version used for building and running tests.
This means Gradle will automatically find the required JDK version or download it for you.

You could control JDK versions with the following Gradle properties:
* `jdkBuildVersion`. Defaults to 17. [JDK version](https://docs.gradle.org/8.4/userguide/toolchains.html#sec:consuming) to use for building $projectName. If the value is 0, then the current Java is used.
* `jdkBuildVendor`. [JDK vendor](https://docs.gradle.org/8.4/userguide/toolchains.html#sec:vendors) to use building
* `jdkBuildImplementation`. Vendor-specific [virtual machine implementation](https://docs.gradle.org/8.4/userguide/toolchains.html#selecting_toolchains_by_virtual_machine_implementation) to use building
* `jdkTestVersion`. Defaults to `jdkBuildVersion`. [JDK version](https://docs.gradle.org/8.4/userguide/toolchains.html#sec:consuming) to use for testing.
* `jdkTestVendor`. Defaults to `jdkBuildVendor`. [JDK vendor](https://docs.gradle.org/8.4/userguide/toolchains.html#sec:vendors) to use testing
* `jdkTestImplementation`. Defaults to `jdkBuildImplementation`. Vendor-specific [virtual machine implementation](https://docs.gradle.org/8.4/userguide/toolchains.html#selecting_toolchains_by_virtual_machine_implementation) to use testing

Additionally, in order to update translations (not typical), you will need the following additional tools:

- the gettext package, which contains the commands "msgfmt", "msgmerge", and "xgettext"
Expand Down Expand Up @@ -109,6 +121,9 @@ on a command line (the outputs are located in the relevant:
./gradlew test # execute tests
./gradlew test --tests org.postgresql.test.ssl.SslTest # execute test by class
./gradlew test -PincludeTestTags=!org.postgresql.test.SlowTests # skip slow tests
./gradlew test -PjdkTestVersion=21 --tests org.postgresql.test.ssl.SslTest # execute test with Java 21

./gradlew parameters # list most build parameters like jdkTestVersion above

Note: `clean` is not required, and the build automatically re-executes the tasks.
However, Gradle caches the results of `test` execution as well, so if you want to
Expand Down Expand Up @@ -218,7 +233,7 @@ is used for releasing artifacts.
## Releasing a new version

Prerequisites:
- Java 8
- Java 17
- a PostgreSQL instance for running tests; it must have a user named `test` as well as a database named `test`
- ensure that the RPM packaging CI isn't failing at
[copr web page](https://copr.fedorainfracloud.org/coprs/g/pgjdbc/pgjdbc-travis/builds/)
Expand Down