Skip to content

Commit 66465a7

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

File tree

134 files changed

+18674
-1
lines changed

Some content is hidden

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

134 files changed

+18674
-1
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
- name: Grunt
100+
if: ${{ !cancelled() }}
101+
run: moodle-plugin-ci grunt --max-lint-warnings 0 ./plugin
102+
103+
- name: PHPUnit tests
104+
if: ${{ !cancelled() }}
105+
run: moodle-plugin-ci phpunit --fail-on-warning ./plugin
106+
107+
- name: Behat features
108+
id: behat
109+
if: ${{ !cancelled() }}
110+
run: moodle-plugin-ci behat --profile chrome ./plugin
111+
112+
- name: Upload Behat Faildump
113+
if: ${{ failure() && steps.behat.outcome == 'failure' }}
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: Behat Faildump (${{ join(matrix.*, ', ') }})
117+
path: ${{ github.workspace }}/moodledata/behat_dump
118+
retention-days: 7
119+
if-no-files-found: ignore
120+
121+
- name: Mark cancelled jobs as failed.
122+
if: ${{ cancelled() }}
123+
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/

vendor/autoload.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
if (PHP_VERSION_ID < 50600) {
6+
if (!headers_sent()) {
7+
header('HTTP/1.1 500 Internal Server Error');
8+
}
9+
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
10+
if (!ini_get('display_errors')) {
11+
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12+
fwrite(STDERR, $err);
13+
} elseif (!headers_sent()) {
14+
echo $err;
15+
}
16+
}
17+
trigger_error(
18+
$err,
19+
E_USER_ERROR
20+
);
21+
}
22+
23+
require_once __DIR__ . '/composer/autoload_real.php';
24+
25+
return ComposerAutoloaderInit3238e5996ada97d06351aa690c9f89b3::getLoader();
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Test Suite
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
services:
11+
redis:
12+
image: redis
13+
ports:
14+
- 6379:6379
15+
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
16+
mongodb:
17+
image: mongo
18+
ports:
19+
- 27017:27017
20+
myriadb:
21+
image: mariadb
22+
env:
23+
MYSQL_ROOT_PASSWORD: root
24+
ports:
25+
- 3808:3808
26+
- 3306:3306
27+
postgres:
28+
image: postgres
29+
env:
30+
POSTGRES_DB: oauth2_server_php
31+
POSTGRES_USER: postgres
32+
POSTGRES_PASSWORD: postgres
33+
ports:
34+
- 5432:5432
35+
options: --health-cmd="pg_isready -h localhost" --health-interval=10s --health-timeout=5s --health-retries=5
36+
strategy:
37+
matrix:
38+
php: [ 7.2, 7.3, 7.4, "8.0", 8.1, 8.2 ]
39+
name: "PHP ${{ matrix.php }} Unit Test"
40+
steps:
41+
- uses: actions/checkout@v2
42+
- uses: codecov/codecov-action@v1
43+
- name: Setup PHP
44+
uses: shivammathur/setup-php@v2
45+
with:
46+
php-version: ${{ matrix.php }}
47+
extensions: mongodb, mbstring, intl, redis, pdo_mysql
48+
- name: Install composer dependencies
49+
uses: nick-invision/retry@v1
50+
with:
51+
timeout_minutes: 10
52+
max_attempts: 3
53+
command: composer install
54+
- name: Run PHPUnit
55+
run: vendor/bin/phpunit -v
56+
phpstan:
57+
name: "PHPStan"
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v2
61+
- name: Setup PHP
62+
uses: shivammathur/setup-php@v2
63+
with:
64+
php-version: 8.1
65+
- name: Install composer dependencies
66+
uses: nick-invision/retry@v1
67+
with:
68+
timeout_minutes: 10
69+
max_attempts: 3
70+
command: composer install
71+
- name: Run PHPStan
72+
run: |
73+
composer require phpstan/phpstan
74+
vendor/bin/phpstan analyse --level=0 src/

0 commit comments

Comments
 (0)