Skip to content

Commit 316225b

Browse files
committed
Use GitHub matrix for all PHPStan jobs
Split PHPStan checks into individual matrix jobs for better visibility: - PHPStan / Demo - PHPStan / Examples - PHPStan / Component / {Agent, Chat, Platform, Store} - PHPStan / Bundle / {AI Bundle, MCP Bundle} - PHPStan / Store / {bridge} - PHPStan / Tool / {bridge} The matrix is computed dynamically by scanning directories, so new packages and bridges are automatically included without workflow changes.
1 parent 363dc0c commit 316225b

File tree

1 file changed

+118
-47
lines changed

1 file changed

+118
-47
lines changed

.github/workflows/code-quality.yaml

Lines changed: 118 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -15,77 +15,148 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
jobs:
18-
phpstan:
19-
name: PHPStan
18+
phpstan-matrix:
19+
name: PHPStan / Matrix
2020
runs-on: ubuntu-latest
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
php-version: [ '8.5' ]
21+
outputs:
22+
packages: ${{ steps.set-matrix.outputs.packages }}
23+
bridges: ${{ steps.set-matrix.outputs.bridges }}
2524
steps:
2625
- name: Checkout
2726
uses: actions/checkout@v6
2827

29-
- name: Configure environment
28+
- name: Set matrix
29+
id: set-matrix
3030
run: |
31-
echo COLUMNS=120 >> $GITHUB_ENV
32-
echo COMPOSER_UP='composer update --no-progress --no-interaction --no-scripts --ansi --ignore-platform-req=ext-mongodb' >> $GITHUB_ENV
33-
echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV
34-
35-
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 | tr '\n' ' ')
36-
echo "Packages: $PACKAGES"
37-
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
31+
# Packages (components and bundles)
32+
PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -not -path "*/Bridge/*" -printf '%h\n' \
33+
| sed 's|^src/||' \
34+
| grep -Ev "examples" \
35+
| sort \
36+
| jq -R -s -c --argjson names '{"agent":"Agent","ai-bundle":"AI Bundle","chat":"Chat","mcp-bundle":"MCP Bundle","platform":"Platform","store":"Store"}' \
37+
'split("\n") | map(select(length > 0)) | map({
38+
path: .,
39+
type: (if endswith("-bundle") then "Bundle" else "Component" end),
40+
name: ($names[.] // .)
41+
})')
42+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
43+
44+
# Bridges (store and tool)
45+
STORE_BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
46+
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})')
47+
TOOL_BRIDGES=$(find src/agent/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
48+
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "agent", type: "Tool", bridge: .})')
49+
BRIDGES=$(jq -n -c --argjson store "$STORE_BRIDGES" --argjson tool "$TOOL_BRIDGES" '$store + $tool')
50+
echo "bridges=$BRIDGES" >> $GITHUB_OUTPUT
51+
52+
phpstan-demo:
53+
name: PHPStan / Demo
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v6
3858

3959
- name: Setup PHP
4060
uses: shivammathur/setup-php@v2
4161
with:
42-
php-version: ${{ matrix.php-version }}
62+
php-version: '8.5'
4363

44-
- name: Get composer cache directory
45-
id: composer-cache
46-
run: |
47-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
64+
- name: Install root dependencies
65+
uses: ramsey/composer-install@v3
66+
67+
- name: Build root packages
68+
run: php .github/build-packages.php
69+
70+
- name: Install dependencies
71+
uses: ramsey/composer-install@v3
72+
with:
73+
working-directory: demo
74+
composer-options: --ignore-platform-req=ext-mongodb
75+
76+
- name: Link packages
77+
run: cd demo && ../link
78+
79+
- name: Run PHPStan
80+
run: cd demo && vendor/bin/phpstan
4881

49-
- name: Cache packages dependencies
50-
uses: actions/cache@v4
82+
phpstan-examples:
83+
name: PHPStan / Examples
84+
runs-on: ubuntu-latest
85+
steps:
86+
- name: Checkout
87+
uses: actions/checkout@v6
88+
89+
- name: Setup PHP
90+
uses: shivammathur/setup-php@v2
5191
with:
52-
path: ${{ steps.composer-cache.outputs.dir }}
53-
key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ hashFiles('src/**/composer.json') }}
54-
restore-keys: |
55-
${{ runner.os }}-composer-packages-${{ matrix.php-version }}
92+
php-version: '8.5'
5693

5794
- name: Install root dependencies
5895
uses: ramsey/composer-install@v3
5996

6097
- name: Build root packages
6198
run: php .github/build-packages.php
6299

63-
- name: Run PHPStan on examples
64-
run: |
65-
cd examples/ && $COMPOSER_UP && ../link && $PHPSTAN
100+
- name: Install dependencies
101+
uses: ramsey/composer-install@v3
102+
with:
103+
working-directory: examples
104+
composer-options: --ignore-platform-req=ext-mongodb
66105

67-
- name: Run PHPStan on demo
68-
run: |
69-
cd demo/ && $COMPOSER_UP && ../link && $PHPSTAN
106+
- name: Link packages
107+
run: cd examples && ../link
70108

71-
- name: Run PHPStan on packages
72-
run: |
73-
source .github/workflows/.utils.sh
109+
- name: Run PHPStan
110+
run: cd examples && vendor/bin/phpstan
74111

75-
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_UP && $PHPSTAN)'"
112+
phpstan-package:
113+
name: PHPStan / ${{ matrix.package.type }} / ${{ matrix.package.name }}
114+
needs: phpstan-matrix
115+
runs-on: ubuntu-latest
116+
strategy:
117+
fail-fast: false
118+
matrix:
119+
package: ${{ fromJson(needs.phpstan-matrix.outputs.packages) }}
120+
steps:
121+
- name: Checkout
122+
uses: actions/checkout@v6
76123

77-
- name: Run PHPStan on store bridges
78-
run: |
79-
source .github/workflows/.utils.sh
124+
- name: Setup PHP
125+
uses: shivammathur/setup-php@v2
126+
with:
127+
php-version: '8.5'
80128

81-
BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort | tr '\n' ' ')
82-
echo "Bridges: $BRIDGES"
83-
echo "$BRIDGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/store/src/Bridge/{} && $COMPOSER_UP && $PHPSTAN)'"
129+
- name: Install dependencies
130+
uses: ramsey/composer-install@v3
131+
with:
132+
working-directory: src/${{ matrix.package.path }}
133+
composer-options: --ignore-platform-req=ext-mongodb
84134

85-
- name: Run PHPStan on tool bridges
86-
run: |
87-
source .github/workflows/.utils.sh
135+
- name: Run PHPStan
136+
run: cd src/${{ matrix.package.path }} && vendor/bin/phpstan
137+
138+
phpstan-bridge:
139+
name: PHPStan / ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }}
140+
needs: phpstan-matrix
141+
runs-on: ubuntu-latest
142+
strategy:
143+
fail-fast: false
144+
matrix:
145+
bridge: ${{ fromJson(needs.phpstan-matrix.outputs.bridges) }}
146+
steps:
147+
- name: Checkout
148+
uses: actions/checkout@v6
149+
150+
- name: Setup PHP
151+
uses: shivammathur/setup-php@v2
152+
with:
153+
php-version: '8.5'
154+
155+
- name: Install dependencies
156+
uses: ramsey/composer-install@v3
157+
with:
158+
working-directory: src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }}
159+
composer-options: --ignore-platform-req=ext-mongodb
88160

89-
BRIDGES=$(find src/agent/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort | tr '\n' ' ')
90-
echo "Bridges: $BRIDGES"
91-
echo "$BRIDGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/agent/src/Bridge/{} && $COMPOSER_UP && $PHPSTAN)'"
161+
- name: Run PHPStan
162+
run: cd src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpstan

0 commit comments

Comments
 (0)