Skip to content

Commit 8e8fc6f

Browse files
Merge pull request #777 from nextcloud/enh/use-new-phpunit-setup
Use new PHPUnit CI setup from nextcloud/.github
2 parents 1ec026b + 57c01a2 commit 8e8fc6f

5 files changed

Lines changed: 433 additions & 264 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: PHPUnit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- stable*
9+
10+
env:
11+
# Location of the phpunit.xml and phpunit.integration.xml files
12+
PHPUNIT_CONFIG: ./tests/phpunit.xml
13+
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
14+
15+
jobs:
16+
phpunit-mysql:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
php-versions: ['7.4', '8.0', '8.1']
22+
server-versions: ['master']
23+
24+
services:
25+
mysql:
26+
image: mariadb:10.5
27+
ports:
28+
- 4444:3306/tcp
29+
env:
30+
MYSQL_ROOT_PASSWORD: rootpassword
31+
options: --health-cmd="mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
32+
33+
steps:
34+
- name: Set app env
35+
run: |
36+
# Split and keep last
37+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
38+
39+
- name: Enable ONLY_FULL_GROUP_BY MySQL option
40+
run: |
41+
echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
42+
echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
43+
44+
- name: Checkout server
45+
uses: actions/checkout@v3
46+
with:
47+
submodules: true
48+
repository: nextcloud/server
49+
ref: ${{ matrix.server-versions }}
50+
51+
- name: Checkout app
52+
uses: actions/checkout@v3
53+
with:
54+
path: apps/${{ env.APP_NAME }}
55+
56+
- name: Set up php ${{ matrix.php-versions }}
57+
uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: ${{ matrix.php-versions }}
60+
tools: phpunit
61+
extensions: mbstring, iconv, fileinfo, intl, mysql, pdo_mysql
62+
coverage: none
63+
64+
- name: Set up PHPUnit
65+
working-directory: apps/${{ env.APP_NAME }}
66+
run: composer i
67+
68+
- name: Set up Nextcloud
69+
env:
70+
DB_PORT: 4444
71+
run: |
72+
mkdir data
73+
./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
74+
./occ app:enable ${{ env.APP_NAME }}
75+
76+
- name: Check PHPUnit config file existence
77+
id: check_phpunit
78+
uses: andstor/file-existence-action@v1
79+
with:
80+
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
81+
82+
- name: Run Nextcloud
83+
run: php -S localhost:8080 &
84+
85+
- name: PHPUnit
86+
# Only run if phpunit config file exists
87+
if: steps.check_phpunit.outputs.files_exists == 'true'
88+
working-directory: apps/${{ env.APP_NAME }}
89+
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
90+
91+
- name: Check PHPUnit integration config file existence
92+
id: check_integration
93+
uses: andstor/file-existence-action@v1
94+
with:
95+
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
96+
97+
- name: PHPUnit integration
98+
# Only run if phpunit integration config file exists
99+
if: steps.check_integration.outputs.files_exists == 'true'
100+
working-directory: apps/${{ env.APP_NAME }}
101+
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
102+
103+
summary:
104+
runs-on: ubuntu-latest
105+
needs: phpunit-mysql
106+
107+
if: always()
108+
109+
name: phpunit-mysql-summary
110+
111+
steps:
112+
- name: Summary status
113+
run: if ${{ needs.phpunit-mysql.result != 'success' }}; then exit 1; fi

.github/workflows/phpunit-oci.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: PHPUnit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- stable*
9+
10+
env:
11+
# Location of the phpunit.xml and phpunit.integration.xml files
12+
PHPUNIT_CONFIG: ./tests/phpunit.xml
13+
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
14+
15+
jobs:
16+
phpunit-oci:
17+
runs-on: ubuntu-20.04
18+
19+
strategy:
20+
matrix:
21+
php-versions: ['8.0']
22+
server-versions: ['master']
23+
24+
services:
25+
oracle:
26+
image: deepdiver/docker-oracle-xe-11g # 'wnameless/oracle-xe-11g-r2'
27+
ports:
28+
- 1521:1521/tcp
29+
30+
steps:
31+
- name: Set app env
32+
run: |
33+
# Split and keep last
34+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
35+
36+
- name: Checkout server
37+
uses: actions/checkout@v3
38+
with:
39+
submodules: true
40+
repository: nextcloud/server
41+
ref: ${{ matrix.server-versions }}
42+
43+
- name: Checkout app
44+
uses: actions/checkout@v3
45+
with:
46+
path: apps/${{ env.APP_NAME }}
47+
48+
- name: Set up php ${{ matrix.php-versions }}
49+
uses: shivammathur/setup-php@v2
50+
with:
51+
php-version: ${{ matrix.php-versions }}
52+
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, oci8
53+
tools: phpunit
54+
coverage: none
55+
56+
- name: Set up PHPUnit
57+
working-directory: apps/${{ env.APP_NAME }}
58+
run: composer i
59+
60+
- name: Set up Nextcloud
61+
env:
62+
DB_PORT: 1521
63+
run: |
64+
mkdir data
65+
./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
66+
./occ app:enable ${{ env.APP_NAME }}
67+
68+
- name: Check PHPUnit config file existence
69+
id: check_phpunit
70+
uses: andstor/file-existence-action@v1
71+
with:
72+
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
73+
74+
- name: PHPUnit
75+
# Only run if phpunit config file exists
76+
if: steps.check_phpunit.outputs.files_exists == 'true'
77+
working-directory: apps/${{ env.APP_NAME }}
78+
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
79+
80+
- name: Check PHPUnit integration config file existence
81+
id: check_integration
82+
uses: andstor/file-existence-action@v1
83+
with:
84+
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
85+
86+
- name: Run Nextcloud
87+
# Only run if phpunit integration config file exists
88+
if: steps.check_integration.outputs.files_exists == 'true'
89+
run: php -S localhost:8080 &
90+
91+
- name: PHPUnit integration
92+
# Only run if phpunit integration config file exists
93+
if: steps.check_integration.outputs.files_exists == 'true'
94+
working-directory: apps/${{ env.APP_NAME }}
95+
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
96+
97+
summary:
98+
runs-on: ubuntu-latest
99+
needs: phpunit-oci
100+
101+
if: always()
102+
103+
name: phpunit-oci-summary
104+
105+
steps:
106+
- name: Summary status
107+
run: if ${{ needs.phpunit-oci.result != 'success' }}; then exit 1; fi
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: PHPUnit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
- stable*
9+
10+
env:
11+
# Location of the phpunit.xml and phpunit.integration.xml files
12+
PHPUNIT_CONFIG: ./tests/phpunit.xml
13+
PHPUNIT_INTEGRATION_CONFIG: ./tests/phpunit.integration.xml
14+
15+
jobs:
16+
phpunit-pgsql:
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
php-versions: ['8.0']
22+
server-versions: ['master']
23+
24+
services:
25+
postgres:
26+
image: postgres
27+
ports:
28+
- 4444:5432/tcp
29+
env:
30+
POSTGRES_USER: root
31+
POSTGRES_PASSWORD: rootpassword
32+
POSTGRES_DB: nextcloud
33+
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
34+
35+
steps:
36+
- name: Set app env
37+
run: |
38+
# Split and keep last
39+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
40+
41+
- name: Checkout server
42+
uses: actions/checkout@v3
43+
with:
44+
submodules: true
45+
repository: nextcloud/server
46+
ref: ${{ matrix.server-versions }}
47+
48+
- name: Checkout app
49+
uses: actions/checkout@v3
50+
with:
51+
path: apps/${{ env.APP_NAME }}
52+
53+
- name: Set up php ${{ matrix.php-versions }}
54+
uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: ${{ matrix.php-versions }}
57+
tools: phpunit
58+
extensions: mbstring, iconv, fileinfo, intl, pgsql, pdo_pgsql
59+
coverage: none
60+
61+
- name: Set up PHPUnit
62+
working-directory: apps/${{ env.APP_NAME }}
63+
run: composer i
64+
65+
- name: Set up Nextcloud
66+
env:
67+
DB_PORT: 4444
68+
run: |
69+
mkdir data
70+
./occ maintenance:install --verbose --database=pgsql --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
71+
./occ app:enable ${{ env.APP_NAME }}
72+
73+
- name: Check PHPUnit config file existence
74+
id: check_phpunit
75+
uses: andstor/file-existence-action@v1
76+
with:
77+
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_CONFIG }}
78+
79+
- name: PHPUnit
80+
# Only run if phpunit config file exists
81+
if: steps.check_phpunit.outputs.files_exists == 'true'
82+
working-directory: apps/${{ env.APP_NAME }}
83+
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_CONFIG }}
84+
85+
- name: Check PHPUnit integration config file existence
86+
id: check_integration
87+
uses: andstor/file-existence-action@v1
88+
with:
89+
files: apps/${{ env.APP_NAME }}/${{ env.PHPUNIT_INTEGRATION_CONFIG }}
90+
91+
- name: Run Nextcloud
92+
# Only run if phpunit integration config file exists
93+
if: steps.check_integration.outputs.files_exists == 'true'
94+
run: php -S localhost:8080 &
95+
96+
- name: PHPUnit integration
97+
# Only run if phpunit integration config file exists
98+
if: steps.check_integration.outputs.files_exists == 'true'
99+
working-directory: apps/${{ env.APP_NAME }}
100+
run: ./vendor/phpunit/phpunit/phpunit -c ${{ env.PHPUNIT_INTEGRATION_CONFIG }}
101+
102+
summary:
103+
runs-on: ubuntu-latest
104+
needs: phpunit-pgsql
105+
106+
if: always()
107+
108+
name: phpunit-pgsql-summary
109+
110+
steps:
111+
- name: Summary status
112+
run: if ${{ needs.phpunit-pgsql.result != 'success' }}; then exit 1; fi

0 commit comments

Comments
 (0)