[CI] Use GitHub matrix for PHPStan jobs #6309
Workflow file for this run
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
| name: Code Quality | |
| on: | |
| push: | |
| paths-ignore: | |
| - 'src/*/doc/**' | |
| - 'src/**/*.md' | |
| pull_request: | |
| paths-ignore: | |
| - 'src/*/doc/**' | |
| - 'src/**/*.md' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| phpstan-matrix: | |
| name: PHPStan / Matrix | |
| runs-on: ubuntu-latest | |
| outputs: | |
| packages: ${{ steps.set-matrix.outputs.packages }} | |
| bridges: ${{ steps.set-matrix.outputs.bridges }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set matrix | |
| id: set-matrix | |
| run: | | |
| # Packages (components and bundles) | |
| PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -not -path "*/Bridge/*" -printf '%h\n' \ | |
| | sed 's|^src/||' \ | |
| | grep -Ev "examples" \ | |
| | sort \ | |
| | jq -R -s -c --argjson names '{"agent":"Agent","ai-bundle":"AI Bundle","chat":"Chat","mcp-bundle":"MCP Bundle","platform":"Platform","store":"Store"}' \ | |
| 'split("\n") | map(select(length > 0)) | map({ | |
| path: ., | |
| type: (if endswith("-bundle") then "Bundle" else "Component" end), | |
| name: ($names[.] // .) | |
| })') | |
| echo "packages=$PACKAGES" >> $GITHUB_OUTPUT | |
| # Bridges (store and tool) | |
| STORE_BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \ | |
| | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})') | |
| TOOL_BRIDGES=$(find src/agent/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \ | |
| | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "agent", type: "Tool", bridge: .})') | |
| BRIDGES=$(jq -n -c --argjson store "$STORE_BRIDGES" --argjson tool "$TOOL_BRIDGES" '$store + $tool') | |
| echo "bridges=$BRIDGES" >> $GITHUB_OUTPUT | |
| phpstan-demo: | |
| name: PHPStan / Demo | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v3 | |
| - name: Build root packages | |
| run: php .github/build-packages.php | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v3 | |
| with: | |
| working-directory: demo | |
| composer-options: --ignore-platform-req=ext-mongodb | |
| - name: Link packages | |
| run: cd demo && ../link | |
| - name: Run PHPStan | |
| run: cd demo && vendor/bin/phpstan | |
| phpstan-examples: | |
| name: PHPStan / Examples | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| - name: Install root dependencies | |
| uses: ramsey/composer-install@v3 | |
| - name: Build root packages | |
| run: php .github/build-packages.php | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v3 | |
| with: | |
| working-directory: examples | |
| composer-options: --ignore-platform-req=ext-mongodb | |
| - name: Link packages | |
| run: cd examples && ../link | |
| - name: Run PHPStan | |
| run: cd examples && vendor/bin/phpstan | |
| phpstan-package: | |
| name: PHPStan / ${{ matrix.package.type }} / ${{ matrix.package.name }} | |
| needs: phpstan-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package: ${{ fromJson(needs.phpstan-matrix.outputs.packages) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v3 | |
| with: | |
| working-directory: src/${{ matrix.package.path }} | |
| composer-options: --ignore-platform-req=ext-mongodb | |
| - name: Run PHPStan | |
| run: cd src/${{ matrix.package.path }} && vendor/bin/phpstan | |
| phpstan-bridge: | |
| name: PHPStan / ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }} | |
| needs: phpstan-matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| bridge: ${{ fromJson(needs.phpstan-matrix.outputs.bridges) }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.5' | |
| - name: Install dependencies | |
| uses: ramsey/composer-install@v3 | |
| with: | |
| working-directory: src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} | |
| composer-options: --ignore-platform-req=ext-mongodb | |
| - name: Run PHPStan | |
| run: cd src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpstan |