1+ # This workflow is provided via the organization template repository
2+ #
3+ # https://github.com/nextcloud/.github
4+ # https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
16name : PHPUnit
27
38on :
49 pull_request :
5- push :
6- branches :
7- - master
8- - stable*
10+ paths :
11+ - ' .github/workflows/**'
12+ - ' appinfo/**'
13+ - ' lib/**'
14+ - ' templates/**'
15+ - ' tests/**'
16+ - ' vendor/**'
17+ - ' vendor-bin/**'
18+ - ' .php-cs-fixer.dist.php'
19+ - ' composer.json'
20+ - ' composer.lock'
21+
22+ permissions :
23+ contents : read
24+
25+ concurrency :
26+ group : phpunit-mysql-${{ github.head_ref || github.run_id }}
27+ cancel-in-progress : true
928
1029env :
11- APP_NAME : registration
1230 # Location of the phpunit.xml and phpunit.integration.xml files
13- # Comment to disable
1431 PHPUNIT_CONFIG : ./tests/phpunit.xml
15- # PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
32+ PHPUNIT_INTEGRATION_CONFIG : ./tests/phpunit.integration.xml
1633
1734jobs :
1835 phpunit-mysql :
1936 runs-on : ubuntu-latest
2037
2138 strategy :
22- # do not stop on another job's failure
23- fail-fast : false
2439 matrix :
2540 php-versions : ['7.4', '8.0', '8.1']
26- server-versions : ['master', 'stable25' ]
41+ server-versions : ['master']
2742
2843 services :
2944 mysql :
@@ -35,15 +50,25 @@ jobs:
3550 options : --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
3651
3752 steps :
53+ - name : Set app env
54+ run : |
55+ # Split and keep last
56+ echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
57+
58+ - name : Enable ONLY_FULL_GROUP_BY MySQL option
59+ run : |
60+ echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
61+ echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
62+
3863 - name : Checkout server
39- uses : actions/checkout@v2
64+ uses : actions/checkout@v3
4065 with :
4166 submodules : true
4267 repository : nextcloud/server
4368 ref : ${{ matrix.server-versions }}
4469
4570 - name : Checkout app
46- uses : actions/checkout@v2
71+ uses : actions/checkout@v3
4772 with :
4873 path : apps/${{ env.APP_NAME }}
4974
5580 extensions : mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
5681 coverage : none
5782
83+ - name : Check composer file existence
84+ id : check_composer
85+ uses : andstor/file-existence-action@v1
86+ with :
87+ files : apps/${{ env.APP_NAME }}/composer.json
88+
5889 - name : Set up PHPUnit
90+ # Only run if phpunit config file exists
91+ if : steps.check_composer.outputs.files_exists == 'true'
5992 working-directory : apps/${{ env.APP_NAME }}
6093 run : composer i
6194
@@ -66,21 +99,39 @@ jobs:
6699 mkdir data
67100 ./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
68101 ./occ app:enable --force ${{ env.APP_NAME }}
69- php -S localhost:8080 &
102+
103+ - name : Check PHPUnit config file existence
104+ id : check_phpunit
105+ uses : andstor/file-existence-action@v1
106+ with :
107+ files : apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
70108
71109 - name : PHPUnit
72110 # Only run if phpunit config file exists
73- if : env.PHPUNIT_CONFIG != ' '
111+ if : steps.check_phpunit.outputs.files_exists == 'true '
74112 working-directory : apps/${{ env.APP_NAME }}
75113 run : ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
76114
115+ - name : Check PHPUnit integration config file existence
116+ id : check_integration
117+ uses : andstor/file-existence-action@v1
118+ with :
119+ files : apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
120+
121+ - name : Run Nextcloud
122+ # Only run if phpunit integration config file exists
123+ if : steps.check_integration.outputs.files_exists == 'true'
124+ run : php -S localhost:8080 &
125+
77126 - name : PHPUnit integration
78127 # Only run if phpunit integration config file exists
79- if : env.PHPUNIT_INTEGRATION_CONFIG != ' '
128+ if : steps.check_integration.outputs.files_exists == 'true '
80129 working-directory : apps/${{ env.APP_NAME }}
81130 run : ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
82131
83132 summary :
133+ permissions :
134+ contents : none
84135 runs-on : ubuntu-latest
85136 needs : phpunit-mysql
86137
0 commit comments