@@ -15,77 +15,154 @@ concurrency:
1515 cancel-in-progress : true
1616
1717jobs :
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+ # Helper function to convert "ai-bundle" to "AI Bundle"
32+ to_title() {
33+ echo "$1" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1' \
34+ | sed 's/\bAi\b/AI/g; s/\bMcp\b/MCP/g'
35+ }
36+
37+ # Packages (components and bundles)
38+ PACKAGES="[]"
39+ 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
40+ if [[ "$pkg" == *-bundle ]]; then
41+ type="Bundle"
42+ else
43+ type="Component"
44+ fi
45+ name=$(to_title "$pkg")
46+ PACKAGES=$(echo "$PACKAGES" | jq -c --arg path "$pkg" --arg type "$type" --arg name "$name" '. + [{path: $path, type: $type, name: $name}]')
47+ done
48+ echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
49+
50+ # Bridges (store and tool)
51+ STORE_BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
52+ | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})')
53+ TOOL_BRIDGES=$(find src/agent/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
54+ | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "agent", type: "Tool", bridge: .})')
55+ BRIDGES=$(jq -n -c --argjson store "$STORE_BRIDGES" --argjson tool "$TOOL_BRIDGES" '$store + $tool')
56+ echo "bridges=$BRIDGES" >> $GITHUB_OUTPUT
57+
58+ phpstan-demo :
59+ name : PHPStan / Demo
60+ runs-on : ubuntu-latest
61+ steps :
62+ - name : Checkout
63+ uses : actions/checkout@v6
3864
3965 - name : Setup PHP
4066 uses : shivammathur/setup-php@v2
4167 with :
42- php-version : ${{ matrix.php-version }}
68+ php-version : ' 8.5 '
4369
44- - name : Get composer cache directory
45- id : composer-cache
46- run : |
47- echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
70+ - name : Install root dependencies
71+ uses : ramsey/composer-install@v3
72+
73+ - name : Build root packages
74+ run : php .github/build-packages.php
75+
76+ - name : Install dependencies
77+ uses : ramsey/composer-install@v3
78+ with :
79+ working-directory : demo
80+ composer-options : --ignore-platform-req=ext-mongodb
81+
82+ - name : Link packages
83+ run : cd demo && ../link
84+
85+ - name : Run PHPStan
86+ run : cd demo && vendor/bin/phpstan
4887
49- - name : Cache packages dependencies
50- uses : actions/cache@v4
88+ phpstan-examples :
89+ name : PHPStan / Examples
90+ runs-on : ubuntu-latest
91+ steps :
92+ - name : Checkout
93+ uses : actions/checkout@v6
94+
95+ - name : Setup PHP
96+ uses : shivammathur/setup-php@v2
5197 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 }}
98+ php-version : ' 8.5'
5699
57100 - name : Install root dependencies
58101 uses : ramsey/composer-install@v3
59102
60103 - name : Build root packages
61104 run : php .github/build-packages.php
62105
63- - name : Run PHPStan on examples
64- run : |
65- cd examples/ && $COMPOSER_UP && ../link && $PHPSTAN
106+ - name : Install dependencies
107+ uses : ramsey/composer-install@v3
108+ with :
109+ working-directory : examples
110+ composer-options : --ignore-platform-req=ext-mongodb
66111
67- - name : Run PHPStan on demo
68- run : |
69- cd demo/ && $COMPOSER_UP && ../link && $PHPSTAN
112+ - name : Link packages
113+ run : cd examples && ../link
70114
71- - name : Run PHPStan on packages
72- run : |
73- source .github/workflows/.utils.sh
115+ - name : Run PHPStan
116+ run : cd examples && vendor/bin/phpstan
74117
75- echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_UP && $PHPSTAN)'"
118+ phpstan-package :
119+ name : PHPStan / ${{ matrix.package.type }} / ${{ matrix.package.name }}
120+ needs : phpstan-matrix
121+ runs-on : ubuntu-latest
122+ strategy :
123+ fail-fast : false
124+ matrix :
125+ package : ${{ fromJson(needs.phpstan-matrix.outputs.packages) }}
126+ steps :
127+ - name : Checkout
128+ uses : actions/checkout@v6
76129
77- - name : Run PHPStan on store bridges
78- run : |
79- source .github/workflows/.utils.sh
130+ - name : Setup PHP
131+ uses : shivammathur/setup-php@v2
132+ with :
133+ php-version : ' 8.5'
80134
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)'"
135+ - name : Install dependencies
136+ uses : ramsey/composer-install@v3
137+ with :
138+ working-directory : src/${{ matrix.package.path }}
139+ composer-options : --ignore-platform-req=ext-mongodb
84140
85- - name : Run PHPStan on tool bridges
86- run : |
87- source .github/workflows/.utils.sh
141+ - name : Run PHPStan
142+ run : cd src/${{ matrix.package.path }} && vendor/bin/phpstan
143+
144+ phpstan-bridge :
145+ name : PHPStan / ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }}
146+ needs : phpstan-matrix
147+ runs-on : ubuntu-latest
148+ strategy :
149+ fail-fast : false
150+ matrix :
151+ bridge : ${{ fromJson(needs.phpstan-matrix.outputs.bridges) }}
152+ steps :
153+ - name : Checkout
154+ uses : actions/checkout@v6
155+
156+ - name : Setup PHP
157+ uses : shivammathur/setup-php@v2
158+ with :
159+ php-version : ' 8.5'
160+
161+ - name : Install dependencies
162+ uses : ramsey/composer-install@v3
163+ with :
164+ working-directory : src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }}
165+ composer-options : --ignore-platform-req=ext-mongodb
88166
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)'"
167+ - name : Run PHPStan
168+ run : cd src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpstan
0 commit comments