|
| 1 | +name: Build Matrix |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + outputs: |
| 6 | + packages: |
| 7 | + description: 'List of packages (components and bundles)' |
| 8 | + value: ${{ jobs.matrix.outputs.packages }} |
| 9 | + packages-include: |
| 10 | + description: 'Package includes for test matrix' |
| 11 | + value: ${{ jobs.matrix.outputs.packages-include }} |
| 12 | + bridges: |
| 13 | + description: 'Combined list of all bridges' |
| 14 | + value: ${{ jobs.matrix.outputs.bridges }} |
| 15 | + store-bridges: |
| 16 | + description: 'List of store bridges' |
| 17 | + value: ${{ jobs.matrix.outputs.store-bridges }} |
| 18 | + store-bridges-include: |
| 19 | + description: 'Store bridge includes for test matrix' |
| 20 | + value: ${{ jobs.matrix.outputs.store-bridges-include }} |
| 21 | + tool-bridges: |
| 22 | + description: 'List of tool bridges' |
| 23 | + value: ${{ jobs.matrix.outputs.tool-bridges }} |
| 24 | + tool-bridges-include: |
| 25 | + description: 'Tool bridge includes for test matrix' |
| 26 | + value: ${{ jobs.matrix.outputs.tool-bridges-include }} |
| 27 | + platform-bridges: |
| 28 | + description: 'List of platform bridges' |
| 29 | + value: ${{ jobs.matrix.outputs.platform-bridges }} |
| 30 | + platform-bridges-include: |
| 31 | + description: 'Platform bridge includes for test matrix' |
| 32 | + value: ${{ jobs.matrix.outputs.platform-bridges-include }} |
| 33 | + |
| 34 | +jobs: |
| 35 | + matrix: |
| 36 | + name: Build |
| 37 | + runs-on: ubuntu-latest |
| 38 | + outputs: |
| 39 | + packages: ${{ steps.set-matrix.outputs.packages }} |
| 40 | + packages-include: ${{ steps.set-matrix.outputs.packages-include }} |
| 41 | + bridges: ${{ steps.set-matrix.outputs.bridges }} |
| 42 | + store-bridges: ${{ steps.set-matrix.outputs.store-bridges }} |
| 43 | + store-bridges-include: ${{ steps.set-matrix.outputs.store-bridges-include }} |
| 44 | + tool-bridges: ${{ steps.set-matrix.outputs.tool-bridges }} |
| 45 | + tool-bridges-include: ${{ steps.set-matrix.outputs.tool-bridges-include }} |
| 46 | + platform-bridges: ${{ steps.set-matrix.outputs.platform-bridges }} |
| 47 | + platform-bridges-include: ${{ steps.set-matrix.outputs.platform-bridges-include }} |
| 48 | + steps: |
| 49 | + - name: Checkout |
| 50 | + uses: actions/checkout@v6 |
| 51 | + |
| 52 | + - name: Set matrix |
| 53 | + id: set-matrix |
| 54 | + run: | |
| 55 | + # Helper function to convert "ai-bundle" to "AI Bundle" |
| 56 | + to_title() { |
| 57 | + echo "$1" | sed 's/-/ /g' | awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2)}1' \ |
| 58 | + | sed 's/\bAi\b/AI/g; s/\bMcp\b/MCP/g' |
| 59 | + } |
| 60 | +
|
| 61 | + # Packages (components and bundles) |
| 62 | + PACKAGES="[]" |
| 63 | + 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 |
| 64 | + if [[ "$pkg" == *-bundle ]]; then |
| 65 | + type="Bundle" |
| 66 | + else |
| 67 | + type="Component" |
| 68 | + fi |
| 69 | + name=$(to_title "$pkg") |
| 70 | + PACKAGES=$(echo "$PACKAGES" | jq -c --arg path "$pkg" --arg type "$type" --arg name "$name" '. + [{path: $path, type: $type, name: $name}]') |
| 71 | + done |
| 72 | + echo "packages=$PACKAGES" >> $GITHUB_OUTPUT |
| 73 | +
|
| 74 | + # Bridges |
| 75 | + STORE_BRIDGES=$(ls -1 src/store/src/Bridge/ | sort \ |
| 76 | + | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "store", type: "Store", bridge: .})') |
| 77 | + TOOL_BRIDGES=$(ls -1 src/agent/src/Bridge/ | sort \ |
| 78 | + | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "agent", type: "Tool", bridge: .})') |
| 79 | + PLATFORM_BRIDGES=$(ls -1 src/platform/src/Bridge/ | sort \ |
| 80 | + | jq -R -s -c 'split("\n") | map(select(length > 0)) | map({component: "platform", type: "Platform", bridge: .})') |
| 81 | +
|
| 82 | + # Combined bridges (for code-quality) |
| 83 | + BRIDGES=$(jq -n -c --argjson store "$STORE_BRIDGES" --argjson tool "$TOOL_BRIDGES" --argjson platform "$PLATFORM_BRIDGES" '$store + $tool + $platform') |
| 84 | + echo "bridges=$BRIDGES" >> $GITHUB_OUTPUT |
| 85 | +
|
| 86 | + # Individual bridges without type (for tests) |
| 87 | + echo "store-bridges=$(echo "$STORE_BRIDGES" | jq -c 'map(del(.type))')" >> $GITHUB_OUTPUT |
| 88 | + echo "tool-bridges=$(echo "$TOOL_BRIDGES" | jq -c 'map(del(.type))')" >> $GITHUB_OUTPUT |
| 89 | + echo "platform-bridges=$(echo "$PLATFORM_BRIDGES" | jq -c 'map({bridge: .bridge})')" >> $GITHUB_OUTPUT |
| 90 | +
|
| 91 | + # Package includes (lowest, Symfony 7.4, Symfony 8.0) |
| 92 | + PACKAGES_INCLUDE=$(echo "$PACKAGES" | jq -c ' |
| 93 | + . as $pkgs | |
| 94 | + ($pkgs | map(. + {"php-version": "8.2", "dependency-version": "lowest"})) + |
| 95 | + ($pkgs | map(. + {"php-version": "8.2", "symfony-version": "7.4.*"})) + |
| 96 | + ($pkgs | map(. + {"php-version": "8.5", "symfony-version": "8.0.*"})) |
| 97 | + | map({package: {path: .path, type: .type, name: .name}} + (. | del(.path, .type, .name))) |
| 98 | + ') |
| 99 | + echo "packages-include=$PACKAGES_INCLUDE" >> $GITHUB_OUTPUT |
| 100 | +
|
| 101 | + # Store bridge includes |
| 102 | + STORE_BRIDGES_INCLUDE=$(echo "$STORE_BRIDGES" | jq -c ' |
| 103 | + map(del(.type)) as $bridges | |
| 104 | + ($bridges | map(. + {"php-version": "8.2", "dependency-version": "lowest"})) + |
| 105 | + ($bridges | map(. + {"php-version": "8.2", "symfony-version": "7.4.*"})) + |
| 106 | + ($bridges | map(. + {"php-version": "8.5", "symfony-version": "8.0.*"})) |
| 107 | + | map({bridge: {component: .component, bridge: .bridge}} + (. | del(.component, .bridge))) |
| 108 | + ') |
| 109 | + echo "store-bridges-include=$STORE_BRIDGES_INCLUDE" >> $GITHUB_OUTPUT |
| 110 | +
|
| 111 | + # Tool bridge includes |
| 112 | + TOOL_BRIDGES_INCLUDE=$(echo "$TOOL_BRIDGES" | jq -c ' |
| 113 | + map(del(.type)) as $bridges | |
| 114 | + ($bridges | map(. + {"php-version": "8.2", "dependency-version": "lowest"})) + |
| 115 | + ($bridges | map(. + {"php-version": "8.2", "symfony-version": "7.4.*"})) + |
| 116 | + ($bridges | map(. + {"php-version": "8.5", "symfony-version": "8.0.*"})) |
| 117 | + | map({bridge: {component: .component, bridge: .bridge}} + (. | del(.component, .bridge))) |
| 118 | + ') |
| 119 | + echo "tool-bridges-include=$TOOL_BRIDGES_INCLUDE" >> $GITHUB_OUTPUT |
| 120 | +
|
| 121 | + # Platform bridge includes |
| 122 | + PLATFORM_BRIDGES_INCLUDE=$(echo "$PLATFORM_BRIDGES" | jq -c ' |
| 123 | + map({bridge: .bridge}) as $bridges | |
| 124 | + ($bridges | map(. + {"php-version": "8.2", "dependency-version": "lowest"})) + |
| 125 | + ($bridges | map(. + {"php-version": "8.2", "symfony-version": "7.4.*"})) + |
| 126 | + ($bridges | map(. + {"php-version": "8.5", "symfony-version": "8.0.*"})) |
| 127 | + | map({bridge: {bridge: .bridge}} + (. | del(.bridge))) |
| 128 | + ') |
| 129 | + echo "platform-bridges-include=$PLATFORM_BRIDGES_INCLUDE" >> $GITHUB_OUTPUT |
| 130 | +
|
| 131 | + # Pretty print |
| 132 | + echo "::group::Packages" |
| 133 | + echo "$PACKAGES" | jq . |
| 134 | + echo "::endgroup::" |
| 135 | + echo "::group::Bridges" |
| 136 | + echo "$BRIDGES" | jq . |
| 137 | + echo "::endgroup::" |
0 commit comments