]> source.dussan.org Git - nextcloud-server.git/commitdiff
chore(tests): Migrate code coverage generation from drone to GitHub
authorFerdinand Thiessen <opensource@fthiessen.de>
Fri, 20 Oct 2023 00:09:27 +0000 (02:09 +0200)
committerJoas Schilling <coding@schilljs.com>
Fri, 26 Jan 2024 13:53:29 +0000 (14:53 +0100)
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
.drone.yml
.github/workflows/phpunit-mariadb.yml
.github/workflows/phpunit-mysql.yml
.github/workflows/phpunit-nodb.yml [new file with mode: 0644]
.github/workflows/phpunit-pgsql.yml
.github/workflows/phpunit-sqlite.yml

index f4cab8f8bfe9bb8049216b57f86154c6cc1f20f7..06564ee90c7ef798851735b39163925f39580bb5 100644 (file)
@@ -216,70 +216,6 @@ trigger:
     - pull_request
     - push
 
----
-kind: pipeline
-name: nodb-codecov
-
-steps:
-- name: submodules
-  image: ghcr.io/nextcloud/continuous-integration-alpine-git:latest
-  commands:
-    - git submodule update --init
-- name: nodb-codecov
-  image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
-  environment:
-      CODECOV_TOKEN:
-          from_secret: CODECOV_TOKEN
-      XDEBUG_MODE: coverage
-  commands:
-    - phpenmod xdebug
-    - TEST_SELECTION=NODB ./autotest.sh sqlite
-    - wget https://codecov.io/bash -O codecov.sh
-    - bash codecov.sh -Z -C $DRONE_COMMIT -f tests/autotest-clover-sqlite.xml
-
-services:
-- name: cache
-  image: ghcr.io/nextcloud/continuous-integration-redis:latest
-
-trigger:
-  branch:
-    - master
-    - stable*
-  event:
-    - push
-
----
-kind: pipeline
-name: db-codecov
-
-steps:
-- name: submodules
-  image: ghcr.io/nextcloud/continuous-integration-alpine-git:latest
-  commands:
-    - git submodule update --init
-- name: db-codecov
-  image: ghcr.io/nextcloud/continuous-integration-php8.0:latest
-  environment:
-      CODECOV_TOKEN:
-          from_secret: CODECOV_TOKEN
-      XDEBUG_MODE: coverage
-  commands:
-    - phpenmod xdebug
-    - TEST_SELECTION=QUICKDB ./autotest.sh sqlite
-    - wget https://codecov.io/bash -O codecov.sh
-    - bash codecov.sh -Z -C $DRONE_COMMIT -f tests/autotest-clover-sqlite.xml
-
-services:
-- name: cache
-  image: ghcr.io/nextcloud/continuous-integration-redis:latest
-
-trigger:
-  branch:
-    - master
-    - stable*
-  event:
-    - push
-
 ---
 kind: pipeline
 name: object-store-s3
index 4ba37751d280f1bd580993854b31e0b99a0ab65d..cf213d1c1b457c2e5e03041786103328aa5d7351 100644 (file)
@@ -60,6 +60,7 @@ jobs:
         include:
           - php-versions: '8.3'
             mariadb-versions: '10.6'
+            coverage: true
 
     name: MariaDB ${{ matrix.mariadb-versions }} (PHP ${{ matrix.php-versions }}) - database tests
 
@@ -93,7 +94,7 @@ jobs:
           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, mysql, pdo_mysql
-          coverage: none
+          coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
           ini-file: development
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -101,19 +102,12 @@ jobs:
       - name: Set up dependencies
         run: composer i
 
-      - name: Wait for MariaDB
-        id: check_mariadb_up
-        run: |
-          apps/files_external/tests/env/wait-for-connection localhost 4444 30
-
       - name: Enable ONLY_FULL_GROUP_BY MySQL option
-        if: steps.check_mariadb_up.outcome == 'success'
         run: |
           echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
           echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
 
       - name: Set up Nextcloud
-        if: steps.check_mariadb_up.outcome == 'success'
         env:
           DB_PORT: 4444
         run: |
@@ -124,8 +118,14 @@ jobs:
           php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
 
       - name: PHPUnit
-        if: steps.check_mariadb_up.outcome == 'success'
-        run: composer run test:db
+        run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
+
+      - name: Upload db code coverage
+        if: ${{ !cancelled() && matrix.coverage }}
+        uses: codecov/codecov-action@v3
+        with:
+          files: ./clover.db.xml
+          flags: phpunit-mariadb
 
       - name: Print logs
         if: always()
index c9f5b103dd9621d72358b2c89a75c47163393d98..1c4795136034134de47c81be8148110a3c4adc6d 100644 (file)
@@ -58,8 +58,9 @@ jobs:
         php-versions: ['8.0']
         mysql-versions: ['8.0', '8.1']
         include:
-          - php-versions: '8.3'
-            mysql-versions: '8.1'
+          - mysql-versions: '8.1'
+            php-versions: '8.3'
+            coverage: true
 
     name: MySQL ${{ matrix.mysql-versions }} (PHP ${{ matrix.php-versions }}) - database tests
 
@@ -93,7 +94,7 @@ jobs:
           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, mysql, pdo_mysql
-          coverage: none
+          coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
           ini-file: development
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -101,19 +102,12 @@ jobs:
       - name: Set up dependencies
         run: composer i
 
-      - name: Wait for MySQL
-        id: check_mysql_up
-        run: |
-          apps/files_external/tests/env/wait-for-connection localhost 4444 30
-
       - name: Enable ONLY_FULL_GROUP_BY MySQL option
-        if: steps.check_mysql_up.outcome == 'success'
         run: |
           echo "SET GLOBAL sql_mode=(SELECT CONCAT(@@sql_mode,',ONLY_FULL_GROUP_BY'));" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
           echo "SELECT @@sql_mode;" | mysql -h 127.0.0.1 -P 4444 -u root -prootpassword
 
       - name: Set up Nextcloud
-        if: steps.check_mysql_up.outcome == 'success'
         env:
           DB_PORT: 4444
         run: |
@@ -124,8 +118,14 @@ jobs:
           php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
 
       - name: PHPUnit
-        if: steps.check_mysql_up.outcome == 'success'
-        run: composer run test:db
+        run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
+
+      - name: Upload db code coverage
+        if: ${{ !cancelled() && matrix.coverage }}
+        uses: codecov/codecov-action@v3
+        with:
+          files: ./clover.db.xml
+          flags: phpunit-mysql
 
       - name: Print logs
         if: always()
diff --git a/.github/workflows/phpunit-nodb.yml b/.github/workflows/phpunit-nodb.yml
new file mode 100644 (file)
index 0000000..b9dea3c
--- /dev/null
@@ -0,0 +1,130 @@
+# This workflow is provided via the organization template repository
+#
+# https://github.com/nextcloud/.github
+# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
+
+# This is the testsuite running all non-database agnostic unit tests
+name: PHPUnit nodb
+
+on:
+  pull_request:
+  push:
+    branches:
+      - main
+      - master
+      - stable*
+
+permissions:
+  contents: read
+
+concurrency:
+  group: phpunit-nodb-${{ 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/**'
+              - '**/appinfo/**'
+              - '**/lib/**'
+              - '**/templates/**'
+              - '**/tests/**'
+              - 'vendor/**'
+              - 'vendor-bin/**'
+              - '.php-cs-fixer.dist.php'
+              - 'composer.json'
+              - 'composer.lock'
+              - '**.php'
+
+  phpunit-nodb:
+    runs-on: ubuntu-latest
+
+    needs: changes
+    if: needs.changes.outputs.src != 'false'
+
+    strategy:
+      matrix:
+        php-versions: ['8.0', '8.1', '8.2', '8.3']
+        include:
+          - php-versions: '8.2'
+            coverage: true
+
+    name: No DB unit tests (PHP ${{ matrix.php-versions }})
+
+    services:
+      cache:
+        image: ghcr.io/nextcloud/continuous-integration-redis:latest
+        ports:
+          - 6379:6379/tcp
+        options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
+
+    steps:
+      - name: Checkout server
+        uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608
+        with:
+          submodules: true
+
+      - name: Set up php ${{ matrix.php-versions }}
+        uses: shivammathur/setup-php@7fdd3ece872ec7ec4c098ae5ab7637d5e0a96067 # 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, imagick, 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
+          # Required for tests that use pcntl
+          ini-values: disable_functions=""
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Set up dependencies
+        run: composer i
+
+      - name: Set up Nextcloud
+        run: |
+          mkdir data
+          cp tests/redis.config.php config/
+          cp tests/preseed-config.php config/config.php
+          ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
+          php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
+
+      - name: PHPUnit nodb testsuite
+        run: composer run test -- --exclude-group DB,SLOWDB ${{ matrix.coverage && ' --coverage-clover ./clover.nodb.xml' || '' }}
+
+      - name: Upload nodb code coverage
+        if: ${{ !cancelled() && matrix.coverage }}
+        uses: codecov/codecov-action@v3
+        with:
+          files: ./clover.nodb.xml
+          flags: phpunit-nodb
+
+      - name: Print logs
+        if: always()
+        run: |
+          cat data/nextcloud.log
+
+  summary:
+    permissions:
+      contents: none
+    runs-on: ubuntu-latest
+    needs: [changes, phpunit-nodb]
+
+    if: always()
+
+    name: phpunit-nodb-summary
+
+    steps:
+      - name: Summary status
+        run: if ${{ needs.changes.outputs.src != 'false' && needs.phpunit-nodb.result != 'success' }}; then exit 1; fi
index bebf8a092826bd7b390683227df0797c32db1008..ddcd20ed51ccdba7832f6ab9177f891c5a38c06e 100644 (file)
@@ -61,6 +61,7 @@ jobs:
         include:
           - php-versions: '8.3'
             postgres-versions: '15'
+            coverage: true
 
     name: PostgreSQL ${{ matrix.postgres-versions }} (PHP ${{ matrix.php-versions }}) - database tests
 
@@ -93,7 +94,7 @@ jobs:
           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, pgsql, pdo_pgsql
-          coverage: none
+          coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
           ini-file: development
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -101,13 +102,7 @@ jobs:
       - name: Set up dependencies
         run: composer i
 
-      - name: Wait for pgsql
-        id: check_pgsql_up
-        run: |
-          apps/files_external/tests/env/wait-for-connection localhost 4444 30
-
       - name: Set up Nextcloud
-        if: steps.check_pgsql_up.outcome == 'success'
         env:
           DB_PORT: 4444
         run: |
@@ -117,12 +112,17 @@ jobs:
           ./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 admin
           php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
 
-      - name: PHPUnit
-        if: steps.check_pgsql_up.outcome == 'success'
-        run: composer run test:db
+      - name: PHPUnit database tests
+        run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
+  
+      - name: Upload db code coverage
+        if: ${{ !cancelled() && matrix.coverage }}
+        uses: codecov/codecov-action@v3
+        with:
+          files: ./clover.db.xml
+          flags: phpunit-postgres
 
       - name: Run repair steps
-        if: steps.check_pgsql_up.outcome == 'success'
         run: |
           ./occ maintenance:repair --include-expensive
 
index afdb0beaa56eb8210ee788a052e68caa12d81b5b..61710f31b6fcd06dd3e15f4bbfc0bb60adfc06af 100644 (file)
@@ -56,12 +56,11 @@ jobs:
     strategy:
       matrix:
         php-versions: ['8.0', '8.1', '8.2', '8.3']
-        database-only: [true]
         include:
-          - php-versions: '8.2'
-            database-only: false
+          - php-versions: '8.1'
+            coverage: true
 
-    name: SQLite (PHP ${{ matrix.php-versions }}) - ${{ matrix.database-only && 'database' || 'all' }} tests
+    name: SQLite (PHP ${{ matrix.php-versions }})
 
     services:
       cache:
@@ -77,12 +76,12 @@ jobs:
           submodules: true
 
       - name: Set up php ${{ matrix.php-versions }}
-        uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2
+        uses: shivammathur/setup-php@7fdd3ece872ec7ec4c098ae5ab7637d5e0a96067 # 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 ${{ matrix.database-only && '' || ', imagick' }}
-          coverage: none
+          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 }}
@@ -98,13 +97,18 @@ jobs:
           ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
           php -f tests/enable_all.php | grep -i -C9999 error && echo "Error during app setup" && exit 1 || exit 0
 
+      - name: Nextcloud debug information
+        run: ./occ app:list && echo "======= System config =======" && ./occ config:list system
+
       - name: PHPUnit database tests
-        if: ${{ matrix.database-only }}
-        run: composer run test:db
+        run: composer run test:db ${{ matrix.coverage && ' -- --coverage-clover ./clover.db.xml' || '' }}
 
-      - name: PHPUnit full testsuite
-        if: ${{ ! matrix.database-only }}
-        run: composer run test
+      - name: Upload db code coverage
+        if: ${{ !cancelled() && matrix.coverage }}
+        uses: codecov/codecov-action@v3
+        with:
+          files: ./clover.db.xml
+          flags: phpunit-sqlite
 
       - name: Print logs
         if: always()