Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTED-2794 #2

Open
wants to merge 3 commits into
base: moodlev4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: moodle-plugin-ci

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-18.04

services:
postgres:
image: postgres:9.6
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3

strategy:
fail-fast: false
matrix:
include:
- php: '7.3'
moodle-branch: 'MOODLE_39_STABLE'
- php: '7.3'
moodle-branch: 'MOODLE_310_STABLE'
- php: '7.4'
moodle-branch: 'MOODLE_311_STABLE'

steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
path: plugin

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV

- name: Install moodle-plugin-ci
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: pgsql
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

- name: Grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit --coverage-text

- name: Behat tests
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@ env:

matrix:
include:
- php: 7.1
env: MOODLE_BRANCH=MOODLE_35_STABLE

- php: 7.2
env: MOODLE_BRANCH=MOODLE_38_STABLE

- php: 7.3
env: MOODLE_BRANCH=MOODLE_39_STABLE

- php: 7.3
env: MOODLE_BRANCH=MOODLE_310_STABLE
- php: 7.4
env: MOODLE_BRANCH=MOODLE_311_STABLE

before_install:
- phpenv config-rm xdebug.ini
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cohort role synchronization [![Build Status](https://travis-ci.com/paulholden/moodle-local_cohortrole.svg?branch=master)](https://travis-ci.com/paulholden/moodle-local_cohortrole)
# Cohort role synchronization [![Build Status](https://github.com/paulholden/moodle-local_cohortrole/workflows/moodle-plugin-ci/badge.svg)](https://github.com/paulholden/moodle-local_cohortrole/actions)

## Requirements

Expand Down
8 changes: 7 additions & 1 deletion locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ function local_cohortrole_role_assign($cohortid, $roleid, array $userids) {
$context = context_system::instance();

foreach ($userids as $userid) {
role_assign($roleid, $userid, $context->id, LOCAL_COHORTROLE_ROLE_COMPONENT, $cohortid);
try {
$user = core_user::get_user($userid, '*', MUST_EXIST);
core_user::require_active_user($user);
role_assign($roleid, $user->id, $context->id, LOCAL_COHORTROLE_ROLE_COMPONENT, $cohortid);
} catch (Exception $e) {
// Exception is caught. Do nothing.
}
}
}

Expand Down
14 changes: 7 additions & 7 deletions tests/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
return new class extends phpunit_coverage_info {
/** @var array The list of folders relative to the plugin root to whitelist in coverage generation. */
protected $whitelistfolders = [
/** @var array The list of folders relative to the plugin root to include in coverage generation. */
protected $includelistfolders = [
'classes',
];

/** @var array The list of files relative to the plugin root to whitelist in coverage generation. */
protected $whitelistfiles = [
/** @var array The list of files relative to the plugin root to include in coverage generation. */
protected $includelistfiles = [
'locallib.php',
];

/** @var array The list of folders relative to the plugin root to excludelist in coverage generation. */
/** @var array The list of folders relative to the plugin root to exclude in coverage generation. */
protected $excludelistfolders = [];

/** @var array The list of files relative to the plugin root to excludelist in coverage generation. */
/** @var array The list of files relative to the plugin root to exclude in coverage generation. */
protected $excludelistfiles = [];
};
};
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'local_cohortrole';
$plugin->release = '3.3';
$plugin->version = 2020110900;
$plugin->release = '3.4';
$plugin->version = 2021060800;
$plugin->requires = 2018051703; // Moodle 3.5.3 onwards.
$plugin->maturity = MATURITY_STABLE;