Skip to content

Commit 696db59

Browse files
author
Laur0r
authored
Merge pull request #48 from learnweb/update/m41
Update for Moodle 4.1 + fix for long course names
2 parents c8cfc99 + c46b17b commit 696db59

36 files changed

+335
-226
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: Moodle Plugin CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
static:
7+
runs-on: ubuntu-latest
8+
9+
strategy:
10+
matrix:
11+
php: ['8.0']
12+
moodle-branch: ['MOODLE_401_STABLE']
13+
database: ['pgsql']
14+
15+
steps:
16+
- name: Start PostgreSQL
17+
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14
18+
19+
- name: Check out repository code
20+
uses: actions/checkout@v3
21+
with:
22+
path: plugin
23+
24+
- name: Setup PHP ${{ matrix.php }}
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
ini-values: max_input_vars=5000
29+
coverage: none
30+
31+
- name: Get composer cache directory
32+
id: composer-cache
33+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
34+
35+
- name: Composer cache
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ steps.composer-cache.outputs.dir }}
39+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-composer-
42+
43+
- name: npm cache
44+
uses: actions/cache@v3
45+
with:
46+
path: ~/.npm
47+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
48+
restore-keys: |
49+
${{ runner.os }}-node-
50+
51+
- name: Initialise moodle-plugin-ci
52+
run: |
53+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
54+
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
55+
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
56+
sudo locale-gen en_AU.UTF-8
57+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
58+
59+
- name: Install moodle-plugin-ci
60+
run: |
61+
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 --no-init
62+
env:
63+
DB: ${{ matrix.database }}
64+
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
65+
66+
- name: PHP Lint
67+
if: ${{ always() }}
68+
run: moodle-plugin-ci phplint
69+
70+
- name: PHP Copy/Paste Detector
71+
if: ${{ always() }}
72+
run: moodle-plugin-ci phpcpd
73+
74+
- name: PHP Mess Detector
75+
if: ${{ always() }}
76+
run: moodle-plugin-ci phpmd
77+
78+
- name: Moodle Code Checker
79+
if: ${{ always() }}
80+
run: moodle-plugin-ci codechecker
81+
82+
- name: Moodle PHPDoc Checker
83+
if: ${{ always() }}
84+
run: moodle-plugin-ci phpdoc
85+
continue-on-error: true
86+
87+
- name: Validating
88+
if: ${{ always() }}
89+
run: moodle-plugin-ci validate
90+
91+
- name: Check upgrade savepoints
92+
if: ${{ always() }}
93+
run: moodle-plugin-ci savepoints
94+
95+
- name: Mustache Lint
96+
if: ${{ always() }}
97+
run: moodle-plugin-ci mustache
98+
99+
- name: Grunt
100+
if: ${{ always() }}
101+
run: moodle-plugin-ci grunt
102+
103+
test:
104+
runs-on: ubuntu-latest
105+
needs: static
106+
107+
strategy:
108+
fail-fast: false
109+
matrix:
110+
php: ['8.0']
111+
moodle-branch: ['MOODLE_311_STABLE', 'MOODLE_400_STABLE', 'MOODLE_401_STABLE']
112+
database: ['mariadb', 'pgsql']
113+
include:
114+
- php: '7.4'
115+
moodle-branch: 'MOODLE_39_STABLE'
116+
database: 'mariadb'
117+
- php: '7.4'
118+
moodle-branch: 'MOODLE_39_STABLE'
119+
database: 'pgsql'
120+
121+
steps:
122+
- name: Start MariaDB
123+
if: matrix.database == 'mariadb'
124+
run: docker run -p 3306:3306 -e MYSQL_USER=root -e MYSQL_ALLOW_EMPTY_PASSWORD=true -d mariadb:10
125+
126+
- name: Start PostgreSQL
127+
if: matrix.database == 'pgsql'
128+
run: docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_HOST_AUTH_METHOD=trust -d postgres:14
129+
130+
- name: Check out repository code
131+
uses: actions/checkout@v3
132+
with:
133+
path: plugin
134+
135+
- name: Setup PHP ${{ matrix.php }}
136+
uses: shivammathur/setup-php@v2
137+
with:
138+
php-version: ${{ matrix.php }}
139+
ini-values: max_input_vars=5000
140+
coverage: none
141+
142+
- name: Get composer cache directory
143+
id: composer-cache
144+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
145+
- name: Composer cache
146+
uses: actions/cache@v3
147+
with:
148+
path: ${{ steps.composer-cache.outputs.dir }}
149+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
150+
restore-keys: |
151+
${{ runner.os }}-composer-
152+
- name: npm cache
153+
uses: actions/cache@v3
154+
with:
155+
path: ~/.npm
156+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
157+
restore-keys: |
158+
${{ runner.os }}-node-
159+
160+
- name: Initialise moodle-plugin-ci
161+
run: |
162+
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
163+
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
164+
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
165+
sudo locale-gen en_AU.UTF-8
166+
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
167+
168+
- name: Install moodle-plugin-ci
169+
run: |
170+
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
171+
env:
172+
DB: ${{ matrix.database }}
173+
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
174+
175+
- name: PHPUnit tests
176+
if: ${{ always() }}
177+
run: moodle-plugin-ci phpunit
178+
179+
- name: Behat features
180+
if: ${{ always() }}
181+
run: moodle-plugin-ci behat --auto-rerun 0
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#
2+
# Whenever a new tag starting with "v" is pushed, add the tagged version
3+
# to the Moodle Plugins directory at https://moodle.org/plugins
4+
#
5+
# revision: 2021070201
6+
# Changed to be released on Github release with the release notes.
7+
#
8+
name: Releasing in the Plugins directory
9+
10+
on:
11+
release:
12+
types: [published]
13+
14+
defaults:
15+
run:
16+
shell: bash
17+
18+
jobs:
19+
release-at-moodle-org:
20+
runs-on: ubuntu-latest
21+
env:
22+
PLUGIN: mod_collaborativefolders
23+
CURL: curl -s
24+
ENDPOINT: https://moodle.org/webservice/rest/server.php
25+
TOKEN: ${{ secrets.MOODLE_ORG_TOKEN }}
26+
FUNCTION: local_plugins_add_version
27+
28+
steps:
29+
- name: Call the service function
30+
id: add-version
31+
run: |
32+
TAGNAME="${{ github.event.release.tag_name }}"
33+
BODY="${{ github.event.release.body }}"
34+
ZIPURL="${{ github.event.release.zipball_url }}"
35+
RESPONSE=$(${CURL} ${ENDPOINT} --data-urlencode "wstoken=${TOKEN}" \
36+
--data-urlencode "wsfunction=${FUNCTION}" \
37+
--data-urlencode "moodlewsrestformat=json" \
38+
--data-urlencode "frankenstyle=${PLUGIN}" \
39+
--data-urlencode "zipurl=${ZIPURL}" \
40+
--data-urlencode "vcssystem=git" \
41+
--data-urlencode "vcsrepositoryurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" \
42+
--data-urlencode "vcstag=${TAGNAME}" \
43+
--data-urlencode "changelogurl=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commits/${TAGNAME}" \
44+
--data-urlencode "altdownloadurl=${ZIPURL}" \
45+
--data-urlencode "releasenotes=${BODY}" \
46+
--data-urlencode "releasenotesformat=4")
47+
echo "::set-output name=response::${RESPONSE}"
48+
- name: Evaluate the response
49+
id: evaluate-response
50+
env:
51+
RESPONSE: ${{ steps.add-version.outputs.response }}
52+
run: |
53+
jq <<< ${RESPONSE}
54+
jq --exit-status ".id" <<< ${RESPONSE} > /dev/null

.travis.yml

Lines changed: 0 additions & 93 deletions
This file was deleted.

classes/configuration_exception.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
namespace mod_collaborativefolders;
2626

27-
defined('MOODLE_INTERNAL') || die();
28-
2927
/**
3028
* Exception for when a client configuration data is missing.
3129
*
@@ -45,4 +43,4 @@ class configuration_exception extends \moodle_exception {
4543
public function __construct($hint = '', $debuginfo = null) {
4644
parent::__construct('configuration_exception', 'mod_collaborativefolders', '', $hint, $debuginfo);
4745
}
48-
}
46+
}

classes/event/course_module_instance_list_viewed.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
namespace mod_collaborativefolders\event;
2626

27-
defined('MOODLE_INTERNAL') || die();
28-
2927
/**
3028
* The mod_collaborativefolders instance list viewed event class.
3129
*

classes/event/course_module_viewed.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
namespace mod_collaborativefolders\event;
2626

27-
defined('MOODLE_INTERNAL') || die();
28-
2927
/**
3028
* The mod_collaborativefolders instance viewed event class.
3129
*

classes/event/link_generated.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
namespace mod_collaborativefolders\event;
2727

28-
defined('MOODLE_INTERNAL') || die();
29-
3028
/**
3129
* Describes the successful link generation event.
3230
*
@@ -74,4 +72,4 @@ public static function get_name() {
7472
public function get_url() {
7573
return new \moodle_url('/mod/collaborativefolders/view.php', array('id' => $this->contextinstanceid));
7674
}
77-
}
75+
}

classes/issuer_management.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
namespace mod_collaborativefolders;
2626

27-
defined('MOODLE_INTERNAL') || die();
2827
use core\oauth2\issuer;
2928

3029
/**
@@ -129,4 +128,4 @@ public static function is_valid_issuer(\core\oauth2\issuer $issuer): bool {
129128
}
130129
return $endpointwebdav && $endpointocs && $endpointtoken && $endpointauth && $endpointuserinfo;
131130
}
132-
}
131+
}

0 commit comments

Comments
 (0)