Skip to content

Commit

Permalink
Merge pull request #1831 from robstoll/chore/matrix_commons
Browse files Browse the repository at this point in the history
use tegonal's matrix_commons.js and simplify matrix.js
  • Loading branch information
robstoll authored Sep 5, 2024
2 parents 1fe1611 + f18b2c8 commit ed2d84d
Show file tree
Hide file tree
Showing 8 changed files with 232 additions and 44 deletions.
49 changes: 5 additions & 44 deletions .github/workflows/matrix.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,7 @@
let { MatrixBuilder } = require('./matrix_builder');
const matrix = new MatrixBuilder();

// Add axes for the matrix
matrix.addAxis({
name: 'os',
title: x => x.replace('-latest', ''),
values: [
'ubuntu-latest',
'windows-latest'
]
});
matrix.addAxis({
name: 'java_version',
values: ['11', '17']
});
matrix.addAxis({
name: 'java_distribution',
title: x => x,
values: [
'corretto',
'liberica',
'microsoft',
'temurin',
'zulu'
]
});

// Configure the order of the fields in job name
matrix.setNamePattern(['os', 'java_version', 'java_distribution']);
const {MatrixBuilder} = require('./matrix_builder');
const {configureKotlinDefaults, setMatrix} = require('./matrix_commons');

// 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: 'ubuntu-latest' });

// Generate more rows, no duplicates would be generated
const include = matrix.generateRows(process.env.MATRIX_JOBS || 5);
if (include.length === 0) {
throw new Error('Matrix list is empty');
}
// Sort jobs by name, however, numeric parts are sorted appropriately
// For instance, 'windows 8' would come before 'windows 11'
include.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }));
const matrix = new MatrixBuilder();
configureKotlinDefaults(matrix)

console.log(include);
console.log('::set-output name=matrix::' + JSON.stringify({ include }));
setMatrix(matrix, 4);
124 changes: 124 additions & 0 deletions .github/workflows/matrix_commons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
//
// __ __
// / /____ ___ ____ ___ ___ _/ / This file is provided to you by https://github.com/tegonal/github-commons
// / __/ -_) _ `/ _ \/ _ \/ _ `/ / Copyright 2022 Tegonal Genossenschaft <info@tegonal.com>
// \__/\__/\_, /\___/_//_/\_,_/_/ It is licensed under Apache License 2.0
// /___/ Please report bugs and contribute back your improvements
//
// Version: v2.7.1
//##################################
// adapted version of https://github.com/vlsi/github-actions-random-matrix/blob/main/examples/matrix.js
// licensed under Apache License 2.0
//##################################
const os = require("os");
const fs = require("fs");

const javaDistributionAxis = {
name: 'java_distribution',
values: [
'corretto',
'liberica',
'microsoft',
'semeru',
'temurin',
'zulu',
]
};

const javaVersionAxis = javaVersionAxisBuilder(['11', '17', '21']);

function javaVersionAxisBuilder(values){
return {
name: 'java_version',
title: x => 'Java ' + x,
values: values
}
}

const osAxis = {
name: 'os',
title: x => x.replace('-latest', ''),
values: [
'ubuntu-latest',
'windows-latest',
'macos-latest'
]
}

function generateJavaMinMaxRows(matrix) {
// generate one with oldest java and one with newest java version
matrix.generateRow({java_version: matrix.axisByName.java_version.values[0]});
matrix.generateRow({java_version: matrix.axisByName.java_version.values.slice(-1)[0]});
}

function generateUbuntuWindowsRows(matrix) {
matrix.generateRow({os: 'ubuntu-latest'});
matrix.generateRow({os: 'windows-latest'});
}

function configureJavaDefaults(matrix, distributionAxis = javaDistributionAxis, versionAxis = javaVersionAxis, operatingSystemAxis = osAxis ) {
matrix.addAxis(distributionAxis);
matrix.addAxis(versionAxis);
matrix.addAxis(operatingSystemAxis);

// This specifies the order of axes in CI job name (individual titles would be joined with a comma)
matrix.setNamePattern(['java_version', 'java_distribution', 'os']);

// arm64 architecture is not supported by IBM Semeru
matrix.exclude({java_distribution: 'semeru', os: 'macos-latest'});

generateJavaMinMaxRows(matrix);
generateUbuntuWindowsRows(matrix);
}

function configureKotlinDefaults(matrix) {
const kotlinJavaDistributionAxis = {
...javaDistributionAxis,
values: javaDistributionAxis.values.filter ( x =>
// seems to have problems with kotlin https://youtrack.jetbrains.com/issue/KT-61836
x != 'semeru'
)
};
configureJavaDefaults(matrix, kotlinJavaDistributionAxis);
}

function configureScalaDefaults(matrix) {
configureJavaDefaults(matrix);
}

// see https://github.com/actions/toolkit/issues/1218
function setOutput(key, value) {
// Temporary hack until core actions library catches up with github new recommendations
const output = process.env['GITHUB_OUTPUT']
if (output !== undefined){
fs.appendFileSync(output, `${key}=${value}${os.EOL}`)
} else {
console.log('::set-output name=' + key + '::' + value);
}
}

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

// Sort jobs by name, however, numeric parts are sorted appropriately
// For instance, 'windows 8' would come before 'windows 11'
include.sort((a, b) => a.name.localeCompare(b.name, undefined, {numeric: true}));

console.log(include);
setOutput('matrix', JSON.stringify({include}));
}

module.exports = {
javaDistributionAxis,
javaVersionAxis,
osAxis,
setMatrix,
generateJavaMinMaxRows,
generateUbuntuWindowsRows,
configureJavaDefaults,
configureKotlinDefaults,
configureScalaDefaults,
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ node_modules
.metals
.vscode
.kotlin
.gt/**/repo
.gt/**/gpg
8 changes: 8 additions & 0 deletions .gt/remotes/tegonal-gh-commons/gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "tegonal-gh-commons"]
url = https://github.com/tegonal/github-commons
fetch = +refs/heads/*:refs/remotes/tegonal-gh-commons/*
89 changes: 89 additions & 0 deletions .gt/remotes/tegonal-gh-commons/public-keys/signing-key.public.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----

mQINBGKzJKUBEACa43/pR6cU85quHQuaZs/rtSlq+2hnz0kmei/n3TlsQkeXgcKH
Fd/j6xEcMp2giIDcFFFhfhMhzzB5CtnSpLCTYcwW3bYiMn/oKBgqPobATch/2/VR
J7+M4ig8pClFX6eZcP8BiRT9hDaLuanWWFdj51i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: 1 addition & 0 deletions .gt/remotes/tegonal-gh-commons/pull.args
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--directory "lib/tegonal-gh-commons"
3 changes: 3 additions & 0 deletions .gt/remotes/tegonal-gh-commons/pulled.tsv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#@ Version: 1.0.0
tag file relativeTarget sha512
v2.7.1 src/.github/workflows/matrix_commons.js ../.github/workflows/matrix_commons.js 1f122bbabd9560b94aaa671bce4b12fc29745e20d951d8c2d34e65cf31ab25296896093a0416b2dabd01654c161389bd871d5579a3e9cbeb09e35a3f7a32a911

0 comments on commit ed2d84d

Please sign in to comment.