From: Ferdinand Thiessen Date: Fri, 20 Oct 2023 00:09:27 +0000 (+0200) Subject: chore(tests): Migrate code coverage generation from drone to GitHub X-Git-Tag: v29.0.0beta1~371^2~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8a682328047bd9201f0b868b11f077786e239eee;p=nextcloud-server.git chore(tests): Migrate code coverage generation from drone to GitHub Signed-off-by: Ferdinand Thiessen --- diff --git a/.drone.yml b/.drone.yml index f4cab8f8bfe..06564ee90c7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 diff --git a/.github/workflows/phpunit-mariadb.yml b/.github/workflows/phpunit-mariadb.yml index 4ba37751d28..cf213d1c1b4 100644 --- a/.github/workflows/phpunit-mariadb.yml +++ b/.github/workflows/phpunit-mariadb.yml @@ -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() diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml index c9f5b103dd9..1c479513603 100644 --- a/.github/workflows/phpunit-mysql.yml +++ b/.github/workflows/phpunit-mysql.yml @@ -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 index 00000000000..b9dea3c28ee --- /dev/null +++ b/.github/workflows/phpunit-nodb.yml @@ -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 diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml index bebf8a09282..ddcd20ed51c 100644 --- a/.github/workflows/phpunit-pgsql.yml +++ b/.github/workflows/phpunit-pgsql.yml @@ -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 diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index afdb0beaa56..61710f31b6f 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -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()