1- name : Moodle Plugin CI
2-
3- on : [push, pull_request]
4-
1+ name : Moodle qtype multianswerwiris CI
2+
3+ # Automatically triggered on push to main branch, on pull requests
4+ on :
5+ workflow_dispatch :
6+ inputs :
7+ tags :
8+ description : ' Add additional test tags. It needs "&&" to concatenate and a leading @. Example: "&&@mtmoodle-x"'
9+ required : false
10+ default : " "
11+ push :
12+ branches :
13+ - main
14+ pull_request :
15+ branches :
16+ - " **"
17+ schedule :
18+ - cron : " 0 6 * * *"
519jobs :
620 test :
7- runs-on : ubuntu-18.04
21+ runs-on : ubuntu-latest
822
923 services :
1024 postgres :
11- image : postgres:10
25+ image : postgres:17
1226 env :
13- POSTGRES_USER : ' postgres'
14- POSTGRES_HOST_AUTH_METHOD : ' trust'
27+ POSTGRES_USER : " postgres"
28+ POSTGRES_HOST_AUTH_METHOD : " trust"
1529 ports :
1630 - 5432:5432
1731 options : --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
1832
1933 strategy :
2034 fail-fast : false
35+
2136 matrix :
22- php : ['7.3', '7.4']
23- moodle-branch : ['MOODLE_39_STABLE', 'MOODLE_310_STABLE', 'MOODLE_311_STABLE', 'MOODLE_400_STABLE']
37+ php : ["7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
38+ moodle_branch :
39+ [
40+ " MOODLE_39_STABLE" ,
41+ " MOODLE_401_STABLE" ,
42+ " MOODLE_405_STABLE" ,
43+ " MOODLE_500_STABLE" ,
44+ " MOODLE_501_STABLE" ,
45+ " main" ,
46+ ]
2447 database : [pgsql]
48+ browser : ["chrome", "firefox"]
49+ exclude :
50+ # Exclude Moodle+PHP incompatible versions
51+ # See: https://docs.moodle.org/dev/Moodle_and_PHP
52+
53+ - moodle_branch : " MOODLE_401_STABLE"
54+ php : " 7.3"
55+ - moodle_branch : " MOODLE_405_STABLE"
56+ php : " 7.3"
57+ - moodle_branch : " MOODLE_500_STABLE"
58+ php : " 7.3"
59+ - moodle_branch : " MOODLE_501_STABLE"
60+ php : " 7.3"
61+
62+
63+ - moodle_branch : " MOODLE_405_STABLE"
64+ php : " 7.4"
65+ - moodle_branch : " MOODLE_500_STABLE"
66+ php : " 7.4"
67+ - moodle_branch : " MOODLE_501_STABLE"
68+ php : " 7.4"
69+
70+
71+ - moodle_branch : " MOODLE_39_STABLE"
72+ php : " 8.0"
73+ - moodle_branch : " MOODLE_405_STABLE"
74+ php : " 8.0"
75+ - moodle_branch : " MOODLE_500_STABLE"
76+ php : " 8.0"
77+ - moodle_branch : " MOODLE_501_STABLE"
78+ php : " 8.0"
79+
80+ - moodle_branch : " MOODLE_39_STABLE"
81+ php : " 8.1"
82+ - moodle_branch : " MOODLE_500_STABLE"
83+ php : " 8.1"
84+ - moodle_branch : " MOODLE_501_STABLE"
85+ php : " 8.1"
86+
87+ - moodle_branch : " MOODLE_39_STABLE"
88+ php : " 8.2"
89+ - moodle_branch : " MOODLE_401_STABLE"
90+ php : " 8.2"
91+
92+ - moodle_branch : " MOODLE_39_STABLE"
93+ php : " 8.3"
94+ - moodle_branch : " MOODLE_401_STABLE"
95+ php : " 8.3"
96+
97+ - moodle_branch : " MOODLE_39_STABLE"
98+ php : " 8.4"
99+ - moodle_branch : " MOODLE_401_STABLE"
100+ php : " 8.4"
101+ - moodle_branch : " MOODLE_405_STABLE"
102+ php : " 8.4"
103+
104+ - moodle_branch : " main"
105+
106+
107+ include :
108+ # Only test master against latest PHP until we know which
109+ # versions are supported in the next release
110+ - moodle_branch : " main"
111+ php : " 8.4"
112+ database : " pgsql"
113+ continue-on-error : ${{ matrix.branch == 'main' }}
114+
25115 steps :
26- - name : Get branch name
27- id : branch-name
28- uses :
tj-actions/[email protected] 29-
30116 - name : Check out repository code
31- uses : actions/checkout@v2
117+ uses : actions/checkout@v4
32118 with :
33119 path : plugin
34120
121+ # 0.1 Detect branch name based on event type.
122+ - name : Set branch name
123+ id : get_branch
124+ run : |
125+ if [ "${{ github.event_name }}" == "pull_request" ]; then
126+ echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
127+ else
128+ echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
129+ fi
130+
131+ # 0.2 Log current matrix info.
132+ - name : Log info
133+ run : |
134+ echo "PHP: ${{ matrix.php }}"
135+ echo "Moodle: ${{ matrix.moodle_branch }}"
136+ echo "Browser: ${{ matrix.browser }}"
137+ echo "Branch: ${{ env.BRANCH_NAME }}"
138+
139+ # 0.3 Cache Composer for faster builds.
140+ - name : Cache Composer dependencies
141+ uses : actions/cache@v3
142+ with :
143+ path : |
144+ ${{ github.workspace }}/.composer/cache
145+ ${{ github.workspace }}/.npm
146+ key : ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.moodle_branch }}
147+ restore-keys : ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.moodle_branch }}
148+
149+ # 1. Setup PHP for the current matrix.
35150 - name : Setup PHP ${{ matrix.php }}
36151 uses : shivammathur/setup-php@v2
37152 with :
38153 php-version : ${{ matrix.php }}
39154 extensions : ${{ matrix.extensions }}
40- ini-values : max_input_vars=5000
155+ ini-values : max_input_vars=10000
41156 coverage : none
42157
158+ # 2. Install moodle-plugin-ci tool.
43159 - name : Initialise moodle-plugin-ci
44160 run : |
45- composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
161+ composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
46162 echo $(cd ci/bin; pwd) >> $GITHUB_PATH
47163 echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
48164 sudo locale-gen en_AU.UTF-8
49- echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
50- - name : Add filter & commons qtype
165+ echo NVM_DIR=$NVM_DIR >> $GITHUB_ENV
166+ env :
167+ IGNORE_PATHS : classes/privacy,ignore,node_modules,integration,render
168+ COVERAGE : false
169+ CODECHECKER_IGNORE_PATHS : classes/privacy,ignore,node_modules,integration,render
170+ PHPUNIT_IGNORE_PATHS : classes/privacy,ignore,node_modules,integration,render
171+
172+ # 3. Install filter
173+ - name : Add Wiris filter
51174 run : |
52175 moodle-plugin-ci add-plugin wiris/moodle-filter_wiris
53- moodle-plugin-ci add-plugin --branch ${{ steps.branch-name.outputs.current_branch }} wiris/moodle-qtype_wq
54- moodle-plugin-ci add-plugin --branch ${{ steps.branch-name.outputs.current_branch }} wiris/moodle-qtype_shortanswerwiris
55- moodle-plugin-ci add-plugin --branch ${{ steps.branch-name.outputs.current_branch }} wiris/moodle-qtype_multichoicewiris
176+
177+ # 3.5. Install Wiris Quizzes plugin.
178+ - name : Add Wiris Quizzes plugin
179+ id : install-plugin-quizzes
180+ if : ${{ always() }}
181+ continue-on-error : true
182+ run : |
183+ moodle-plugin-ci add-plugin --branch ${{ env.BRANCH_NAME }} wiris/moodle-qtype_wq
184+ moodle-plugin-ci add-plugin --branch ${{ env.BRANCH_NAME }} wiris/moodle-qtype_shortanswerwiris
185+ - name : Add Wiris Quizzes plugin using the main branch
186+ if : ${{ steps.install-plugin-quizzes.outcome != 'success' }}
187+ run : |
188+ moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_wq
189+ moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_shortanswerwiris
56190
191+ # 4. Install plugin and configure DB.
57192 - name : Install moodle-plugin-ci
58- run : |
59- moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
193+ run : moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
60194 env :
61195 DB : ${{ matrix.database }}
62- MOODLE_BRANCH : ${{ matrix.moodle-branch }}
63-
64- - name : PHP Lint
65- if : ${{ always() }}
66- run : moodle-plugin-ci phplint
196+ MOODLE_BRANCH : ${{ matrix.moodle_branch }}
67197
68- - name : PHP Copy/Paste Detector
69- continue-on-error : true # This step will show errors but will not fail
70- if : ${{ always() }}
71- run : moodle-plugin-ci phpcpd
72-
73- - name : PHP Mess Detector
74- continue-on-error : true # This step will show errors but will not fail
75- if : ${{ always() }}
76- run : moodle-plugin-ci phpmd
77-
78- - name : Moodle Code Checker
198+ # 5. Run PHPUnit tests.
199+ - name : PHPUnit tests
79200 if : ${{ always() }}
80- run : moodle-plugin-ci codechecker --max-warnings 0
201+ run : moodle-plugin-ci phpunit ./plugin
202+ continue-on-error : true
81203
204+ # 5.1 Run Moodle code validation.
82205 - name : Validating
83206 if : ${{ always() }}
84- run : moodle-plugin-ci validate
85-
86- - name : Check upgrade savepoints
87- if : ${{ always() }}
88- run : moodle-plugin-ci savepoints
89-
90- - name : Mustache Lint
91- if : ${{ always() }}
92- run : moodle-plugin-ci mustache
93-
94- - name : Grunt
95- if : ${{ always() }}
96- run : moodle-plugin-ci grunt --max-lint-warnings 0
207+ run : moodle-plugin-ci validate ./plugin
208+ continue-on-error : true
97209
98- - name : PHPUnit tests
99- if : ${{ always() }}
100- run : moodle-plugin-ci phpunit
210+ # 6. Run Behat tests.
211+ - name : Behat features for ( ${{ matrix.moodle_branch }} on PHP ${{ matrix.php }} )
212+ id : behat
213+ run : |
214+ case "${{ matrix.moodle_branch }}" in
215+ "MOODLE_401_STABLE"|"MOODLE_402_STABLE"|"MOODLE_403_STABLE"|"MOODLE_404_STABLE"|"MOODLE_405_STABLE"|"MOODLE_500_STABLE"|"MOODLE_501_STABLE"|"main")
216+ TAG="@qtype_multianswerwiris"
217+ ;;
218+ esac
219+ moodle-plugin-ci behat --tags=$TAG --profile ${{ matrix.browser }} --auto-rerun=2 --verbose -vvv
220+
221+ # 6.1 Upload Behat fail dumps when errors occur.
222+ - name : Upload Behat Faildump
223+ if : ${{ failure() && steps.behat.outcome == 'failure' }}
224+ uses : actions/upload-artifact@v4
225+ with :
226+ name : Behat Faildump (${{ matrix.php }}, ${{ matrix.moodle_branch }}, ${{ matrix.browser }})
227+ path : ${{ github.workspace }}/moodledata/behat_dump
228+ retention-days : 1
229+ if-no-files-found : ignore
101230
102- - name : Behat features
103- if : ${{ always() }}
104- run : moodle-plugin-ci behat --profile chrome
0 commit comments