From f9ed7956084e1dee27cad2357ef9cfaac2e9d798 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 30 Jan 2024 19:46:32 +0100 Subject: [PATCH 1/4] chore(ci): Migrate files-external webdav tests to GitHub Signed-off-by: Ferdinand Thiessen --- .drone.yml | 31 ----- .github/workflows/files-external-webdav.yml | 106 ++++++++++++++++++ .../tests/env/start-webdav-apachedrone.sh | 26 ----- .../tests/env/stop-webdav-apachedrone.sh | 14 --- 4 files changed, 106 insertions(+), 71 deletions(-) create mode 100644 .github/workflows/files-external-webdav.yml delete mode 100755 apps/files_external/tests/env/start-webdav-apachedrone.sh delete mode 100755 apps/files_external/tests/env/stop-webdav-apachedrone.sh diff --git a/.drone.yml b/.drone.yml index 1e0a0c55e87d0..769d692cbfca5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -184,37 +184,6 @@ trigger: - pull_request - push ---- -kind: pipeline -name: sqlite-php8.0-webdav-apache - -steps: -- name: submodules - image: ghcr.io/nextcloud/continuous-integration-alpine-git:latest - commands: - - git submodule update --init -- name: sqlite-php8.0-webdav-apache - image: ghcr.io/nextcloud/continuous-integration-webdav-apache-php8.0:latest - commands: - - apache2ctl start - - ./autotest-external.sh sqlite webdav-apachedrone - - wget https://codecov.io/bash -O codecov.sh - - sh -c "if [ '$DRONE_BUILD_EVENT' = 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -P $DRONE_PULL_REQUEST -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-external-clover-sqlite.xml; fi" - - sh -c "if [ '$DRONE_BUILD_EVENT' != 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-external-clover-sqlite.xml; fi" - - sh -c "if [ '$DRONE_BUILD_EVENT' = 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -P $DRONE_PULL_REQUEST -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-external-clover-sqlite-webdav-apachedrone.xml; fi" - - sh -c "if [ '$DRONE_BUILD_EVENT' != 'pull_request' ]; then bash codecov.sh -B $DRONE_BRANCH -C $DRONE_COMMIT -t 117641e2-a9e8-4b7b-984b-ae872d9b05f5 -f tests/autotest-external-clover-sqlite-webdav-apachedrone.xml; fi" - -services: -- name: cache - image: ghcr.io/nextcloud/continuous-integration-redis:latest - -trigger: - branch: - - master - - stable* - event: - - pull_request - - push --- kind: signature diff --git a/.github/workflows/files-external-webdav.yml b/.github/workflows/files-external-webdav.yml new file mode 100644 index 0000000000000..10fe68f68fe9a --- /dev/null +++ b/.github/workflows/files-external-webdav.yml @@ -0,0 +1,106 @@ +name: PHPUnit files_external WebDAV +on: + pull_request: + schedule: + - cron: "5 2 * * *" + +concurrency: + group: files-external-webdav-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + changes: + runs-on: ubuntu-latest + + outputs: + src: ${{ steps.changes.outputs.src}} + + steps: + - uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 + id: changes + continue-on-error: true + with: + filters: | + src: + - '.github/workflows/**' + - '3rdparty/**' + - 'apps/files_external/**' + - 'vendor/**' + - 'vendor-bin/**' + - '.php-cs-fixer.dist.php' + - 'composer.json' + - 'composer.lock' + - '**.php' + + files-external-webdav-apache: + runs-on: ubuntu-latest + needs: changes + + if: ${{ github.repository_owner != 'nextcloud-gmbh' && needs.changes.outputs.src != 'false' }} + + strategy: + matrix: + php-versions: ['8.0', '8.1', '8.2', '8.3'] + include: + - php-versions: '8.3' + coverage: true + + name: php${{ matrix.php-versions }}-webdav + + services: + apache: + image: ghcr.io/nextcloud/continuous-integration-webdav-apache:latest + ports: + - 8081:80 + + steps: + - name: Checkout server + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + with: + submodules: true + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2 + with: + php-version: ${{ matrix.php-versions }} + # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation + extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, redis, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite + coverage: ${{ matrix.coverage && 'xdebug' || 'none' }} + ini-file: development + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Nextcloud + run: | + composer install + ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password + ./occ config:system:set --value true --type boolean allow_local_remote_servers + ./occ app:enable --force files_external + echo " true, 'host' => 'localhost:8081/webdav/', 'user' => 'test', 'password'=>'pass', 'root' => '', 'wait' => 0];" > apps/files_external/tests/config.webdav.php + + - name: Wait for WebDAV + run: | + sleep 5 + curl -f -m 1 --retry-connrefused --retry 10 --retry-delay 10 http://test:pass@localhost:8081/webdav/ + + - name: PHPUnit + run: composer run test:files_external -- --verbose \ + apps/files_external/tests/Storage/WebdavTest.php \ + ${{ matrix.coverage && ' --coverage-clover ./clover.xml' || '' }} + + - name: Upload code coverage + if: ${{ !cancelled() && matrix.coverage }} + uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5 + with: + files: ./clover.xml + flags: phpunit-files-external-webdav + + files-external-webdav-summary: + runs-on: ubuntu-latest + needs: [changes, files-external-webdav-apache] + + if: always() + + steps: + - name: Summary status + run: if ${{ needs.changes.outputs.src != 'false' && needs.files-external-webdav-apache.result != 'success' }}; then exit 1; fi diff --git a/apps/files_external/tests/env/start-webdav-apachedrone.sh b/apps/files_external/tests/env/start-webdav-apachedrone.sh deleted file mode 100755 index 9887cea5eeede..0000000000000 --- a/apps/files_external/tests/env/start-webdav-apachedrone.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash -# -# Nextcloud -# - -# retrieve current folder to place the config in the parent folder -thisFolder=`echo $0 | sed 's#env/start-webdav-apachedrone\.sh##'` - -if [ -z "$thisFolder" ]; then - thisFolder="." -fi; - -cat > $thisFolder/config.webdav.php <true, - 'host'=>'127.0.0.1:80/webdav/', - 'user'=>'test', - 'password'=>'pass', - 'root'=>'', - 'wait'=> 0 -); - -DELIM - diff --git a/apps/files_external/tests/env/stop-webdav-apachedrone.sh b/apps/files_external/tests/env/stop-webdav-apachedrone.sh deleted file mode 100755 index 3c4b0492dd0cd..0000000000000 --- a/apps/files_external/tests/env/stop-webdav-apachedrone.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# -# Nextcloud - -# retrieve current folder to remove the config from the parent folder -thisFolder=`echo $0 | sed 's#env/stop-webdav-apachedrone\.sh##'` - -if [ -z "$thisFolder" ]; then - thisFolder="." -fi; - -# cleanup -rm $thisFolder/config.webdav.php - From 4b6bd8b0c56c4db24582fa965acec054fa38e3bf Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 1 Feb 2024 13:01:11 +0100 Subject: [PATCH 2/4] fix(tests): Adjust `files_external` tests to also work locally with WebDAV Signed-off-by: Ferdinand Thiessen --- .../files_external/tests/env/start-webdav-apache.sh | 8 ++++---- autotest-external.sh | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/files_external/tests/env/start-webdav-apache.sh b/apps/files_external/tests/env/start-webdav-apache.sh index a5464c9cfabf3..c58225d89b057 100755 --- a/apps/files_external/tests/env/start-webdav-apache.sh +++ b/apps/files_external/tests/env/start-webdav-apache.sh @@ -23,8 +23,8 @@ fi echo "Docker executable found - setup docker" -echo "Fetch recent morrisjobke/webdav docker image" -docker pull morrisjobke/webdav +echo "Fetch recent webdav docker image" +docker pull ghcr.io/nextcloud/continuous-integration-webdav-apache:latest # retrieve current folder to place the config in the parent folder thisFolder=`echo $0 | sed 's#env/start-webdav-apache\.sh##'` @@ -45,7 +45,7 @@ if [ -n "$RUN_DOCKER_MYSQL" ]; then parameter="--link $containerName:db" fi -container=`docker run -P $parameter -d -e USERNAME=test -e PASSWORD=test morrisjobke/webdav` +container=`docker run -P $parameter -d --rm ghcr.io/nextcloud/continuous-integration-webdav-apache:latest` host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` echo -n "Waiting for Apache initialization on ${host}:${port}" @@ -64,7 +64,7 @@ return array( 'run'=>true, 'host'=>'${host}:80/webdav/', 'user'=>'test', - 'password'=>'test', + 'password'=>'pass', 'root'=>'', // wait delay in seconds after write operations // (only in tests) diff --git a/autotest-external.sh b/autotest-external.sh index bc40e2474cd1c..ca5e2c2fa0b93 100755 --- a/autotest-external.sh +++ b/autotest-external.sh @@ -31,16 +31,21 @@ function print_syntax { } if ! [ -x "$PHPUNIT" ]; then - echo "phpunit executable not found, please install phpunit version >= 4.8" >&2 - exit 3 + echo "phpunit executable not found, trying local one from build/integration" >&2 + if [ -x "$PWD/build/integration/vendor/phpunit/phpunit/phpunit" ]; then + PHPUNIT="$PWD/build/integration/vendor/phpunit/phpunit/phpunit" + else + echo "phpunit executable not found, please install phpunit version >= 9.6" >&2 + exit 3 + fi fi PHPUNIT_VERSION=$("$PHPUNIT" --version | cut -d" " -f2) PHPUNIT_MAJOR_VERSION=$(echo $PHPUNIT_VERSION | cut -d"." -f1) PHPUNIT_MINOR_VERSION=$(echo $PHPUNIT_VERSION | cut -d"." -f2) -if ! [ $PHPUNIT_MAJOR_VERSION -gt 9 -o \( $PHPUNIT_MAJOR_VERSION -eq 9 -a $PHPUNIT_MINOR_VERSION -ge 0 \) ]; then - echo "phpunit version >= 9.0 required. Version found: $PHPUNIT_VERSION" >&2 +if ! [ $PHPUNIT_MAJOR_VERSION -gt 9 -o \( $PHPUNIT_MAJOR_VERSION -eq 9 -a $PHPUNIT_MINOR_VERSION -ge 6 \) ]; then + echo "phpunit version >= 9.6 required. Version found: $PHPUNIT_VERSION" >&2 exit 4 fi From c56d792491cca76ec41280c8b95bd7eebe63c67c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 1 Feb 2024 13:28:24 +0100 Subject: [PATCH 3/4] Sign drone.yml Signed-off-by: Joas Schilling --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 769d692cbfca5..e6d18071d1c97 100644 --- a/.drone.yml +++ b/.drone.yml @@ -187,4 +187,4 @@ trigger: --- kind: signature -hmac: c0e95a282303de842a645a780b391964eb839e4cb11446e4cc9a19ef1a661383 +hmac: a4f9a3fec27fbd14dfb478902b7b5cbc155916a309f05fe6eb78961b3db18c3a From f546a2fe14434f63685ad5db7c9b807cc865c550 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 1 Feb 2024 13:57:51 +0100 Subject: [PATCH 4/4] fix(ci): Disable coverage on pull requests Co-authored-by: Ferdinand Thiessen Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Signed-off-by: Ferdinand Thiessen --- .github/workflows/files-external-s3.yml | 4 ++-- .github/workflows/files-external-webdav.yml | 4 ++-- autotest-external.sh | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/files-external-s3.yml b/.github/workflows/files-external-s3.yml index 2aa1fa37a56c4..7efdde88da8b3 100644 --- a/.github/workflows/files-external-s3.yml +++ b/.github/workflows/files-external-s3.yml @@ -42,8 +42,8 @@ jobs: matrix: php-versions: ['8.0', '8.1', '8.2', '8.3'] include: - - php-versions: '8.3' - coverage: true + - php-versions: '8.2' + coverage: ${{ github.event_name != 'pull_request' }} name: php${{ matrix.php-versions }}-s3 diff --git a/.github/workflows/files-external-webdav.yml b/.github/workflows/files-external-webdav.yml index 10fe68f68fe9a..46d1226a83c61 100644 --- a/.github/workflows/files-external-webdav.yml +++ b/.github/workflows/files-external-webdav.yml @@ -42,8 +42,8 @@ jobs: matrix: php-versions: ['8.0', '8.1', '8.2', '8.3'] include: - - php-versions: '8.3' - coverage: true + - php-versions: '8.2' + coverage: ${{ github.event_name != 'pull_request' }} name: php${{ matrix.php-versions }}-webdav diff --git a/autotest-external.sh b/autotest-external.sh index ca5e2c2fa0b93..fb768b2663694 100755 --- a/autotest-external.sh +++ b/autotest-external.sh @@ -35,7 +35,7 @@ if ! [ -x "$PHPUNIT" ]; then if [ -x "$PWD/build/integration/vendor/phpunit/phpunit/phpunit" ]; then PHPUNIT="$PWD/build/integration/vendor/phpunit/phpunit/phpunit" else - echo "phpunit executable not found, please install phpunit version >= 9.6" >&2 + echo "phpunit executable not found, please install phpunit version >= 9.0" >&2 exit 3 fi fi @@ -44,8 +44,8 @@ PHPUNIT_VERSION=$("$PHPUNIT" --version | cut -d" " -f2) PHPUNIT_MAJOR_VERSION=$(echo $PHPUNIT_VERSION | cut -d"." -f1) PHPUNIT_MINOR_VERSION=$(echo $PHPUNIT_VERSION | cut -d"." -f2) -if ! [ $PHPUNIT_MAJOR_VERSION -gt 9 -o \( $PHPUNIT_MAJOR_VERSION -eq 9 -a $PHPUNIT_MINOR_VERSION -ge 6 \) ]; then - echo "phpunit version >= 9.6 required. Version found: $PHPUNIT_VERSION" >&2 +if ! [ $PHPUNIT_MAJOR_VERSION -gt 9 -o \( $PHPUNIT_MAJOR_VERSION -eq 9 -a $PHPUNIT_MINOR_VERSION -ge 0 \) ]; then + echo "phpunit version >= 9.0 required. Version found: $PHPUNIT_VERSION" >&2 exit 4 fi