@@ -32,11 +32,6 @@ concurrency:
3232 group : phpunit-mysql-${{ github.head_ref || github.run_id }}
3333 cancel-in-progress : true
3434
35- env :
36- # Location of the phpunit.xml and phpunit.integration.xml files
37- PHPUNIT_CONFIG : ./tests/phpunit.xml
38- PHPUNIT_INTEGRATION_CONFIG : ./tests/phpunit.integration.xml
39-
4035jobs :
4136 phpunit-mysql :
4237 runs-on : ubuntu-latest
@@ -67,22 +62,21 @@ jobs:
6762 echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
6863
6964 - name : Checkout server
70- uses : actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
65+ uses : actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
7166 with :
7267 submodules : true
7368 repository : nextcloud/server
7469 ref : ${{ matrix.server-versions }}
7570
7671 - name : Checkout app
77- uses : actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
72+ uses : actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
7873 with :
7974 path : apps/${{ env.APP_NAME }}
8075
8176 - name : Set up php ${{ matrix.php-versions }}
8277 uses : shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2
8378 with :
8479 php-version : ${{ matrix.php-versions }}
85- tools : phpunit
8680 extensions : mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
8781 coverage : none
8882 env :
9488 with :
9589 files : apps/${{ env.APP_NAME }}/composer.json
9690
97- - name : Set up PHPUnit
91+ - name : Set up dependencies
9892 # Only run if phpunit config file exists
9993 if : steps.check_composer.outputs.files_exists == 'true'
10094 working-directory : apps/${{ env.APP_NAME }}
@@ -108,34 +102,43 @@ jobs:
108102 ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
109103 ./occ app:enable --force ${{ env.APP_NAME }}
110104
111- - name : Check PHPUnit config file existence
105+ - name : Check PHPUnit script is defined
112106 id : check_phpunit
113- uses : andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
114- with :
115- files : apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
107+ continue-on-error : true
108+ working-directory : apps/${{ env.APP_NAME }}
109+ run : |
110+ composer run --list | grep "^ test:unit " | wc -l | grep 1
116111
117112 - name : PHPUnit
118113 # Only run if phpunit config file exists
119- if : steps.check_phpunit.outputs.files_exists == 'true '
114+ if : steps.check_phpunit.outcome == 'success '
120115 working-directory : apps/${{ env.APP_NAME }}
121- run : ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
116+ run : composer run test:unit
122117
123- - name : Check PHPUnit integration config file existence
118+ - name : Check PHPUnit integration script is defined
124119 id : check_integration
125- uses : andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
126- with :
127- files : apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
120+ continue-on-error : true
121+ working-directory : apps/${{ env.APP_NAME }}
122+ run : |
123+ composer run --list | grep "^ test:integration " | wc -l | grep 1
128124
129125 - name : Run Nextcloud
130126 # Only run if phpunit integration config file exists
131- if : steps.check_integration.outputs.files_exists == 'true '
127+ if : steps.check_integration.outcome == 'success '
132128 run : php -S localhost:8080 &
133129
134130 - name : PHPUnit integration
135131 # Only run if phpunit integration config file exists
136- if : steps.check_integration.outputs.files_exists == 'true '
132+ if : steps.check_integration.outcome == 'success '
137133 working-directory : apps/${{ env.APP_NAME }}
138- run : ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
134+ run : composer run test:integration
135+
136+ - name : Skipped
137+ # Fail the action when neither unit nor integration tests ran
138+ if : steps.check_phpunit.outcome == 'failure' && steps.check_integration.outcome == 'failure'
139+ run : |
140+ echo 'Neither PHPUnit nor PHPUnit integration tests are specified in composer.json scripts'
141+ exit 1
139142
140143 summary :
141144 permissions :
0 commit comments