@@ -15,77 +15,153 @@ 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+ }
35+
36+ # Packages (components and bundles)
37+ PACKAGES="[]"
38+ 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
39+ if [[ "$pkg" == *-bundle ]]; then
40+ type="Bundle"
41+ else
42+ type="Component"
43+ fi
44+ name=$(to_title "$pkg" | sed 's/ Bundle$//')
45+ PACKAGES=$(echo "$PACKAGES" | jq -c --arg path "$pkg" --arg type "$type" --arg name "$name" '. + [{path: $path, type: $type, name: $name}]')
46+ done
47+ echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
48+
49+ # Bridges (store and tool)
50+ STORE_BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
51+ | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})')
52+ TOOL_BRIDGES=$(find src/agent/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
53+ | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "agent", type: "Tool", bridge: .})')
54+ BRIDGES=$(jq -n -c --argjson store "$STORE_BRIDGES" --argjson tool "$TOOL_BRIDGES" '$store + $tool')
55+ echo "bridges=$BRIDGES" >> $GITHUB_OUTPUT
56+
57+ phpstan-demo :
58+ name : PHPStan / Demo
59+ runs-on : ubuntu-latest
60+ steps :
61+ - name : Checkout
62+ uses : actions/checkout@v6
3863
3964 - name : Setup PHP
4065 uses : shivammathur/setup-php@v2
4166 with :
42- php-version : ${{ matrix.php-version }}
67+ php-version : ' 8.5 '
4368
44- - name : Get composer cache directory
45- id : composer-cache
46- run : |
47- echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
69+ - name : Install root dependencies
70+ uses : ramsey/composer-install@v3
71+
72+ - name : Build root packages
73+ run : php .github/build-packages.php
74+
75+ - name : Install dependencies
76+ uses : ramsey/composer-install@v3
77+ with :
78+ working-directory : demo
79+ composer-options : --ignore-platform-req=ext-mongodb
80+
81+ - name : Link packages
82+ run : cd demo && ../link
83+
84+ - name : Run PHPStan
85+ run : cd demo && vendor/bin/phpstan
4886
49- - name : Cache packages dependencies
50- uses : actions/cache@v4
87+ phpstan-examples :
88+ name : PHPStan / Examples
89+ runs-on : ubuntu-latest
90+ steps :
91+ - name : Checkout
92+ uses : actions/checkout@v6
93+
94+ - name : Setup PHP
95+ uses : shivammathur/setup-php@v2
5196 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 }}
97+ php-version : ' 8.5'
5698
5799 - name : Install root dependencies
58100 uses : ramsey/composer-install@v3
59101
60102 - name : Build root packages
61103 run : php .github/build-packages.php
62104
63- - name : Run PHPStan on examples
64- run : |
65- cd examples/ && $COMPOSER_UP && ../link && $PHPSTAN
105+ - name : Install dependencies
106+ uses : ramsey/composer-install@v3
107+ with :
108+ working-directory : examples
109+ composer-options : --ignore-platform-req=ext-mongodb
66110
67- - name : Run PHPStan on demo
68- run : |
69- cd demo/ && $COMPOSER_UP && ../link && $PHPSTAN
111+ - name : Link packages
112+ run : cd examples && ../link
70113
71- - name : Run PHPStan on packages
72- run : |
73- source .github/workflows/.utils.sh
114+ - name : Run PHPStan
115+ run : cd examples && vendor/bin/phpstan
74116
75- echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_UP && $PHPSTAN)'"
117+ phpstan-package :
118+ name : PHPStan / ${{ matrix.package.type }} / ${{ matrix.package.name }}
119+ needs : phpstan-matrix
120+ runs-on : ubuntu-latest
121+ strategy :
122+ fail-fast : false
123+ matrix :
124+ package : ${{ fromJson(needs.phpstan-matrix.outputs.packages) }}
125+ steps :
126+ - name : Checkout
127+ uses : actions/checkout@v6
76128
77- - name : Run PHPStan on store bridges
78- run : |
79- source .github/workflows/.utils.sh
129+ - name : Setup PHP
130+ uses : shivammathur/setup-php@v2
131+ with :
132+ php-version : ' 8.5'
80133
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)'"
134+ - name : Install dependencies
135+ uses : ramsey/composer-install@v3
136+ with :
137+ working-directory : src/${{ matrix.package.path }}
138+ composer-options : --ignore-platform-req=ext-mongodb
84139
85- - name : Run PHPStan on tool bridges
86- run : |
87- source .github/workflows/.utils.sh
140+ - name : Run PHPStan
141+ run : cd src/${{ matrix.package.path }} && vendor/bin/phpstan
142+
143+ phpstan-bridge :
144+ name : PHPStan / ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }}
145+ needs : phpstan-matrix
146+ runs-on : ubuntu-latest
147+ strategy :
148+ fail-fast : false
149+ matrix :
150+ bridge : ${{ fromJson(needs.phpstan-matrix.outputs.bridges) }}
151+ steps :
152+ - name : Checkout
153+ uses : actions/checkout@v6
154+
155+ - name : Setup PHP
156+ uses : shivammathur/setup-php@v2
157+ with :
158+ php-version : ' 8.5'
159+
160+ - name : Install dependencies
161+ uses : ramsey/composer-install@v3
162+ with :
163+ working-directory : src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }}
164+ composer-options : --ignore-platform-req=ext-mongodb
88165
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)'"
166+ - name : Run PHPStan
167+ run : cd src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpstan
0 commit comments