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