1+ # Title of the workflow
12name : Moodle Plugin CI
23
4+ # Run this workflow every time a new commit pushed to your repository or PR
5+ # created.
36on :
47 push :
58 paths-ignore :
811 paths-ignore :
912 - ' node_modules/**'
1013
11-
1214jobs :
15+ # Set the job key. The key is displayed as the job name
16+ # when a job name is not provided
1317 test :
14- runs-on : ubuntu-latest
18+ # Virtual environment to use.
19+ runs-on : ubuntu-22.04
1520
21+ # DB services you need for testing.
1622 services :
1723 postgres :
1824 image : postgres:13
@@ -22,25 +28,39 @@ jobs:
2228 ports :
2329 - 5432:5432
2430 options : --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
31+
2532 mariadb :
2633 image : mariadb:10
2734 env :
2835 MYSQL_USER : ' root'
2936 MYSQL_ALLOW_EMPTY_PASSWORD : " true"
3037 MYSQL_CHARACTER_SET_SERVER : " utf8mb4"
3138 MYSQL_COLLATION_SERVER : " utf8mb4_unicode_ci"
32-
3339 ports :
3440 - 3306:3306
3541 options : --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3
3642
43+ # Determines build matrix. This is a list of PHP versions, databases and
44+ # branches to test our project against. For each combination a separate
45+ # build will be created. For example below 6 builds will be created in
46+ # total (7.4-pgsql, 7.4-mariadb, 8.0-pgsql, 8.0-mariadb, etc.). If we add
47+ # another branch, total number of builds will become 12.
3748 strategy :
3849 fail-fast : false
3950 matrix :
4051 include :
41- - php : ' 8.3 '
52+ - php : ' 8.4 '
4253 moodle-branch : ' main'
4354 database : ' pgsql'
55+ - php : ' 8.4'
56+ moodle-branch : ' MOODLE_501_STABLE'
57+ database : ' mariadb'
58+ - php : ' 8.3'
59+ moodle-branch : ' MOODLE_500_STABLE'
60+ database : ' pgsql'
61+ - php : ' 8.3'
62+ moodle-branch : ' MOODLE_405_STABLE'
63+ database : ' mariadb'
4464 - php : ' 8.3'
4565 moodle-branch : ' MOODLE_404_STABLE'
4666 database : ' pgsql'
@@ -55,78 +75,93 @@ jobs:
5575 database : ' mariadb'
5676
5777 steps :
78+ # Check out this repository code in ./plugin directory
5879 - name : Check out repository code
59- uses : actions/checkout@v2
80+ uses : actions/checkout@v4
6081 with :
6182 path : plugin
6283
84+ # Install PHP of required version. For possible options see https://github.com/shivammathur/setup-php
6385 - name : Setup PHP ${{ matrix.php }}
6486 uses : shivammathur/setup-php@v2
6587 with :
6688 php-version : ${{ matrix.php }}
67- extensions : ${{ matrix.extensions }}
6889 ini-values : max_input_vars=5000
69- # none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead.
90+ # If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
91+ # If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
7092 coverage : none
7193
94+ # Install this project into a directory called "ci", updating PATH and
95+ # locale, define nvm location.
7296 - name : Initialise moodle-plugin-ci
7397 run : |
74- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
98+ composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
7599 echo $(cd ci/bin; pwd) >> $GITHUB_PATH
76100 echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
77101 sudo locale-gen en_AU.UTF-8
78102 echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
103+
104+ # Run the default install.
105+ # Optionally, it is possible to specify a different Moodle repo to use
106+ # (https://github.com/moodle/moodle.git is used by default) and define
107+ # ignore directives or any other env vars for install step. For more
108+ # details on configuring for specific requirements please refer to the
109+ # 'Help' page.
110+ #
111+ # env:
112+ # MOODLE_REPO=https://github.com/username/moodle.git
113+ # IGNORE_PATHS: 'ignore'
114+ # IGNORE_NAMES: 'ignore_name.php'
115+ # MUSTACHE_IGNORE_NAMES: 'broken.mustache'
116+ # CODECHECKER_IGNORE_PATHS: 'ignoreme'
117+ # CODECHECKER_IGNORE_NAMES: 'ignoreme_name.php'
118+ #
119+ # Other env vars are available for install, namely:
120+ # - DB_USER / DB_PASS / DB_NAME / DB_HOST / DB_PORT: used
121+ # by install to feed the corresponding --db-xxxx options.
122+ # - MOODLE_APP: used to install dependencies to run Behat tests
123+ # using the Moodle App.
79124 - name : Install moodle-plugin-ci
80125 run : |
81126 moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
82127 env :
83128 DB : ${{ matrix.database }}
84129 MOODLE_BRANCH : ${{ matrix.moodle-branch }}
130+ # Uncomment this to run Behat tests using the Moodle App.
131+ # MOODLE_APP: 'true'
85132
133+ # Steps that are run for the purpose of testing. Any of these steps
134+ # can be re-ordered or removed to your liking. And of course, you can
135+ # add any of your own custom steps.
86136 - name : PHP Lint
87- if : ${{ always () }}
137+ if : ${{ !cancelled () }} # prevents CI run stopping if step failed.
88138 run : moodle-plugin-ci phplint
89139
90- - name : PHP Copy/Paste Detector
91- continue-on-error : true # This step will show errors but will not fail
92- if : ${{ always() }}
93- run : moodle-plugin-ci phpcpd
94-
95140 - name : PHP Mess Detector
96- continue-on-error : true # This step will show errors but will not fail
97- if : ${{ always () }}
141+ continue-on-error : true
142+ if : ${{ !cancelled () }}
98143 run : moodle-plugin-ci phpmd
99144
100145 - name : Moodle Code Checker
101- if : ${{ always() }}
102- # Allow 3 warnings for privacy provider interfaces (Moodle <3.6)
103- run : moodle-plugin-ci codechecker --max-warnings 3
146+ if : ${{ !cancelled() }}
147+ run : moodle-plugin-ci phpcs --max-warnings 3
104148
105149 - name : Moodle PHPDoc Checker
106- if : ${{ always () }}
107- run : moodle-plugin-ci phpdoc
150+ if : ${{ !cancelled () }}
151+ run : moodle-plugin-ci phpdoc --max-warnings 0
108152
109153 - name : Validating
110- if : ${{ always () }}
154+ if : ${{ !cancelled () }}
111155 run : moodle-plugin-ci validate
112156
113157 - name : Check upgrade savepoints
114- if : ${{ always () }}
158+ if : ${{ !cancelled () }}
115159 run : moodle-plugin-ci savepoints
116160
117- # Mustache and Grunt are failing so commenting out for now
118- # - name: Mustache Lint
119- # if: ${{ always() }}
120- # run: moodle-plugin-ci mustache
121-
122- # - name: Grunt
123- # if: ${{ always() }}
124- # run: moodle-plugin-ci grunt --max-lint-warnings 0
125-
126161 - name : PHPUnit tests
127- if : ${{ always () }}
128- run : moodle-plugin-ci phpunit --fail-on-warning
162+ if : ${{ !cancelled () }}
163+ run : moodle-plugin-ci phpunit
129164
130- - name : Behat features
131- if : ${{ always () }}
132- run : moodle-plugin-ci behat --profile chrome
165+ - name : Mark cancelled jobs as failed.
166+ if : ${{ cancelled () }}
167+ run : exit 1
0 commit comments