add output for "availble" php version

This commit is contained in:
Robin Appelman 2024-02-05 19:14:53 +01:00
commit abc1a0628d
5 changed files with 4826 additions and 4765 deletions

View file

@ -22,5 +22,6 @@ jobs:
- name: Get the result
run: |
echo -e "Versions :\n${{ steps.run.outputs.versions }}"
echo -e "Available PHP :\n${{ steps.run.outputs.php-available }}"
echo -e "Branches :\n${{ steps.run.outputs.branches }}"
echo -e "Matrix :\n${{ steps.run.outputs.matrix }}"

View file

@ -50,6 +50,10 @@ Maximum supported php version
Minimum supported php version
### `php-available`
Maximum supported php version that is available in the runner
### `php-max-list`
Maximum supported php version, as a single-item list
@ -58,6 +62,10 @@ Maximum supported php version, as a single-item list
Minimum supported php version, as a single-item list
### `php-available-list`
Maximum supported php version that is available in the runner, as a single-item list
### `branches-max`
Maximum supported server version

9558
dist/index.js vendored

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@
"main": "src/action.js",
"scripts": {
"build": "ncc build src/action.js -o dist",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "INPUT_FILENAME=.github/workflows/info.xml node src/action.js"
},
"keywords": [],
"author": "",

View file

@ -5,6 +5,8 @@ const fs = require('fs');
const urlExist = require('url-exist');
const {HttpClient} = require('@actions/http-client');
const equal = require('deep-equal');
const { promisify } = require('util');
const exec = promisify(require('child_process').exec)
const client = new HttpClient('nextcloud-version-matrix')
@ -47,6 +49,15 @@ async function getAllPhpVersions() {
return matches.map(match => match[1]);
}
async function distroSupportsPhpVersion(version) {
try {
const output = await exec(`apt-cache policy php${version}`);
return output.stdout.includes("Candidate")
} catch (_e) {
return false;
}
}
function onlyUnique(value, index, array) {
return array.findIndex(item => equal(value, item)) === index;
}
@ -142,6 +153,15 @@ function copy(obj) {
}
}
const distroPhp = [];
let availablePhp = phpMax;
for(let version of php) {
if (await distroSupportsPhpVersion(version)) {
distroPhp.push(version)
availablePhp = version;
}
}
// matrix with a single server version per php version
const phpMatrix = cartesianProduct({
"php-versions": php,
@ -175,11 +195,13 @@ function copy(obj) {
core.setOutput("php-min-list", JSON.stringify([php[0]]));
core.setOutput("php-max-list", JSON.stringify([php[php.length - 1]]));
core.setOutput("php-available-list", JSON.stringify([availablePhp]));
core.setOutput("branches-min-list", JSON.stringify([branches[0]]));
core.setOutput("branches-max-list", JSON.stringify([branches[branches.length - 1]]));
core.setOutput("php-min", php[0]);
core.setOutput("php-max", php[php.length - 1]);
core.setOutput("php-available", availablePhp);
core.setOutput("branches-min", branches[0]);
core.setOutput("branches-max", branches[branches.length - 1]);