|
| 1 | +# SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +name: Test |
| 4 | +on: pull_request |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +env: |
| 10 | + APP_NAME: contacts |
| 11 | + |
| 12 | +jobs: |
| 13 | + backend-unit-tests: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + php-versions: ['8.1', '8.2', '8.3'] |
| 18 | + nextcloud-versions: ['master', 'stable30'] |
| 19 | + include: |
| 20 | + - php-versions: '8.4' |
| 21 | + nextcloud-versions: ['master', 'stable30'] |
| 22 | + name: php${{ matrix.php-versions }} branch ${{ matrix.nextcloud-versions }} unit tests |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Set up Nextcloud env |
| 26 | + uses: ChristophWurst/setup-nextcloud@fc0790385c175d97e88a7cb0933490de6e990374 # v0.3.2 |
| 27 | + with: |
| 28 | + nextcloud-version: ${{ matrix.nextcloud-versions }} |
| 29 | + php-version: ${{ matrix.php-versions }} |
| 30 | + php-coverage: 'xdebug' |
| 31 | + patch-php-version-check: ${{ matrix.php-versions == '8.4' }} |
| 32 | + node-version: 'false' |
| 33 | + install: true |
| 34 | + |
| 35 | + - name: Checkout App |
| 36 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 |
| 37 | + with: |
| 38 | + path: nextcloud/apps/${{ env.APP_NAME }} |
| 39 | + |
| 40 | + - name: Install dependencies |
| 41 | + working-directory: nextcloud/apps/${{ env.APP_NAME }} |
| 42 | + run: composer install |
| 43 | + |
| 44 | + - name: Run tests |
| 45 | + working-directory: nextcloud/apps/${{ env.APP_NAME }} |
| 46 | + run: composer run test:unit |
| 47 | + if: ${{ matrix.php-versions == '8.3' }} |
| 48 | + env: |
| 49 | + XDEBUG_MODE: coverage |
| 50 | + |
| 51 | + - name: Run tests |
| 52 | + working-directory: nextcloud/apps/${{ env.APP_NAME }} |
| 53 | + run: composer run test:unit |
| 54 | + if: ${{ matrix.php-versions != '8.3' }} |
| 55 | + env: |
| 56 | + XDEBUG_MODE: off |
| 57 | + |
| 58 | + - name: Report coverage |
| 59 | + uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3.1.6 |
| 60 | + if: ${{ always() && matrix.php-versions == '8.3' }} |
| 61 | + with: |
| 62 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 63 | + file: ./nextcloud/apps/${{ env.APP_NAME }}/tests/clover.unit.xml |
| 64 | + flags: unittests |
| 65 | + fail_ci_if_error: ${{ !github.event.pull_request.head.repo.fork }} |
| 66 | + |
| 67 | + summary: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: |
| 70 | + - backend-unit-tests |
| 71 | + |
| 72 | + if: always() |
| 73 | + |
| 74 | + name: test-summary |
| 75 | + |
| 76 | + steps: |
| 77 | + - name: Unit test status |
| 78 | + run: if ${{ needs.unit-tests.result != 'success' && needs.unit-tests.result != 'skipped' }}; then exit 1; fi |
0 commit comments