Skip to content

Commit 5036178

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 363dc0c commit 5036178

File tree

2 files changed

+152
-47
lines changed

2 files changed

+152
-47
lines changed

.github/workflows/code-quality.yaml

Lines changed: 136 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -14,78 +14,167 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1515
cancel-in-progress: true
1616

17+
env:
18+
PHP_VERSION: '8.5'
19+
1720
jobs:
18-
phpstan:
19-
name: PHPStan
21+
phpstan-matrix:
22+
name: PHPStan / Matrix
2023
runs-on: ubuntu-latest
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
php-version: [ '8.5' ]
24+
outputs:
25+
packages: ${{ steps.set-matrix.outputs.packages }}
26+
bridges: ${{ steps.set-matrix.outputs.bridges }}
2527
steps:
2628
- name: Checkout
2729
uses: actions/checkout@v6
2830

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

3976
- name: Setup PHP
4077
uses: shivammathur/setup-php@v2
4178
with:
42-
php-version: ${{ matrix.php-version }}
79+
php-version: ${{ env.PHP_VERSION }}
4380

44-
- name: Get composer cache directory
45-
id: composer-cache
46-
run: |
47-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
81+
- name: Install root dependencies
82+
uses: ramsey/composer-install@v3
4883

49-
- name: Cache packages dependencies
50-
uses: actions/cache@v4
84+
- name: Build root packages
85+
run: php .github/build-packages.php
86+
87+
- name: Install dependencies
88+
uses: ramsey/composer-install@v3
5189
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 }}
90+
working-directory: demo
91+
composer-options: --ignore-platform-req=ext-mongodb
92+
93+
- name: Link packages
94+
run: cd demo && ../link
95+
96+
- name: Run PHPStan
97+
run: cd demo && vendor/bin/phpstan
98+
99+
phpstan-examples:
100+
needs: phpstan-matrix
101+
name: PHPStan / Examples
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Checkout
105+
uses: actions/checkout@v6
106+
107+
- name: Setup PHP
108+
uses: shivammathur/setup-php@v2
109+
with:
110+
php-version: ${{ env.PHP_VERSION }}
56111

57112
- name: Install root dependencies
58113
uses: ramsey/composer-install@v3
59114

60115
- name: Build root packages
61116
run: php .github/build-packages.php
62117

63-
- name: Run PHPStan on examples
64-
run: |
65-
cd examples/ && $COMPOSER_UP && ../link && $PHPSTAN
118+
- name: Install dependencies
119+
uses: ramsey/composer-install@v3
120+
with:
121+
working-directory: examples
122+
composer-options: --ignore-platform-req=ext-mongodb
66123

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

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

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

77-
- name: Run PHPStan on store bridges
78-
run: |
79-
source .github/workflows/.utils.sh
142+
- name: Setup PHP
143+
uses: shivammathur/setup-php@v2
144+
with:
145+
php-version: ${{ env.PHP_VERSION }}
80146

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)'"
147+
- name: Install dependencies
148+
uses: ramsey/composer-install@v3
149+
with:
150+
working-directory: src/${{ matrix.package.path }}
151+
composer-options: --ignore-platform-req=ext-mongodb
84152

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

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)'"
179+
- name: Run PHPStan
180+
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)