@@ -15,77 +15,163 @@ 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+ # Pretty print for info
59+ echo "### Packages"
60+ echo "$PACKAGES" | jq .
61+ echo ""
62+ echo "### Bridges"
63+ echo "$BRIDGES" | jq .
64+
65+ phpstan-demo :
66+ needs : phpstan-matrix
67+ name : PHPStan / Demo
68+ runs-on : ubuntu-latest
69+ steps :
70+ - name : Checkout
71+ uses : actions/checkout@v6
3872
3973 - name : Setup PHP
4074 uses : shivammathur/setup-php@v2
4175 with :
42- php-version : ${{ matrix.php-version }}
76+ php-version : ' 8.5 '
4377
44- - name : Get composer cache directory
45- id : composer-cache
46- run : |
47- echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
78+ - name : Install root dependencies
79+ uses : ramsey/composer-install@v3
80+
81+ - name : Build root packages
82+ run : php .github/build-packages.php
83+
84+ - name : Install dependencies
85+ uses : ramsey/composer-install@v3
86+ with :
87+ working-directory : demo
88+ composer-options : --ignore-platform-req=ext-mongodb
89+
90+ - name : Link packages
91+ run : cd demo && ../link
92+
93+ - name : Run PHPStan
94+ run : cd demo && vendor/bin/phpstan
4895
49- - name : Cache packages dependencies
50- uses : actions/cache@v4
96+ phpstan-examples :
97+ needs : phpstan-matrix
98+ name : PHPStan / Examples
99+ runs-on : ubuntu-latest
100+ steps :
101+ - name : Checkout
102+ uses : actions/checkout@v6
103+
104+ - name : Setup PHP
105+ uses : shivammathur/setup-php@v2
51106 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 }}
107+ php-version : ' 8.5'
56108
57109 - name : Install root dependencies
58110 uses : ramsey/composer-install@v3
59111
60112 - name : Build root packages
61113 run : php .github/build-packages.php
62114
63- - name : Run PHPStan on examples
64- run : |
65- cd examples/ && $COMPOSER_UP && ../link && $PHPSTAN
115+ - name : Install dependencies
116+ uses : ramsey/composer-install@v3
117+ with :
118+ working-directory : examples
119+ composer-options : --ignore-platform-req=ext-mongodb
66120
67- - name : Run PHPStan on demo
68- run : |
69- cd demo/ && $COMPOSER_UP && ../link && $PHPSTAN
121+ - name : Link packages
122+ run : cd examples && ../link
70123
71- - name : Run PHPStan on packages
72- run : |
73- source .github/workflows/.utils.sh
124+ - name : Run PHPStan
125+ run : cd examples && vendor/bin/phpstan
74126
75- echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_UP && $PHPSTAN)'"
127+ phpstan-package :
128+ name : PHPStan / ${{ matrix.package.type }} / ${{ matrix.package.name }}
129+ needs : phpstan-matrix
130+ runs-on : ubuntu-latest
131+ strategy :
132+ fail-fast : false
133+ matrix :
134+ package : ${{ fromJson(needs.phpstan-matrix.outputs.packages) }}
135+ steps :
136+ - name : Checkout
137+ uses : actions/checkout@v6
76138
77- - name : Run PHPStan on store bridges
78- run : |
79- source .github/workflows/.utils.sh
139+ - name : Setup PHP
140+ uses : shivammathur/setup-php@v2
141+ with :
142+ php-version : ' 8.5'
80143
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)'"
144+ - name : Install dependencies
145+ uses : ramsey/composer-install@v3
146+ with :
147+ working-directory : src/${{ matrix.package.path }}
148+ composer-options : --ignore-platform-req=ext-mongodb
84149
85- - name : Run PHPStan on tool bridges
86- run : |
87- source .github/workflows/.utils.sh
150+ - name : Run PHPStan
151+ run : cd src/${{ matrix.package.path }} && vendor/bin/phpstan
152+
153+ phpstan-bridge :
154+ name : PHPStan / ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }}
155+ needs : phpstan-matrix
156+ runs-on : ubuntu-latest
157+ strategy :
158+ fail-fast : false
159+ matrix :
160+ bridge : ${{ fromJson(needs.phpstan-matrix.outputs.bridges) }}
161+ steps :
162+ - name : Checkout
163+ uses : actions/checkout@v6
164+
165+ - name : Setup PHP
166+ uses : shivammathur/setup-php@v2
167+ with :
168+ php-version : ' 8.5'
169+
170+ - name : Install dependencies
171+ uses : ramsey/composer-install@v3
172+ with :
173+ working-directory : src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }}
174+ composer-options : --ignore-platform-req=ext-mongodb
88175
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)'"
176+ - name : Run PHPStan
177+ run : cd src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpstan
0 commit comments