Skip to content

Commit f94af85

Browse files
authored
Merge pull request #23788 from nextcloud/techdebt/noid/only-run-phpunit-when-php-changed
Only run phpunit when "php" changed
2 parents 9b54a4a + 8a3d9e5 commit f94af85

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

.drone.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,17 @@ steps:
249249
- name: nodb-php7.3
250250
image: nextcloudci/php7.3:latest
251251
commands:
252+
- bash tests/drone-run-php-tests.sh || exit 0
252253
- NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
253254
- name: nodb-php7.4
254255
image: nextcloudci/php7.4:latest
255256
commands:
257+
- bash tests/drone-run-php-tests.sh || exit 0
256258
- NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
257259
#- name: nodb-php8.0
258260
# image: nextcloudci/php8.0:latest
259261
# commands:
262+
# - bash tests/drone-run-php-tests.sh || exit 0
260263
# - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite
261264

262265
services:
@@ -283,14 +286,17 @@ steps:
283286
- name: sqlite-php7.3
284287
image: nextcloudci/php7.3:latest
285288
commands:
289+
- bash tests/drone-run-php-tests.sh || exit 0
286290
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
287291
- name: sqlite-php7.4
288292
image: nextcloudci/php7.4:latest
289293
commands:
294+
- bash tests/drone-run-php-tests.sh || exit 0
290295
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
291296
#- name: sqlite-php8.0
292297
# image: nextcloudci/php8.0:latest
293298
# commands:
299+
# - bash tests/drone-run-php-tests.sh || exit 0
294300
# - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite
295301

296302
services:
@@ -317,6 +323,7 @@ steps:
317323
- name: mariadb10.1-php7.3
318324
image: nextcloudci/php7.3:latest
319325
commands:
326+
- bash tests/drone-run-php-tests.sh || exit 0
320327
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb
321328

322329
services:
@@ -352,6 +359,7 @@ steps:
352359
- name: mariadb10.2-php7.3
353360
image: nextcloudci/php7.3:latest
354361
commands:
362+
- bash tests/drone-run-php-tests.sh || exit 0
355363
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb
356364

357365
services:
@@ -386,6 +394,7 @@ steps:
386394
- name: mariadb10.3-php7.3
387395
image: nextcloudci/php7.3:latest
388396
commands:
397+
- bash tests/drone-run-php-tests.sh || exit 0
389398
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb
390399

391400
services:
@@ -421,10 +430,12 @@ steps:
421430
- name: mariadb10.4-php7.4
422431
image: nextcloudci/php7.4:latest
423432
commands:
433+
- bash tests/drone-run-php-tests.sh || exit 0
424434
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb
425435
#- name: mariadb10.4-php8.0
426436
# image: nextcloudci/php8.0:latest
427437
# commands:
438+
# - bash tests/drone-run-php-tests.sh || exit 0
428439
# - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb
429440

430441
services:
@@ -460,6 +471,7 @@ steps:
460471
- name: mysql-php7.4
461472
image: nextcloudci/php7.4:latest
462473
commands:
474+
- bash tests/drone-run-php-tests.sh || exit 0
463475
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql
464476

465477
services:
@@ -496,6 +508,7 @@ steps:
496508
- name: mysql-php7.4
497509
image: nextcloudci/php7.4:latest
498510
commands:
511+
- bash tests/drone-run-php-tests.sh || exit 0
499512
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql
500513

501514
services:
@@ -528,6 +541,7 @@ steps:
528541
- name: mysql-php7.3
529542
image: nextcloudci/php7.3:php7.3-4
530543
commands:
544+
- bash tests/drone-run-php-tests.sh || exit 0
531545
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql
532546

533547
services:
@@ -560,6 +574,7 @@ steps:
560574
- name: mysql5.6-php7.3
561575
image: nextcloudci/php7.3:latest
562576
commands:
577+
- bash tests/drone-run-php-tests.sh || exit 0
563578
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql
564579

565580
services:
@@ -594,6 +609,7 @@ steps:
594609
- name: postgres-php7.3
595610
image: nextcloudci/php7.3:php7.3-4
596611
commands:
612+
- bash tests/drone-run-php-tests.sh || exit 0
597613
- sleep 10 # gives the database enough time to initialize
598614
- POSTGRES=9 NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql
599615

@@ -629,6 +645,7 @@ steps:
629645
- name: postgres-php7.3
630646
image: nextcloudci/php7.3:latest
631647
commands:
648+
- bash tests/drone-run-php-tests.sh || exit 0
632649
- sleep 10 # gives the database enough time to initialize
633650
- POSTGRES=10 NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql
634651

@@ -663,6 +680,7 @@ steps:
663680
- name: postgres-php7.4
664681
image: nextcloudci/php7.4:latest
665682
commands:
683+
- bash tests/drone-run-php-tests.sh || exit 0
666684
- sleep 10 # gives the database enough time to initialize
667685
- POSTGRES=11 NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql
668686

@@ -699,10 +717,12 @@ steps:
699717
- name: mysqlmb4-php7.4
700718
image: nextcloudci/php7.4:latest
701719
commands:
720+
- bash tests/drone-run-php-tests.sh || exit 0
702721
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4
703722
#- name: mysqlmb4-php8.0
704723
# image: nextcloudci/php8.0:latest
705724
# commands:
725+
# - bash tests/drone-run-php-tests.sh || exit 0
706726
# - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4
707727

708728
services:
@@ -738,6 +758,7 @@ steps:
738758
- name: mysqlmb4-php7.3
739759
image: nextcloudci/php7.3:php7.3-4
740760
commands:
761+
- bash tests/drone-run-php-tests.sh || exit 0
741762
- NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4
742763

743764
services:

tests/drone-run-integration-tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ echo "========================="
88

99
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0
1010

11+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep ".json" | grep -v "package.json" | grep -c -v "package-lock.json") -gt 0 ]] && echo "JSON files are modified" && exit 0
12+
13+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".sh") -gt 0 ]] && echo "bash files are modified" && exit 0
14+
15+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".yml") -gt 0 ]] && echo "YML files are modified" && exit 0
16+
17+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0
18+
1119
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".php$") -gt 0 ]] && echo "PHP files are modified" && exit 0
1220

1321
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c "^build/integration/") -gt 0 ]] && echo "Integration test files are modified" && exit 0

tests/drone-run-php-tests.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
echo "========================="
4+
echo "= List of changed files ="
5+
echo "========================="
6+
git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA
7+
echo "========================="
8+
9+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0
10+
11+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep ".json" | grep -v "package.json" | grep -c -v "package-lock.json") -gt 0 ]] && echo "JSON files are modified" && exit 0
12+
13+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".sh") -gt 0 ]] && echo "bash files are modified" && exit 0
14+
15+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".yml") -gt 0 ]] && echo "YML files are modified" && exit 0
16+
17+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0
18+
19+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".php$") -gt 0 ]] && echo "PHP files are modified" && exit 0
20+
21+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c "^tests/") -gt 0 ]] && echo "PHP test files are modified" && exit 0
22+
23+
[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c "/tests/") -gt 0 ]] && echo "PHP test files of an app are modified" && exit 0
24+
25+
exit 1

0 commit comments

Comments
 (0)