Development¶
Versioning¶
version.php follows the suite standard:
$plugin->versionformatYYYY_MM_DD_XXX, whereYYYY_MM_DDreflects the change date andXXXis a 3-digit counter.$plugin->releaseformat4.5.XXX, sharing the sameXXXcounter.Database upgrade changes in
db/upgrade.phprequire incrementingversion/release.
CI/CD¶
.github/workflows/ci.yml— Moodle Plugin CIRuns on push and pull requests to
main. Executes PHP Lint, PHPCS, PHPDoc, unit tests (PHPUnit), and Behat tests..github/workflows/release.yml— ReleaseTriggered by git tags matching release versions. Builds installable ZIP assets and publishes GitHub Releases.
.github/workflows/docs.yml— Build & Deploy DocumentationCompiles Sphinx documentation for both Portuguese (pt-BR) and English (en) and deploys them to GitHub Pages.
Documentation¶
Documentation uses Sphinx with moodle-docs-theme and .rst files located under docs/pt-br/ and docs/en/.
To build the English documentation locally:
pip install sphinx moodle-docs-theme
sphinx-build -W -b html docs/en docs/_build/html/en
To build the Portuguese documentation locally:
sphinx-build -W -b html docs/pt-br docs/_build/html/pt-br
The docs.yml workflow executes these commands in CI and deploys the output via actions/deploy-pages.
Commit Conventions¶
Supported commit message prefixes:
Prefix |
Usage |
|---|---|
|
New features. |
|
Bug fixes. |
|
Refactoring or performance improvements. |
|
Code style or formatting. |
|
Tests. |
|
Documentation updates. |
|
CI/CD or configuration changes. |
|
Dependencies or build tools. |
How to contribute: pre-commit (pre-push) with act¶
The pre-commit hook (.pre-commit-config.yaml, pre-push stage) runs the same CI workflow used on GitHub
(.github/workflows/ci.yml, job ci) locally through act, inside Docker. You therefore
do not need PHP (or Moodle) installed: only Python, pre-commit, Docker and act.
Requirements:
Python 3 and pre-commit;
Docker running;
act (on Windows:
winget install nektos.act).
One-time setup:
pip install pre-commit
pre-commit install --hook-type pre-push
On its first run act asks which Docker image to use and fails in non-interactive terminals. To avoid that, create
the act config file (Linux/macOS: ~/.config/act/actrc; Windows: %LOCALAPPDATA%ctctrc) with the
equivalent of the “Medium” image:
-P ubuntu-latest=catthehacker/ubuntu:act-latest
On every git push the hook runs (it does not run on git commit, since it is slow):
act -j ci --matrix php:8.3 --matrix database:pgsql --matrix moodle-branch:MOODLE_405_STABLE --reuse
To run the hook manually, without pushing: pre-commit run --all-files --hook-stage pre-push.
Note
The full CI on GitHub uses a larger matrix (Moodle 4.4 and 4.5, pgsql and mariadb); the hook validates a
single combination to keep the run time reasonable. The first run downloads Docker images and installs Moodle, so it
takes much longer. Steps marked as non-blocking in the workflow (e.g. Moodle Code Checker) do not fail the push.