Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the CI matrix generation to stop querying the external Moodle updates API and instead derive Moodle branch/version breakpoints from a local moodle_branches.json, improving offline capability and reducing external dependency risk.
Changes:
- Added
moodle_branches.jsonas the local source of Moodle branch/version metadata. - Updated
.github/actions/parse-version/script.phpto read branch/version data from the local JSON instead ofdownload.moodle.org.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
moodle_branches.json |
Introduces a local list of Moodle branches and their version breakpoints used for matrix selection. |
.github/actions/parse-version/script.php |
Switches matrix filtering logic to consume the local branch/version list rather than the external Moodle API. |
Comments suppressed due to low confidence (1)
.github/actions/parse-version/script.php:120
$upperfrom$plugin->supportedis compared against$apiVersion['branch'](e.g., 500 vs "5.0"), so$existswill never be true andmainwill be included even when the upper bound corresponds to an existing stable branch. Normalize both values (e.g., compare$uppertostr_replace('.', '', $apiVersion['branch'])), or revert to checking the matrix entries as before.
if ($entry['moodle-branch'] === 'main') {
// If the upper range does NOT exist in the matrix, then assume the user wants the main to be tested.
$exists = false;
foreach ($updates as $apiVersion) {
if ($apiVersion['branch'] == $upper) {
$exists = true;
break;
}
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $branchesJson = file_get_contents("$workspace/ci/moodle_branches.json"); | ||
| $updates = json_decode($branchesJson, true)['core'] ?? []; |
There was a problem hiding this comment.
Reading and decoding moodle_branches.json has no failure handling: file_get_contents can return false and json_decode can return null, which will lead to warnings and an empty $updates set (silently altering the matrix). Consider failing fast with a clear message if the file is missing/unreadable or the JSON is invalid (e.g., JSON_THROW_ON_ERROR + try/catch).
| $branchesJson = file_get_contents("$workspace/ci/moodle_branches.json"); | |
| $updates = json_decode($branchesJson, true)['core'] ?? []; | |
| $branchesFilePath = "$workspace/ci/moodle_branches.json"; | |
| $branchesJson = file_get_contents($branchesFilePath); | |
| if ($branchesJson === false) { | |
| fwrite(STDERR, "Failed to read moodle branches file at {$branchesFilePath}" . PHP_EOL); | |
| exit(1); | |
| } | |
| try { | |
| $branchesData = json_decode($branchesJson, true, 512, JSON_THROW_ON_ERROR); | |
| } catch (\JsonException $e) { | |
| fwrite(STDERR, "Invalid JSON in moodle branches file at {$branchesFilePath}: " . $e->getMessage() . PHP_EOL); | |
| exit(1); | |
| } | |
| $updates = $branchesData['core'] ?? []; |
There was a problem hiding this comment.
The file clearly exists...
| { "branch": "3.8", "version": 2020082800 }, | ||
| { "branch": "3.9", "version": 2020120700 }, | ||
| { "branch": "3.10", "version": 2021041200 }, | ||
| { "branch": "3.11", "version": 2022080100 }, | ||
| { "branch": "4.0", "version": 2022080100 }, | ||
| { "branch": "4.1", "version": 2022112800 }, | ||
| { "branch": "4.2", "version": 2023042400 }, | ||
| { "branch": "4.3", "version": 2023100900 }, | ||
| { "branch": "4.4", "version": 2024042200 }, | ||
| { "branch": "4.5", "version": 2024100700 }, | ||
| { "branch": "5.0", "version": 2025041400 }, | ||
| { "branch": "5.1", "version": 2025100600 }, | ||
| { "branch": "5.2", "version": 2026040200 }, | ||
| { "branch": "main", "version": 9999999999 } |
There was a problem hiding this comment.
I had removed support from EOL versions from the main matrix file.
It may be worth adding this to the matrix, instead? we could ues the full matrix to do this mapping instead? as that needs to be updated regurally instead
This PR removes the dependency on the external Moodle API (download.moodle.org/api/1.3/updates.php) in the plugin CI workflow. Instead, all Moodle branch information is now sourced from a local JSON file (moodle_branches.json). This makes the workflow fully offline-capable and more stable.
You need to update
moodle_branches.jsonwhenever new stable Moodle releases are officially available and you want your CI to test them.