add option to add extra php versions for testing

This commit is contained in:
Robin Appelman 2024-10-03 14:31:56 +02:00
commit 3b6f20f8d2
3 changed files with 4814 additions and 4768 deletions

View file

@ -9,6 +9,10 @@ inputs:
description: 'Other fields to include in the output matrix, json encoded' description: 'Other fields to include in the output matrix, json encoded'
required: false required: false
default: '{}' default: '{}'
with_php:
description: 'Extra php versions to use, either a single string or json array. These will be included in the matrix with the "master" server branch'
required: false
default: '[]'
outputs: outputs:
matrix: matrix:
description: 'Test matrix covering all server versions' description: 'Test matrix covering all server versions'

9553
dist/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -107,6 +107,14 @@ function copy(obj) {
try { try {
const filename = core.getInput('filename') || 'appinfo/info.xml'; const filename = core.getInput('filename') || 'appinfo/info.xml';
const matrixInput = JSON.parse(core.getInput('matrix') || '{}'); const matrixInput = JSON.parse(core.getInput('matrix') || '{}');
const withPhpInput = core.getInput('with_php') || '[]';
console.log(withPhpInput);
let withPhp = [];
if (withPhpInput.startsWith('[') && withPhpInput.endsWith(']')) {
withPhp = JSON.parse(withPhpInput);
} else {
withPhp = [withPhpInput];
}
const content = fs.readFileSync(filename, 'utf8'); const content = fs.readFileSync(filename, 'utf8');
const document = new DOMParser().parseFromString(content); const document = new DOMParser().parseFromString(content);
@ -137,6 +145,12 @@ function copy(obj) {
const phpMax = versionData.find(data => data.branch === row["server-versions"]).phpMax; const phpMax = versionData.find(data => data.branch === row["server-versions"]).phpMax;
row["php-versions"] = phpMax.toFixed(1); row["php-versions"] = phpMax.toFixed(1);
}); });
for (let extraPhpVersion of withPhp) {
serverMatrix.push({
"php-versions": extraPhpVersion,
"server-versions": "master",
});
}
core.setOutput("versions", JSON.stringify(versions)); core.setOutput("versions", JSON.stringify(versions));
@ -145,7 +159,7 @@ function copy(obj) {
const phpMin = Math.min(...versionData.map(data => data.phpMin)); const phpMin = Math.min(...versionData.map(data => data.phpMin));
const phpMax = Math.max(...versionData.map(data => data.phpMax)); const phpMax = Math.max(...versionData.map(data => data.phpMax));
const php = []; const php = withPhp.concat([]); // clone, not alias
for(let version = phpMin; version <= phpMax; version += 0.1) { for(let version = phpMin; version <= phpMax; version += 0.1) {
// floats are a pain // floats are a pain
version = parseFloat(version.toFixed(1)); version = parseFloat(version.toFixed(1));
@ -156,6 +170,7 @@ function copy(obj) {
version = Math.ceil(version) - 0.1; version = Math.ceil(version) - 0.1;
} }
} }
php.sort();
const distroPhp = []; const distroPhp = [];
let availablePhp = phpMax; let availablePhp = phpMax;
@ -174,7 +189,7 @@ function copy(obj) {
phpMatrix.forEach(row => { phpMatrix.forEach(row => {
const php = row['php-versions']; const php = row['php-versions'];
const candidateVersion = versionData.findLast(data => data.phpMin <= php && data.phpMax >= php); const candidateVersion = versionData.findLast(data => data.phpMin <= php && data.phpMax >= php);
row["server-versions"] = candidateVersion.branch; row["server-versions"] = candidateVersion?.branch ?? "master";
}); });
// matrix with every php and server combination // matrix with every php and server combination
@ -187,6 +202,12 @@ function copy(obj) {
const version = versionData.find(version => version.branch === row['server-versions']); const version = versionData.find(version => version.branch === row['server-versions']);
return version.phpMin <= php && version.phpMax >= php; return version.phpMin <= php && version.phpMax >= php;
}); });
for (let extraPhpVersion of withPhp) {
fullMatrix.push({
"php-versions": extraPhpVersion,
"server-versions": "master",
});
}
// matrix with at least one item for every server and php version // matrix with at least one item for every server and php version
let testMatrix = phpMatrix.concat(serverMatrix).filter(onlyUnique); let testMatrix = phpMatrix.concat(serverMatrix).filter(onlyUnique);