Skip to content

Commit dd2f970

Browse files
committed
add workflow from moodle-plugin-ci
1 parent 082bc5b commit dd2f970

File tree

155 files changed

+18767
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+18767
-57
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
name: Moodle Plugin CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-22.04
9+
10+
services:
11+
postgres:
12+
image: postgres:14
13+
env:
14+
POSTGRES_USER: 'postgres'
15+
POSTGRES_HOST_AUTH_METHOD: 'trust'
16+
ports:
17+
- 5432:5432
18+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
19+
20+
mariadb:
21+
image: mariadb:10
22+
env:
23+
MYSQL_USER: 'root'
24+
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
25+
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
26+
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"
27+
ports:
28+
- 3306:3306
29+
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
30+
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
php: ['7.4', '8.0', '8.1']
35+
moodle-branch: ['MOODLE_401_STABLE']
36+
database: [pgsql, mariadb]
37+
38+
steps:
39+
- name: Check out repository code
40+
uses: actions/checkout@v4
41+
with:
42+
path: plugin
43+
44+
- name: Setup PHP ${{ matrix.php }}
45+
uses: shivammathur/setup-php@v2
46+
with:
47+
php-version: ${{ matrix.php }}
48+
extensions: ${{ matrix.extensions }}
49+
ini-values: max_input_vars=5000
50+
# If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
51+
# If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
52+
coverage: none
53+
54+
- name: Initialise moodle-plugin-ci
55+
run: |
56+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
57+
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
58+
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
59+
sudo locale-gen en_AU.UTF-8
60+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
61+
62+
- name: Install moodle-plugin-ci
63+
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
64+
env:
65+
DB: ${{ matrix.database }}
66+
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
67+
# Uncomment this to run Behat tests using the Moodle App.
68+
# MOODLE_APP: 'true'
69+
70+
- name: PHP Lint
71+
if: ${{ !cancelled() }}
72+
run: moodle-plugin-ci phplint ./plugin
73+
74+
- name: PHP Mess Detector
75+
continue-on-error: true # This step will show errors but will not fail
76+
if: ${{ !cancelled() }}
77+
run: moodle-plugin-ci phpmd ./plugin
78+
79+
- name: Moodle Code Checker
80+
if: ${{ !cancelled() }}
81+
run: moodle-plugin-ci phpcs --max-warnings 0 ./plugin
82+
83+
- name: Moodle PHPDoc Checker
84+
if: ${{ !cancelled() }}
85+
run: moodle-plugin-ci phpdoc --max-warnings 0 ./plugin
86+
87+
- name: Validating
88+
if: ${{ !cancelled() }}
89+
run: moodle-plugin-ci validate ./plugin
90+
91+
- name: Check upgrade savepoints
92+
if: ${{ !cancelled() }}
93+
run: moodle-plugin-ci savepoints ./plugin
94+
95+
- name: Mustache Lint
96+
if: ${{ !cancelled() }}
97+
run: moodle-plugin-ci mustache ./plugin
98+
99+
# no javascript used in this pluing
100+
# - name: Grunt
101+
# if: ${{ !cancelled() }}
102+
# run: moodle-plugin-ci grunt --max-lint-warnings 0 ./plugin
103+
104+
- name: PHPUnit tests
105+
if: ${{ !cancelled() }}
106+
run: moodle-plugin-ci phpunit --fail-on-warning ./plugin
107+
108+
- name: Behat features
109+
id: behat
110+
if: ${{ !cancelled() }}
111+
run: moodle-plugin-ci behat --profile chrome ./plugin
112+
113+
- name: Upload Behat Faildump
114+
if: ${{ failure() && steps.behat.outcome == 'failure' }}
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: Behat Faildump (${{ join(matrix.*, ', ') }})
118+
path: ${{ github.workspace }}/moodledata/behat_dump
119+
retention-days: 7
120+
if-no-files-found: ignore
121+
122+
- name: Mark cancelled jobs as failed.
123+
if: ${{ cancelled() }}
124+
run: exit 1

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
/vendor/
21
.well-known/

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ default:
3636
- export PATH="/opt/moodle-plugin-ci/bin:/opt/moodle-plugin-ci/vendor/bin:$PATH"
3737
# TODO not always needed
3838
# install moodle
39-
# - moodle-plugin-ci install --db-host db
39+
# - moodle-plugin-ci install --db-host db
4040
# - '{ php -S 0.0.0.0:8000 -t "$CI_PROJECT_DIR/moodle" >/dev/null 2>&1 & }'
4141

4242
# install dependencies:

classes/claim/address.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@
2929
*/
3030
class address implements claim {
3131

32-
3332
/**
3433
* Get addres claim.
35-
* @param array of core_user user user want the address claim from
34+
* @param array $user core_user user user want the address claim from
3635
* @return array() Returns address information of user
3736
*/
3837
public function claim($user): array {

classes/claim/claim.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface claim {
3333

3434
/**
3535
* Get addres claim.
36-
* @param array of core_user user user want the address claim from
36+
* @param array $user core_user user user want the address claim from
3737
* @return array() Returns address information of user
3838
*/
3939
public function claim(array $user);

classes/claim/email.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class email implements claim {
3131

3232
/**
3333
* Get email claim.
34-
* @param array of core_user user user want the email claim from
34+
* @param array $user core_user user user want the email claim from
3535
* @return array() Returns email information of user
3636
*/
3737
public function claim($user) {

classes/claim/enrolments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class enrolments implements claim {
3131
// TODO maybe also return role, and external id.
3232
/**
3333
* Get addres claim.
34-
* @param array of core_user user user want the address claim from
34+
* @param array $user core_user want the address claim from
3535
* @return array() Returns address information of user enrolments which array of course short names
3636
*/
3737
public function claim($user) {

classes/claim/phone.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class phone implements claim {
3131

3232
/**
3333
* Get phone claim.
34-
* @param array of core_user user user want the address claim from
34+
* @param array $user core_user want the address claim from
3535
* @return array() Returns phone_number information of user
3636
*/
3737
public function claim($user) {

classes/claim/profile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class profile implements claim {
3232

3333
/**
3434
* Get addres claim.
35-
* @param array of core_user user user want the address claim from
35+
* @param array $user core_user want the address claim from
3636
* @return array() Returns profile information of user
3737
*/
3838
public function claim($user) {

classes/client.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,38 @@
2727
* class that manges settings for client for this IdP.
2828
*/
2929
class client {
30-
/**@var int id primary for this client in the database */
30+
/** @var int $id primary for this client in the database */
3131
public int $id; // Has to be pulic now because the way its send to database in update.
3232

33-
/**@var string $clientid name of the client */
33+
/** @var string $clientid name of the client */
3434
public string $clientid;
35-
/**@var string $clientsecret password of this client*/
35+
36+
/** @var string $clientsecret password of this client*/
3637
public string $clientsecret;
37-
/**@var string $redirecturi addres of the clinet to send user to after identification*/
38+
39+
/** @var string $redirecturi addres of the clinet to send user to after identification*/
3840
public string $redirecturi;
39-
/**@var array $granttypes types of oauth flows server will accept for this client*/
41+
42+
/** @var array $granttypes types of oauth flows server will accept for this client*/
4043
public array $granttypes;
41-
/**@var array $scopes the client is allowed to request, which in our case are the claims*/
44+
45+
/** @var array $scope the client is allowed to request, which in our case are the claims*/
4246
public array $scope;
43-
/**@var int $userid if client grantype used is client_authenticat. which user the client inperonates */
47+
48+
/** @var int $userid if client grantype used is client_authenticat. which user the client inperonates */
4449
public int $userid;
45-
/**@var int $noconfirmation if user is asked to confirm that client is allowed to get this information of the user*/
50+
51+
/** @var int $noconfirmation if user is asked to confirm that client is allowed to get this information of the user*/
4652
public int $noconfirmation;
4753

4854
/**
4955
* Initialze the client class.
56+
* @param int $clientid
57+
* @param string $redirecturi
58+
* @param array $granttypes
59+
* @param array $scope
60+
* @param int $userid
61+
* @param bool $noconfirmation
5062
*/
5163
public function __construct($clientid, $redirecturi, $granttypes, $scope, $userid, $noconfirmation) {
5264
$this->clientid = $clientid;
@@ -71,6 +83,8 @@ public function id() {
7183
// TODO Use $storage->getClientDetails instead .
7284
/**
7385
* Get client by client id from database.
86+
*
87+
* @param int $id clientid
7488
*/
7589
public static function get_client_by_id($id) {
7690
global $DB;
@@ -130,6 +144,8 @@ public function delete() {
130144

131145
/**
132146
* Generate public private key pair
147+
*
148+
* @param int $clientid
133149
*/
134150
public static function generate_key_pair($clientid) {
135151
global $DB;

0 commit comments

Comments
 (0)