Skip to content

Commit cbda539

Browse files
committed
minor #1165 Add dedicated unit test jobs for each tool and store bridge (OskarStark)
This PR was merged into the main branch. Discussion ---------- Add dedicated unit test jobs for each tool and store bridge | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | Docs? | no | Issues | -- | License | MIT Commits ------- 3291f67 Add dedicated unit test jobs for each tool and store bridge
2 parents 0895454 + 3291f67 commit cbda539

File tree

1 file changed

+153
-40
lines changed

1 file changed

+153
-40
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 153 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,74 +18,187 @@ env:
1818
REQUIRED_PHP_EXTENSIONS: 'mongodb, redis'
1919

2020
jobs:
21-
php:
21+
matrix:
22+
name: Matrix
23+
runs-on: ubuntu-latest
24+
outputs:
25+
packages: ${{ steps.set-matrix.outputs.packages }}
26+
bridges: ${{ steps.set-matrix.outputs.bridges }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v6
30+
31+
- name: Set matrix
32+
id: set-matrix
33+
run: |
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/*" | xargs -I{} dirname {} | 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=$(ls -1 src/store/src/Bridge/ | sort \
55+
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})')
56+
TOOL_BRIDGES=$(ls -1 src/agent/src/Bridge/ | 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+
package:
69+
name: ${{ matrix.package.type }} / ${{ matrix.package.name }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }}${{ matrix.symfony-version && format(' / Symfony {0}', matrix.symfony-version) || '' }}
70+
needs: matrix
2271
runs-on: ubuntu-latest
2372
strategy:
2473
fail-fast: false
2574
matrix:
75+
package: ${{ fromJson(needs.matrix.outputs.packages) }}
2676
php-version: ['8.2', '8.5']
2777
dependency-version: ['']
2878
symfony-version: ['']
2979
include:
30-
# lowest deps
31-
- php-version: '8.2'
32-
dependency-version: 'lowest'
33-
# Symfony 7.4 LTS
34-
- php-version: '8.2'
35-
symfony-version: '7.4.*'
36-
# Symfony 8.0
37-
- php-version: '8.5'
38-
symfony-version: '8.0.*'
80+
# lowest deps for all packages
81+
- php-version: '8.2'
82+
dependency-version: 'lowest'
83+
package: { path: 'agent', type: 'Component', name: 'Agent' }
84+
- php-version: '8.2'
85+
dependency-version: 'lowest'
86+
package: { path: 'ai-bundle', type: 'Bundle', name: 'AI Bundle' }
87+
- php-version: '8.2'
88+
dependency-version: 'lowest'
89+
package: { path: 'chat', type: 'Component', name: 'Chat' }
90+
- php-version: '8.2'
91+
dependency-version: 'lowest'
92+
package: { path: 'mcp-bundle', type: 'Bundle', name: 'MCP Bundle' }
93+
- php-version: '8.2'
94+
dependency-version: 'lowest'
95+
package: { path: 'platform', type: 'Component', name: 'Platform' }
96+
- php-version: '8.2'
97+
dependency-version: 'lowest'
98+
package: { path: 'store', type: 'Component', name: 'Store' }
99+
# Symfony 7.4 LTS for all packages
100+
- php-version: '8.2'
101+
symfony-version: '7.4.*'
102+
package: { path: 'agent', type: 'Component', name: 'Agent' }
103+
- php-version: '8.2'
104+
symfony-version: '7.4.*'
105+
package: { path: 'ai-bundle', type: 'Bundle', name: 'AI Bundle' }
106+
- php-version: '8.2'
107+
symfony-version: '7.4.*'
108+
package: { path: 'chat', type: 'Component', name: 'Chat' }
109+
- php-version: '8.2'
110+
symfony-version: '7.4.*'
111+
package: { path: 'mcp-bundle', type: 'Bundle', name: 'MCP Bundle' }
112+
- php-version: '8.2'
113+
symfony-version: '7.4.*'
114+
package: { path: 'platform', type: 'Component', name: 'Platform' }
115+
- php-version: '8.2'
116+
symfony-version: '7.4.*'
117+
package: { path: 'store', type: 'Component', name: 'Store' }
118+
# Symfony 8.0 for all packages
119+
- php-version: '8.5'
120+
symfony-version: '8.0.*'
121+
package: { path: 'agent', type: 'Component', name: 'Agent' }
122+
- php-version: '8.5'
123+
symfony-version: '8.0.*'
124+
package: { path: 'ai-bundle', type: 'Bundle', name: 'AI Bundle' }
125+
- php-version: '8.5'
126+
symfony-version: '8.0.*'
127+
package: { path: 'chat', type: 'Component', name: 'Chat' }
128+
- php-version: '8.5'
129+
symfony-version: '8.0.*'
130+
package: { path: 'mcp-bundle', type: 'Bundle', name: 'MCP Bundle' }
131+
- php-version: '8.5'
132+
symfony-version: '8.0.*'
133+
package: { path: 'platform', type: 'Component', name: 'Platform' }
134+
- php-version: '8.5'
135+
symfony-version: '8.0.*'
136+
package: { path: 'store', type: 'Component', name: 'Store' }
39137

40138
env:
41139
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=7.4' }}
42140

43141
steps:
44-
- uses: actions/checkout@v6
142+
- name: Checkout
143+
uses: actions/checkout@v6
45144

46145
- name: Configure environment
47146
run: |
48147
echo COLUMNS=120 >> $GITHUB_ENV
49-
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest --prefer-stable' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
50-
echo PHPUNIT='vendor/bin/phpunit' >> $GITHUB_ENV
51-
[ 'lowest' = '${{ matrix.dependency-version }}' ] && export SYMFONY_DEPRECATIONS_HELPER=weak
52-
53-
PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "examples" | sort | tr '\n' ' ')
54-
echo "Packages: $PACKAGES"
55-
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
148+
[ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true
56149
57150
- name: Setup PHP
58151
uses: shivammathur/setup-php@v2
59152
with:
60153
php-version: ${{ matrix.php-version }}
61154
tools: flex
62-
extensions: "${{ env.REQUIRED_PHP_EXTENSIONS }}"
63-
64-
- name: Get composer cache directory
65-
id: composer-cache
66-
run: |
67-
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
155+
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
68156

69-
- name: Cache packages dependencies
70-
uses: actions/cache@v4
157+
- name: Install dependencies
158+
uses: ramsey/composer-install@v3
71159
with:
72-
path: ${{ steps.composer-cache.outputs.dir }}
73-
key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ hashFiles('src/**/composer.json') }}
74-
restore-keys: |
75-
${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}
160+
working-directory: src/${{ matrix.package.path }}
161+
dependency-versions: ${{ matrix.dependency-version || 'highest' }}
76162

77-
- name: Remove deptrac/deptrac for Symfony 8
78-
if: matrix.symfony-version == '8.0.*'
79-
run: composer remove deptrac/deptrac --dev --no-update
163+
- name: Run PHPUnit
164+
run: cd src/${{ matrix.package.path }} && vendor/bin/phpunit
80165

81-
- name: Install root dependencies
82-
uses: ramsey/composer-install@v3
166+
bridge:
167+
name: ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }} / PHP ${{ matrix.php-version }}${{ matrix.dependency-version == 'lowest' && ' / lowest' || '' }}${{ matrix.symfony-version && format(' / Symfony {0}', matrix.symfony-version) || '' }}
168+
needs: matrix
169+
runs-on: ubuntu-latest
170+
strategy:
171+
fail-fast: false
172+
matrix:
173+
bridge: ${{ fromJson(needs.matrix.outputs.bridges) }}
174+
php-version: ['8.2', '8.5']
175+
dependency-version: ['']
176+
symfony-version: ['']
83177

84-
- name: Build root packages
85-
run: php .github/build-packages.php
178+
env:
179+
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=7.4' }}
180+
181+
steps:
182+
- name: Checkout
183+
uses: actions/checkout@v6
86184

87-
- name: Run packages tests
185+
- name: Configure environment
88186
run: |
89-
source .github/workflows/.utils.sh
187+
echo COLUMNS=120 >> $GITHUB_ENV
188+
[ 'lowest' = '${{ matrix.dependency-version }}' ] && echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV || true
189+
190+
- name: Setup PHP
191+
uses: shivammathur/setup-php@v2
192+
with:
193+
php-version: ${{ matrix.php-version }}
194+
tools: flex
195+
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
196+
197+
- name: Install dependencies
198+
uses: ramsey/composer-install@v3
199+
with:
200+
working-directory: src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }}
201+
dependency-versions: ${{ matrix.dependency-version || 'highest' }}
90202

91-
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_UP && $PHPUNIT)'"
203+
- name: Run PHPUnit
204+
run: cd src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpunit

0 commit comments

Comments
 (0)