Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update testing workflow #4187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 0 additions & 235 deletions .github/workflows/phpunit.yml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT
name: Test
on: pull_request

permissions:
contents: read

env:
APP_NAME: contacts

jobs:
backend-unit-tests:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.1', '8.2', '8.3']
nextcloud-versions: ['master', 'stable30']
include:
- php-versions: '8.4'
nextcloud-versions: 'master'
name: php${{ matrix.php-versions }} branch ${{ matrix.nextcloud-versions }} unit tests

steps:
- name: Set up Nextcloud env
uses: ChristophWurst/setup-nextcloud@fc0790385c175d97e88a7cb0933490de6e990374 # v0.3.2
with:
nextcloud-version: ${{ matrix.nextcloud-versions }}
php-version: ${{ matrix.php-versions }}
php-coverage: 'xdebug'
patch-php-version-check: ${{ matrix.php-versions == '8.4' }}
node-version: 'false'
install: true

- name: Checkout App
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
path: nextcloud/apps/${{ env.APP_NAME }}

- name: Install dependencies
working-directory: nextcloud/apps/${{ env.APP_NAME }}
run: composer install

- name: Run tests
working-directory: nextcloud/apps/${{ env.APP_NAME }}
run: composer run test:unit
if: ${{ matrix.php-versions == '8.3' }}
env:
XDEBUG_MODE: coverage

- name: Run tests
working-directory: nextcloud/apps/${{ env.APP_NAME }}
run: composer run test:unit
if: ${{ matrix.php-versions != '8.3' }}
env:
XDEBUG_MODE: off

- name: Upload coverage to Codecov
if: ${{ matrix.php-versions != '8.3' }}
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: nextcloud/apps/${{ env.APP_NAME }}/clover.unit.xml
flags: php
fail_ci_if_error: ${{ !github.event.pull_request.head.repo.fork }}
verbose: true

summary:
runs-on: ubuntu-latest
needs:
- backend-unit-tests

if: always()

name: php-test-summary

steps:
- name: Unit test status
run: if ${{ needs.backend-unit-tests.result != 'success' && needs.backend-unit-tests.result != 'skipped' }}; then exit 1; fi
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
comment: false
ignore:
- "tests"
- "lib/Vendor"
37 changes: 15 additions & 22 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<!--
- SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<phpunit bootstrap="tests/bootstrap.php"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
verbose="true"
convertDeprecationsToExceptions="true"
colors="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
timeoutForLargeTests="900">
<testsuite name='Contacts app tests'>
<directory>./tests/unit</directory>
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd">
<testsuite name="unit">
<directory suffix="Test.php">./tests/unit</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">./</directory>
<exclude>
<directory suffix=".php">./l10n</directory>
<directory suffix=".php">./templates</directory>
<directory suffix=".php">./tests</directory>
</exclude>
</whitelist>
</filter>
<coverage>
<include>
<directory suffix=".php">./lib</directory>
</include>
<report>
<clover outputFile="./clover.unit.xml"/>
</report>
</coverage>
</phpunit>
Loading