Skip to content

Commit

Permalink
Added java_version to use in GH action Gradle build as -D param
Browse files Browse the repository at this point in the history
  • Loading branch information
jlink committed Nov 12, 2023
1 parent 4f192f4 commit 5864532
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions .github/workflows/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ matrix.addAxis({
'8',
'11',
'17',
'20',
'21 ',
]
});
Expand All @@ -67,16 +66,6 @@ matrix.addAxis({
]
});

// Test cases when Object#hashCode produces the same results
// It allows capturing cases when the code uses hashCode as a unique identifier
matrix.addAxis({
name: 'hash',
values: [
{value: 'regular', title: '', weight: 42},
{value: 'same', title: 'same hashcode', weight: 1}
]
});

matrix.addAxis({
name: 'locale',
title: x => x.language + '_' + x.country,
Expand All @@ -89,59 +78,51 @@ matrix.addAxis({
});

matrix.setNamePattern([
'java_version', 'java_distribution', 'hash', 'os',
'java_version', 'java_distribution', 'os',
'tz', 'locale',
]);

// Microsoft Java has no distribution for 8, 18, 19
// Microsoft Java has no distribution for 8, 18, 19, 20
matrix.exclude({java_distribution: 'microsoft', java_version: '8'});
matrix.exclude({java_distribution: 'microsoft', java_version: '18'});
matrix.exclude({java_distribution: 'microsoft', java_version: '19'});
matrix.exclude({java_distribution: 'microsoft', java_version: '20'});
// Oracle supports 17+ only
matrix.exclude({java_distribution: 'oracle', java_version: ['8', '11', '19']});
// TODO: remove when compileJava with "same hashcode" issues are resolved
// See https://bugs.openjdk.org/browse/JDK-8288590 is resolved
// See https://github.com/jqwik-team/jqwik/pull/460#issuecomment-1428261036
matrix.exclude({hash: {value: 'same'}});

// The most rare features should be generated the first
// For instance, we have a lot of PostgreSQL versions, so we generate the minimal the first
// It would have to generate other parameters, and it might happen it would cover "most recent Java" automatically
// Ensure at least one job with "same" hashcode exists
// TODO: un-comment once "same hashcode" issues are resolved
// matrix.generateRow({hash: {value: 'same'}});

// 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 at least one Windows and at least one Linux job is present (macOS is almost the same as Linux)
// matrix.generateRow({os: 'windows-latest'});
matrix.generateRow({os: 'windows-latest'});
matrix.generateRow({os: 'ubuntu-latest'});

const include = matrix.generateRows(process.env.MATRIX_JOBS || 5);
if (include.length === 0) {
throw new Error('Matrix list is empty');
}

include.sort((a, b) => a.name.localeCompare(b.name, undefined, {numeric: true}));
include.forEach(v => {
// Pass locale via Gradle arguments in case it won't be inherited from _JAVA_OPTIONS
// In fact, _JAVA_OPTIONS is non-standard and might be ignored by some JVMs
let gradleArgs = [
`-Duser.country=${v.locale.country}`,
`-Duser.language=${v.locale.language}`,
`-DjavaVersion=${v.java_version}`,
];
v.extraGradleArgs = gradleArgs.join(' ');
});
include.forEach(v => {
let jvmArgs = [];

if (v.hash.value === 'same') {
jvmArgs.push('-XX:+UnlockExperimentalVMOptions', '-XX:hashCode=2');
}
// Pass locale via _JAVA_OPTIONS so all the forked processes inherit it
jvmArgs.push(`-Duser.country=${v.locale.country}`);
jvmArgs.push(`-Duser.language=${v.locale.language}`);
//jvmArgs.push(`-DjavaVersion=${v.java_version}`); // Is that necessary?
if (v.jit === 'hotspot' && Math.random() > 0.5) {
// The following options randomize instruction selection in JIT compiler
// so it might reveal missing synchronization in TestNG code
Expand Down

0 comments on commit 5864532

Please sign in to comment.