Skip to content

Commit 7dcbd17

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. Also add all store bridge dev dependencies to ai-bundle for PHPStan.
1 parent 44b7f7b commit 7dcbd17

File tree

2 files changed

+150
-48
lines changed

2 files changed

+150
-48
lines changed

.github/workflows/code-quality.yaml

Lines changed: 134 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,81 +15,167 @@ concurrency:
1515
cancel-in-progress: true
1616

1717
env:
18+
PHP_VERSION: '8.5'
1819
REQUIRED_PHP_EXTENSIONS: 'mongodb, redis'
1920

2021
jobs:
21-
phpstan:
22-
name: PHPStan
22+
phpstan-matrix:
23+
name: PHPStan / Matrix
2324
runs-on: ubuntu-latest
24-
strategy:
25-
fail-fast: false
26-
matrix:
27-
php-version: [ '8.5' ]
25+
outputs:
26+
packages: ${{ steps.set-matrix.outputs.packages }}
27+
bridges: ${{ steps.set-matrix.outputs.bridges }}
2828
steps:
2929
- name: Checkout
3030
uses: actions/checkout@v6
3131

32-
- name: Configure environment
32+
- name: Set matrix
33+
id: set-matrix
3334
run: |
34-
echo COLUMNS=120 >> $GITHUB_ENV
35-
echo COMPOSER_UP='composer update --no-progress --no-interaction --no-scripts --ansi' >> $GITHUB_ENV
36-
echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV
37-
38-
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' ' ')
39-
echo "Packages: $PACKAGES"
40-
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
35+
# Helper function to convert "ai-bundle" to "AI Bundle"
36+
to_title() {
37+
echo "$1" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1' \
38+
| sed 's/\bAi\b/AI/g; s/\bMcp\b/MCP/g'
39+
}
40+
41+
# Packages (components and bundles)
42+
PACKAGES="[]"
43+
for pkg in $(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); do
44+
if [[ "$pkg" == *-bundle ]]; then
45+
type="Bundle"
46+
else
47+
type="Component"
48+
fi
49+
name=$(to_title "$pkg")
50+
PACKAGES=$(echo "$PACKAGES" | jq -c --arg path "$pkg" --arg type "$type" --arg name "$name" '. + [{path: $path, type: $type, name: $name}]')
51+
done
52+
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
53+
54+
# Bridges (store and tool)
55+
STORE_BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
56+
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})')
57+
TOOL_BRIDGES=$(find src/agent/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
58+
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "agent", type: "Tool", bridge: .})')
59+
BRIDGES=$(jq -n -c --argjson store "$STORE_BRIDGES" --argjson tool "$TOOL_BRIDGES" '$store + $tool')
60+
echo "bridges=$BRIDGES" >> $GITHUB_OUTPUT
61+
62+
# Pretty print for info
63+
echo "### Packages"
64+
echo "$PACKAGES" | jq .
65+
echo ""
66+
echo "### Bridges"
67+
echo "$BRIDGES" | jq .
68+
69+
phpstan-demo:
70+
needs: phpstan-matrix
71+
name: PHPStan / Demo
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v6
4176

4277
- name: Setup PHP
4378
uses: shivammathur/setup-php@v2
4479
with:
45-
php-version: ${{ matrix.php-version }}
46-
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
80+
php-version: ${{ env.PHP_VERSION }}
81+
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
4782

48-
- name: Get composer cache directory
49-
id: composer-cache
50-
run: |
51-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
83+
- name: Install root dependencies
84+
uses: ramsey/composer-install@v3
85+
86+
- name: Build root packages
87+
run: php .github/build-packages.php
88+
89+
- name: Install dependencies
90+
uses: ramsey/composer-install@v3
91+
with:
92+
working-directory: demo
93+
94+
- name: Link packages
95+
run: cd demo && ../link
96+
97+
- name: Run PHPStan
98+
run: cd demo && vendor/bin/phpstan
5299

53-
- name: Cache packages dependencies
54-
uses: actions/cache@v4
100+
phpstan-examples:
101+
needs: phpstan-matrix
102+
name: PHPStan / Examples
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Checkout
106+
uses: actions/checkout@v6
107+
108+
- name: Setup PHP
109+
uses: shivammathur/setup-php@v2
55110
with:
56-
path: ${{ steps.composer-cache.outputs.dir }}
57-
key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ hashFiles('src/**/composer.json') }}
58-
restore-keys: |
59-
${{ runner.os }}-composer-packages-${{ matrix.php-version }}
111+
php-version: ${{ env.PHP_VERSION }}
112+
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
60113

61114
- name: Install root dependencies
62115
uses: ramsey/composer-install@v3
63116

64117
- name: Build root packages
65118
run: php .github/build-packages.php
66119

67-
- name: Run PHPStan on examples
68-
run: |
69-
cd examples/ && $COMPOSER_UP && ../link && $PHPSTAN
120+
- name: Install dependencies
121+
uses: ramsey/composer-install@v3
122+
with:
123+
working-directory: examples
70124

71-
- name: Run PHPStan on demo
72-
run: |
73-
cd demo/ && $COMPOSER_UP && ../link && $PHPSTAN
125+
- name: Link packages
126+
run: cd examples && ../link
74127

75-
- name: Run PHPStan on packages
76-
run: |
77-
source .github/workflows/.utils.sh
128+
- name: Run PHPStan
129+
run: cd examples && vendor/bin/phpstan
78130

79-
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_UP && $PHPSTAN)'"
131+
phpstan-package:
132+
name: PHPStan / ${{ matrix.package.type }} / ${{ matrix.package.name }}
133+
needs: phpstan-matrix
134+
runs-on: ubuntu-latest
135+
strategy:
136+
fail-fast: false
137+
matrix:
138+
package: ${{ fromJson(needs.phpstan-matrix.outputs.packages) }}
139+
steps:
140+
- name: Checkout
141+
uses: actions/checkout@v6
80142

81-
- name: Run PHPStan on store bridges
82-
run: |
83-
source .github/workflows/.utils.sh
143+
- name: Setup PHP
144+
uses: shivammathur/setup-php@v2
145+
with:
146+
php-version: ${{ env.PHP_VERSION }}
147+
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
84148

85-
BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort | tr '\n' ' ')
86-
echo "Bridges: $BRIDGES"
87-
echo "$BRIDGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/store/src/Bridge/{} && $COMPOSER_UP && $PHPSTAN)'"
149+
- name: Install dependencies
150+
uses: ramsey/composer-install@v3
151+
with:
152+
working-directory: src/${{ matrix.package.path }}
88153

89-
- name: Run PHPStan on tool bridges
90-
run: |
91-
source .github/workflows/.utils.sh
154+
- name: Run PHPStan
155+
run: cd src/${{ matrix.package.path }} && vendor/bin/phpstan
156+
157+
phpstan-bridge:
158+
name: PHPStan / ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }}
159+
needs: phpstan-matrix
160+
runs-on: ubuntu-latest
161+
strategy:
162+
fail-fast: false
163+
matrix:
164+
bridge: ${{ fromJson(needs.phpstan-matrix.outputs.bridges) }}
165+
steps:
166+
- name: Checkout
167+
uses: actions/checkout@v6
168+
169+
- name: Setup PHP
170+
uses: shivammathur/setup-php@v2
171+
with:
172+
php-version: ${{ env.PHP_VERSION }}
173+
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
174+
175+
- name: Install dependencies
176+
uses: ramsey/composer-install@v3
177+
with:
178+
working-directory: src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }}
92179

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

src/ai-bundle/composer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,27 @@
3535
"phpstan/phpstan": "^2.1",
3636
"phpstan/phpstan-strict-rules": "^2.0",
3737
"phpunit/phpunit": "^11.5.46",
38+
"symfony/ai-azure-search-store": "@dev",
39+
"symfony/ai-cache-store": "@dev",
3840
"symfony/ai-chroma-db-store": "@dev",
41+
"symfony/ai-click-house-store": "@dev",
42+
"symfony/ai-cloudflare-store": "@dev",
43+
"symfony/ai-elasticsearch-store": "@dev",
44+
"symfony/ai-manticore-search-store": "@dev",
45+
"symfony/ai-maria-db-store": "@dev",
46+
"symfony/ai-meilisearch-store": "@dev",
47+
"symfony/ai-milvus-store": "@dev",
3948
"symfony/ai-mongo-db-store": "@dev",
49+
"symfony/ai-neo4j-store": "@dev",
50+
"symfony/ai-open-search-store": "@dev",
4051
"symfony/ai-pinecone-store": "@dev",
4152
"symfony/ai-postgres-store": "@dev",
53+
"symfony/ai-qdrant-store": "@dev",
4254
"symfony/ai-redis-store": "@dev",
55+
"symfony/ai-supabase-store": "@dev",
56+
"symfony/ai-surreal-db-store": "@dev",
57+
"symfony/ai-typesense-store": "@dev",
58+
"symfony/ai-weaviate-store": "@dev",
4359
"symfony/expression-language": "^7.3|^8.0",
4460
"symfony/security-core": "^7.3|^8.0",
4561
"symfony/translation": "^7.3|^8.0"

0 commit comments

Comments
 (0)