This GitHub Action facilitates the execution of comprehensive code quality checks and tests for Moodle plugins. It is designed to be reusable and is based on the official Moodle Plugin CI workflow , enabling seamless integration into other Moodle plugin repositories.
Executes a comprehensive suite of checks:
- PHP Linting
- PHP Mess Detector
- Moodle Code Checker
- PHPDoc Validation
- Plugin Validation
- PHPUnit Tests
- Behat Tests
Important
This Action does not start database services. If your tests require a database (PostgreSQL or MariaDB), you must define the services in your workflow.
Param | Description | Required | Default |
---|---|---|---|
php-version | Version of PHP to use | false |
8.3 |
moodle-branch | Moodle branch to test against | false |
MOODLE_500_STABLE |
database | Database to use: pgsql or mariadb | false |
null |
plugin-path | Path to the Moodle plugin to test | false |
./ |
This assumes that the plugin code is located in the root directory. For this, the action checkout@v4 is used to clone the current repository.
name: Test Moodle plugin (no database)
jobs:
test:
runs-on: ubuntu-22.04
steps:
- name: Checkout action code
uses: actions/checkout@v4
- name: Moodle CI PHP 8.3 Moodle 5.0
uses: gfrancv/moodle-plugin-ci-action@v1.1.0
with:
php-version: 8.3
moodle-branch: MOODLE_500_STABLE
Note: It is important to checkout your plugin repository before running the action. The action needs access to the plugin files, so make sure to use actions/checkout@v4 (or a similar checkout step) to clone your repository into the workflow workspace.
This assumes that the plugin code is located in the root directory.
name: Test Moodle plugin (with database)
jobs:
test:
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- 5432:5432
# Or
mariadb:
image: mariadb:10.11
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
ports:
- 3306:3306
steps:
- name: Checkout action code
uses: actions/checkout@v4
- name: Moodle CI PHP 8.3 Moodle 5.0 DB mariadb
uses: gfrancv/moodle-plugin-ci-action@v1.1.0
with:
php-version: 8.3
moodle-branch: MOODLE_500_STABLE
database: mariadb
name: Test Moodle plugin (matrix)
jobs:
test:
runs-on: ubuntu-22.04
services:
mariadb:
image: mariadb:10.11
env:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
ports:
- 3306:3306
strategy:
matrix:
include:
- php: '8.2'
moodle: 'MOODLE_500_STABLE'
db: mariadb
- php: '8.3'
moodle: 'MOODLE_500_STABLE'
db: mariadb
steps:
- name: Checkout action code
uses: actions/checkout@v4
- name: Moodle CI PHP ${{ matrix.php }} Moodle ${{ matrix.moodle }} DB ${{ matrix.db }}
uses: gfrancv/moodle-plugin-ci-action@v1.1.0
with:
php-version: ${{ matrix.php }}
moodle-branch: ${{ matrix.moodle }}
database: ${{ matrix.db }}
Ensure that your plugin repository includes a version.php
file with the appropriate $plugin->supported
range to align with the Moodle versions being tested.
This action is intended to be used within a GitHub Actions workflow in your plugin repository.
It is important to checkout your plugin repository before running the action. The action needs access to the plugin files, so make sure to use actions/checkout@v4 (or a similar checkout step) to clone your repository into the workflow workspace.
The scripts and documentation in this project are released under the MIT License