Merge pull request #201 from nextcloud/dependabot/composer/changelog/… #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | |
| # SPDX-License-Identifier: AGPL-3.0-or-later | |
| name: Test PHP tools | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - '**.php' | |
| - '**/composer.json' | |
| - '**/composer.lock' | |
| - '.github/workflows/php-test.yml' | |
| pull_request: | |
| paths: | |
| - '**.php' | |
| - '**/composer.json' | |
| - '**/composer.lock' | |
| - '.github/workflows/php-test.yml' | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: php-test-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| # Discover every PHP tool (any directory with a composer.json) so new tools | |
| # are picked up automatically without touching this workflow. | |
| discover: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| matrix: ${{ steps.find.outputs.matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Find composer projects | |
| id: find | |
| run: | | |
| dirs=$(find . -mindepth 2 -maxdepth 2 -name composer.json -not -path '*/vendor/*' \ | |
| -printf '%h\n' | sed 's#^\./##' | sort -u | jq -R . | jq -sc .) | |
| echo "matrix=$dirs" >> "$GITHUB_OUTPUT" | |
| echo "Discovered: $dirs" | |
| test: | |
| needs: discover | |
| if: needs.discover.outputs.matrix != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| dir: ${{ fromJson(needs.discover.outputs.matrix) }} | |
| defaults: | |
| run: | |
| working-directory: ${{ matrix.dir }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| # Matches the PHP version used by the release changelog workflow. | |
| - name: Set up PHP | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2 | |
| with: | |
| php-version: '8.4' | |
| coverage: none | |
| - name: Install dependencies | |
| run: composer install --no-progress | |
| - name: Lint PHP files | |
| run: find . -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n1 php -l | |
| # Runs the test suite only for tools that define a "test" composer script. | |
| - name: Run tests | |
| run: | | |
| if composer run-script --list 2>/dev/null | grep -qE '^\s*test\b'; then | |
| composer test | |
| else | |
| echo "No 'test' script in ${{ matrix.dir }}/composer.json, skipping." | |
| fi | |
| # Single fixed-name check that aggregates the dynamic matrix, so branch | |
| # protection can require one status regardless of how many tools exist. | |
| summary: | |
| permissions: | |
| contents: none | |
| runs-on: ubuntu-latest | |
| needs: [discover, test] | |
| if: always() | |
| name: php-test-summary | |
| steps: | |
| - name: Summary status | |
| run: if ${{ needs.test.result != 'success' && needs.test.result != 'skipped' }}; then exit 1; fi |