Skip to content

[Platform] Add FailoverPlatform #6585

[Platform] Add FailoverPlatform

[Platform] Add FailoverPlatform #6585

Workflow file for this run

name: Code Quality
on:
push:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
pull_request:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
PHP_VERSION: '8.5'
REQUIRED_PHP_EXTENSIONS: 'mongodb, redis'
jobs:
phpstan-matrix:
name: PHPStan / Matrix
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set-matrix.outputs.packages }}
bridges: ${{ steps.set-matrix.outputs.bridges }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set matrix
id: set-matrix
run: |
# Helper function to convert "ai-bundle" to "AI Bundle"
to_title() {
echo "$1" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1' \
| sed 's/\bAi\b/AI/g; s/\bMcp\b/MCP/g'
}
# Packages (components and bundles)
PACKAGES="[]"
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
if [[ "$pkg" == *-bundle ]]; then
type="Bundle"
else
type="Component"
fi
name=$(to_title "$pkg")
PACKAGES=$(echo "$PACKAGES" | jq -c --arg path "$pkg" --arg type "$type" --arg name "$name" '. + [{path: $path, type: $type, name: $name}]')
done
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
# Bridges (store, tool, and platform)
STORE_BRIDGES=$(find src/store/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})')
TOOL_BRIDGES=$(find src/agent/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "agent", type: "Tool", bridge: .})')
PLATFORM_BRIDGES=$(find src/platform/src/Bridge/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort \
| jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "platform", type: "Platform", bridge: .})')
BRIDGES=$(jq -n -c --argjson store "$STORE_BRIDGES" --argjson tool "$TOOL_BRIDGES" --argjson platform "$PLATFORM_BRIDGES" '$store + $tool + $platform')
echo "bridges=$BRIDGES" >> $GITHUB_OUTPUT
# Pretty print for info
echo "### Packages"
echo "$PACKAGES" | jq .
echo ""
echo "### Bridges"
echo "$BRIDGES" | jq .
phpstan-demo:
needs: phpstan-matrix
name: PHPStan / Demo
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
- name: Install root dependencies
uses: ramsey/composer-install@v3
- name: Build root packages
run: php .github/build-packages.php
- name: Install dependencies
uses: ramsey/composer-install@v3
with:
working-directory: demo
- name: Link packages
run: cd demo && ../link
- name: Run PHPStan
run: cd demo && vendor/bin/phpstan
phpstan-examples:
needs: phpstan-matrix
name: PHPStan / Examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
- name: Install root dependencies
uses: ramsey/composer-install@v3
- name: Build root packages
run: php .github/build-packages.php
- name: Install dependencies
uses: ramsey/composer-install@v3
with:
working-directory: examples
- name: Link packages
run: cd examples && ../link
- name: Run PHPStan
run: cd examples && vendor/bin/phpstan
phpstan-package:
name: PHPStan / ${{ matrix.package.type }} / ${{ matrix.package.name }}
needs: phpstan-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{ fromJson(needs.phpstan-matrix.outputs.packages) }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
- name: Install dependencies
uses: ramsey/composer-install@v3
with:
working-directory: src/${{ matrix.package.path }}
- name: Run PHPStan
run: cd src/${{ matrix.package.path }} && vendor/bin/phpstan
phpstan-bridge:
name: PHPStan / ${{ matrix.bridge.type }} / ${{ matrix.bridge.bridge }}
needs: phpstan-matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
bridge: ${{ fromJson(needs.phpstan-matrix.outputs.bridges) }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: ${{ env.REQUIRED_PHP_EXTENSIONS }}
- name: Install root dependencies (platform bridges only)
if: matrix.bridge.component == 'platform'
uses: ramsey/composer-install@v3
- name: Build root packages (platform bridges only)
if: matrix.bridge.component == 'platform'
run: php .github/build-packages.php
# Remove root vendor and bridge vendor to avoid circular symlinks when installing bridge dependencies
- name: Clean vendor folders (platform bridges only)
if: matrix.bridge.component == 'platform'
run: rm -rf vendor src/platform/src/Bridge/${{ matrix.bridge.bridge }}/vendor
- name: Install dependencies
uses: ramsey/composer-install@v3
with:
working-directory: src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }}
- name: Run PHPStan
run: cd src/${{ matrix.bridge.component }}/src/Bridge/${{ matrix.bridge.bridge }} && vendor/bin/phpstan