Skip to content

Commit

Permalink
CI: Update for Moodle 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Apr 4, 2024
1 parent 0dd07f0 commit 44e573b
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 152 deletions.
94 changes: 30 additions & 64 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Moodle Plugin CI

on: [ push, pull_request ]
on: [push, pull_request]

jobs:
static:
runs-on: ubuntu-latest

strategy:
matrix:
php: [ '8.1' ]
moodle-branch: [ 'MOODLE_402_STABLE' ]
database: [ 'pgsql' ]
php: ['8.2']
moodle-branch: ['main']
database: ['pgsql']

steps:
- name: Start PostgreSQL
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14

- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -28,29 +28,9 @@ jobs:
ini-values: max_input_vars=5000
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Composer cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: npm cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
Expand Down Expand Up @@ -83,7 +63,6 @@ jobs:
- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc
continue-on-error: true

- name: Validating
if: ${{ always() }}
Expand All @@ -109,28 +88,21 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '8.0', '8.1' ]
moodle-branch: [ 'MOODLE_401_STABLE', 'MOODLE_402_STABLE' ]
database: [ 'mariadb', 'pgsql' ]
php: ['8.0', '8.1', '8.2']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'main']
database: ['mariadb', 'pgsql']
exclude:
- php: '8.0'
moodle-branch: 'main'
- php: '8.2'
moodle-branch: 'MOODLE_401_STABLE'
include:
- php: '7.4'
moodle-branch: 'MOODLE_39_STABLE'
database: 'mariadb'
- php: '7.4'
moodle-branch: 'MOODLE_39_STABLE'
moodle-branch: 'MOODLE_401_STABLE'
database: 'pgsql'
- php: '8.0'
moodle-branch: 'MOODLE_311_STABLE'
database: 'mariadb'
- php: '8.0'
moodle-branch: 'MOODLE_311_STABLE'
database: 'pgsql'
- php: '8.0'
moodle-branch: 'MOODLE_400_STABLE'
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'mariadb'
- php: '8.0'
moodle-branch: 'MOODLE_400_STABLE'
database: 'pgsql'

steps:
- name: Start MariaDB
Expand All @@ -142,7 +114,7 @@ jobs:
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14

- name: Check out repository code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: plugin

Expand All @@ -153,24 +125,6 @@ jobs:
ini-values: max_input_vars=5000
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Composer cache
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: npm cache
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
Expand All @@ -194,3 +148,15 @@ jobs:
- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome --auto-rerun 0

# This step allows to upload Behat faildump (screenshots) as workflow artifact,
# so it can be downloaded and inspected. You don't need this step if you
# are not running Behat test. Artifact will be retained for 7 days.
- name: Upload Behat Faildump
if: ${{ failure() && steps.behat.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: Behat Faildump (${{ join(matrix.*, ', ') }})
path: ${{ github.workspace }}/moodledata/behat_dump
retention-days: 7
if-no-files-found: ignore
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class provider implements null_provider {
*
* @return string the reason
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
4 changes: 2 additions & 2 deletions lang/en/lifecycletrigger_byrole.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* @copyright 2017 Tobias Reischmann WWU Nina Herrmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['pluginname'] = 'Delete courses by roles missing';
$string['delay'] = 'Days of delay for triggering';
$string['delay_help'] = 'Days a course has to remain without any responsible person until the course is finally triggered';
$string['pluginname'] = 'Delete courses by roles missing';
$string['privacy:metadata'] = 'Does not store user specific data';
$string['responsibleroles'] = 'Responsible Roles in courses';
$string['responsibleroles_help'] = 'Select the roles that have to be presented within a course. If one of the roles is present the course is not triggered.';
$string['privacy:metadata'] = 'Does not store user specific data';
16 changes: 8 additions & 8 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function get_course_recordset_where($triggerid) {

$sql = "{course}.id in (SELECT DISTINCT courseid
FROM {lifecycletrigger_byrole} WHERE triggerid = $triggerid AND timecreated < $maxtime)";
return array($sql, array());
return [$sql, []];
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ private function get_roles($triggerid) {
private function update_courses($triggerid) {
global $DB;
$coursesintable = $DB->get_records('lifecycletrigger_byrole',
array('triggerid' => $triggerid), '', 'courseid');
['triggerid' => $triggerid], '', 'courseid');

$coursesintable = array_map(function($elem) {
return $elem->courseid;
Expand Down Expand Up @@ -120,7 +120,7 @@ private function update_courses($triggerid) {

$insertcourses = array_diff($courseswithoutteacher, $coursesintable);

$records = array();
$records = [];
foreach ($insertcourses as $courseid) {
$dataobject = new \stdClass();
$dataobject->courseid = $courseid;
Expand Down Expand Up @@ -157,10 +157,10 @@ public function get_subpluginname() {
* @return array|instance_setting[]
*/
public function instance_settings() {
return array(
return [
new instance_setting('roles', PARAM_SEQUENCE),
new instance_setting('delay', PARAM_INT),
);
];
}

/**
Expand All @@ -174,13 +174,13 @@ public function extend_add_instance_form_definition($mform) {
global $DB;
$allroles = $DB->get_records('role', null, 'sortorder DESC');

$rolenames = array();
$rolenames = [];
foreach ($allroles as $role) {
$rolenames[$role->id] = empty($role->name) ? $role->shortname : $role->name;
}
$options = array(
$options = [
'multiple' => true,
);
];
$mform->addElement('autocomplete', 'roles',
get_string('responsibleroles', 'lifecycletrigger_byrole'),
$rolenames, $options);
Expand Down
17 changes: 9 additions & 8 deletions tests/generator/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @copyright 2017 Tobias Reischmann WWU Nina Herrmann WWU
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package lifecycletrigger_byrole
*/

use tool_lifecycle\local\entity\trigger_subplugin;
Expand Down Expand Up @@ -69,10 +70,10 @@ public function create_trigger_with_workflow() {
/**
* Creates data to test the trigger subplugin lifecycletrigger_byrole.
*/
public function test_create_preparation () {
public function test_create_preparation() {
global $DB;
$generator = advanced_testcase::getDataGenerator();
$data = array();
$data = [];

$data['trigger'] = $this->create_trigger_with_workflow();

Expand All @@ -82,25 +83,25 @@ public function test_create_preparation () {
$user3 = $generator->create_user();

// Creates a course with one student one teacher.
$teachercourse = $generator->create_course(array('name' => 'teachercourse'));
$teachercourse = $generator->create_course(['name' => 'teachercourse']);
$generator->enrol_user($user1->id, $teachercourse->id, 3);
$generator->enrol_user($user2->id, $teachercourse->id, 5);
$data['teachercourse'] = $teachercourse;

// Creates a course with one student one manager.
$managercourse = $generator->create_course(array('name' => 'managercourse'));
$managercourse = $generator->create_course(['name' => 'managercourse']);
$manager = $generator->create_user();
$data['manager'] = $manager;
$generator->enrol_user($user1->id, $managercourse->id, 1);
$generator->enrol_user($user2->id, $managercourse->id, 5);
$data['managercourse'] = $managercourse;

// Create a course without any role.
$norolecourse = $generator->create_course(array('name' => 'norolecourse'));
$norolecourse = $generator->create_course(['name' => 'norolecourse']);
$data['norolecourse'] = $norolecourse;

// Create a course already marked for deletion with one student and old.
$norolefoundcourse = $generator->create_course(array('name' => 'norolefoundcourse'));
$norolefoundcourse = $generator->create_course(['name' => 'norolefoundcourse']);
$generator->enrol_user($user3->id, $norolefoundcourse->id, 5);
$dataobject = new \stdClass();
$dataobject->courseid = $norolefoundcourse->id;
Expand All @@ -110,7 +111,7 @@ public function test_create_preparation () {
$data['norolefoundcourse'] = $norolefoundcourse;

// Create a course already marked for deletion with one student and really old.
$norolefoundcourse2 = $generator->create_course(array('name' => 'norolefoundcourse2'));
$norolefoundcourse2 = $generator->create_course(['name' => 'norolefoundcourse2']);
$generator->enrol_user($user3->id, $norolefoundcourse2->id, 5);
$dataobject = new \stdClass();
$dataobject->courseid = $norolefoundcourse2->id;
Expand All @@ -120,7 +121,7 @@ public function test_create_preparation () {
$data['norolefoundcourse2'] = $norolefoundcourse2;

// Create a course already marked for deletion with one student and one teacher and old.
$rolefoundagain = $generator->create_course(array('name' => 'rolefoundagain'));
$rolefoundagain = $generator->create_course(['name' => 'rolefoundagain']);
$generator->enrol_user($user3->id, $rolefoundagain->id, 3);
$generator->enrol_user($user2->id, $rolefoundagain->id, 5);
$dataobject = new \stdClass();
Expand Down
Loading

0 comments on commit 44e573b

Please sign in to comment.