From 53c18b8c2638d8a85c44af41082d21f58e5bfc31 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 30 Oct 2020 09:46:53 +0100 Subject: [PATCH 1/4] Only run phpunit when php, xml or test files are modified Signed-off-by: Joas Schilling --- .drone.yml | 17 +++++++++++++++++ tests/drone-run-integration-tests.sh | 2 ++ tests/drone-run-php-tests.sh | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100755 tests/drone-run-php-tests.sh diff --git a/.drone.yml b/.drone.yml index c6edf453c0..0b4fdf851f 100644 --- a/.drone.yml +++ b/.drone.yml @@ -253,10 +253,12 @@ steps: - name: nodb-php7.3 image: nextcloudci/php7.3:latest commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite - name: nodb-php7.4 image: nextcloudci/php7.4:latest commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite services: @@ -287,10 +289,12 @@ steps: - name: sqlite-php7.3 image: nextcloudci/php7.3:php7.3-4 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite - name: sqlite-php7.4 image: nextcloudci/php7.4:2 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite services: @@ -317,6 +321,7 @@ steps: - name: mariadb10.1-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb services: @@ -352,6 +357,7 @@ steps: - name: mariadb10.2-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb services: @@ -386,6 +392,7 @@ steps: - name: mariadb10.3-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb services: @@ -420,6 +427,7 @@ steps: - name: mariadb10.4-php7.3 image: nextcloudci/php7.3:php7.3-4 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mariadb services: @@ -455,6 +463,7 @@ steps: - name: mysql-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql services: @@ -491,6 +500,7 @@ steps: - name: mysql-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql services: @@ -523,6 +533,7 @@ steps: - name: mysql-php7.3 image: nextcloudci/php7.3:php7.3-4 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql services: @@ -555,6 +566,7 @@ steps: - name: mysql5.6-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysql services: @@ -589,6 +601,7 @@ steps: - name: postgres-php7.3 image: nextcloudci/php7.3:php7.3-4 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - sleep 10 # gives the database enough time to initialize - POSTGRES=9 NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql @@ -624,6 +637,7 @@ steps: - name: postgres-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - sleep 10 # gives the database enough time to initialize - POSTGRES=10 NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql @@ -658,6 +672,7 @@ steps: - name: postgres-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - sleep 10 # gives the database enough time to initialize - POSTGRES=11 NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh pgsql @@ -693,6 +708,7 @@ steps: - name: mysqlmb4-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4 services: @@ -728,6 +744,7 @@ steps: - name: mysqlmb4-php7.3 image: nextcloudci/php7.3:php7.3-4 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh mysqlmb4 services: diff --git a/tests/drone-run-integration-tests.sh b/tests/drone-run-integration-tests.sh index 9da224ccba..605e1eb356 100755 --- a/tests/drone-run-integration-tests.sh +++ b/tests/drone-run-integration-tests.sh @@ -8,6 +8,8 @@ echo "=========================" [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0 +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0 + [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".php$") -gt 0 ]] && echo "PHP files are modified" && exit 0 [[ $(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 diff --git a/tests/drone-run-php-tests.sh b/tests/drone-run-php-tests.sh new file mode 100755 index 0000000000..9552141adc --- /dev/null +++ b/tests/drone-run-php-tests.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +echo "=========================" +echo "= List of changed files =" +echo "=========================" +git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA +echo "=========================" + +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0 + +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0 + +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".php$") -gt 0 ]] && echo "PHP files are modified" && exit 0 + +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c "^tests/") -gt 0 ]] && echo "PHP test files are modified" && exit 0 + +[[ $(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 + +exit 1 From 0a7fef627229f83296ab67e1ae9ac74399957ab8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 30 Oct 2020 09:47:27 +0100 Subject: [PATCH 2/4] Also run all tests when drone config is modified Signed-off-by: Joas Schilling --- tests/drone-run-integration-tests.sh | 2 ++ tests/drone-run-php-tests.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/drone-run-integration-tests.sh b/tests/drone-run-integration-tests.sh index 605e1eb356..9b610d0172 100755 --- a/tests/drone-run-integration-tests.sh +++ b/tests/drone-run-integration-tests.sh @@ -8,6 +8,8 @@ echo "=========================" [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0 +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".yml") -gt 0 ]] && echo "YML files are modified" && exit 0 + [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0 [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".php$") -gt 0 ]] && echo "PHP files are modified" && exit 0 diff --git a/tests/drone-run-php-tests.sh b/tests/drone-run-php-tests.sh index 9552141adc..0a215f7bf3 100755 --- a/tests/drone-run-php-tests.sh +++ b/tests/drone-run-php-tests.sh @@ -8,6 +8,8 @@ echo "=========================" [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0 +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".yml") -gt 0 ]] && echo "YML files are modified" && exit 0 + [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0 [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".php$") -gt 0 ]] && echo "PHP files are modified" && exit 0 From 3f5d275e6d1780d5d5055ee46e969d73a3849bb8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 30 Oct 2020 10:30:50 +0100 Subject: [PATCH 3/4] Also run for .sh and .json (when not package or package-lock) Signed-off-by: Joas Schilling --- tests/drone-run-integration-tests.sh | 4 ++++ tests/drone-run-php-tests.sh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/tests/drone-run-integration-tests.sh b/tests/drone-run-integration-tests.sh index 9b610d0172..af3c7a895c 100755 --- a/tests/drone-run-integration-tests.sh +++ b/tests/drone-run-integration-tests.sh @@ -8,6 +8,10 @@ echo "=========================" [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0 +[[ $(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 + +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".sh") -gt 0 ]] && echo "bash files are modified" && exit 0 + [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".yml") -gt 0 ]] && echo "YML files are modified" && exit 0 [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0 diff --git a/tests/drone-run-php-tests.sh b/tests/drone-run-php-tests.sh index 0a215f7bf3..c51117a21d 100755 --- a/tests/drone-run-php-tests.sh +++ b/tests/drone-run-php-tests.sh @@ -8,6 +8,10 @@ echo "=========================" [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | wc -l) -eq 0 ]] && echo "No files are modified => merge commit" && exit 0 +[[ $(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 + +[[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".sh") -gt 0 ]] && echo "bash files are modified" && exit 0 + [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".yml") -gt 0 ]] && echo "YML files are modified" && exit 0 [[ $(git diff --name-only origin/$DRONE_TARGET_BRANCH...$DRONE_COMMIT_SHA | grep -c ".xml") -gt 0 ]] && echo "info.xml files are modified" && exit 0 From 7bf32677b8ee23c593a29a27ffc716ef60568d61 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 30 Oct 2020 13:35:42 +0100 Subject: [PATCH 4/4] Add script to old versions Signed-off-by: Morris Jobke --- .drone.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.yml b/.drone.yml index 0b4fdf851f..4adb9ac621 100644 --- a/.drone.yml +++ b/.drone.yml @@ -249,6 +249,7 @@ steps: - name: nodb-php7.2 image: nextcloudci/php7.2:latest commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=NODB ./autotest.sh sqlite - name: nodb-php7.3 image: nextcloudci/php7.3:latest @@ -285,6 +286,7 @@ steps: - name: sqlite-php7.2 image: nextcloudci/php7.2:php7.2-13 commands: + - bash tests/drone-run-php-tests.sh || exit 0 - NOCOVERAGE=true TEST_SELECTION=DB ./autotest.sh sqlite - name: sqlite-php7.3 image: nextcloudci/php7.3:php7.3-4