@@ -97,35 +97,49 @@ jobs:
9797 with :
9898 path : apps/${{ env.APP_NAME }}
9999
100+ - name : Check PHP version requirement
101+ id : php_check
102+ run : |
103+ PHP_MIN=$(grep -oP 'php min-version="\K[^"]+' apps/${{ env.APP_NAME }}/appinfo/info.xml)
104+ echo "App requires PHP >= $PHP_MIN, current is ${{ matrix.php-versions }}"
105+ if php -r "exit(version_compare('${{ matrix.php-versions }}', '$PHP_MIN') < 0 ? 1 : 0);"; then
106+ echo "PHP version ${{ matrix.php-versions }} meets minimum requirement $PHP_MIN"
107+ else
108+ echo "PHP version ${{ matrix.php-versions }} is below minimum $PHP_MIN, skipping"
109+ echo "skip=true" >> $GITHUB_OUTPUT
110+ fi
111+
100112 - name : Set up php ${{ matrix.php-versions }}
113+ if : steps.php_check.outputs.skip != 'true'
101114 uses : shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
102115 with :
103116 php-version : ${{ matrix.php-versions }}
104- # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
105117 extensions : bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, mysql, pdo_mysql
106118 coverage : none
107119 ini-file : development
108120 env :
109121 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
110122
111123 - name : Enable ONLY_FULL_GROUP_BY MySQL option
124+ if : steps.php_check.outputs.skip != 'true'
112125 run : |
113126 echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
114127 echo 'SELECT @@sql_mode;' | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
115128
116129 - name : Check composer file existence
130+ if : steps.php_check.outputs.skip != 'true'
117131 id : check_composer
118132 uses : andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3.0.0
119133 with :
120134 files : apps/${{ env.APP_NAME }}/composer.json
121135
122136 - name : Set up dependencies
123- # Only run if phpunit config file exists
124- if : steps.check_composer.outputs.files_exists == 'true'
137+ if : steps.php_check.outputs.skip != 'true' && steps.check_composer.outputs.files_exists == 'true'
125138 working-directory : apps/${{ env.APP_NAME }}
126139 run : composer i
127140
128141 - name : Set up Nextcloud
142+ if : steps.php_check.outputs.skip != 'true'
129143 env :
130144 DB_PORT : 4444
131145 run : |
@@ -134,47 +148,44 @@ jobs:
134148 ./occ app:enable --force ${{ env.APP_NAME }}
135149
136150 - name : Check PHPUnit script is defined
151+ if : steps.php_check.outputs.skip != 'true'
137152 id : check_phpunit
138153 continue-on-error : true
139154 working-directory : apps/${{ env.APP_NAME }}
140155 run : |
141156 composer run --list | grep '^ test:unit ' | wc -l | grep 1
142157
143158 - name : PHPUnit
144- # Only run if phpunit config file exists
145- if : steps.check_phpunit.outcome == 'success'
159+ if : steps.php_check.outputs.skip != 'true' && steps.check_phpunit.outcome == 'success'
146160 working-directory : apps/${{ env.APP_NAME }}
147161 run : composer run test:unit
148162
149163 - name : Check PHPUnit integration script is defined
164+ if : steps.php_check.outputs.skip != 'true'
150165 id : check_integration
151166 continue-on-error : true
152167 working-directory : apps/${{ env.APP_NAME }}
153168 run : |
154169 composer run --list | grep '^ test:integration ' | wc -l | grep 1
155170
156171 - name : Run Nextcloud
157- # Only run if phpunit integration config file exists
158- if : steps.check_integration.outcome == 'success'
172+ if : steps.php_check.outputs.skip != 'true' && steps.check_integration.outcome == 'success'
159173 run : php -S localhost:8080 &
160174
161175 - name : PHPUnit integration
162- # Only run if phpunit integration config file exists
163- if : steps.check_integration.outcome == 'success'
176+ if : steps.php_check.outputs.skip != 'true' && steps.check_integration.outcome == 'success'
164177 working-directory : apps/${{ env.APP_NAME }}
165178 run : composer run test:integration
166179
167180 - name : Print logs
168- if : always()
181+ if : steps.php_check.outputs.skip != 'true'
169182 run : |
170183 cat data/nextcloud.log
171184
172- - name : Skipped
173- # Fail the action when neither unit nor integration tests ran
174- if : steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
185+ - name : Skipped notification
186+ if : steps.php_check.outputs.skip == 'true'
175187 run : |
176- echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
177- exit 1
188+ echo "PHP version ${{ matrix.php-versions }} is below app minimum, skipping"
178189
179190 summary :
180191 permissions :
@@ -188,4 +199,4 @@ jobs:
188199
189200 steps :
190201 - name : Summary status
191- run : if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mysql.result != 'success' }}; then exit 1; fi
202+ run : if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-mysql.result != 'success' && needs.phpunit-mysql.result != 'skipped' }}; then exit 1; fi
0 commit comments