|
| 1 | +name: Validation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'src/store/src/Bridge/**/composer.json' |
| 7 | + - 'src/ai-bundle/config/options.php' |
| 8 | + - '.github/workflows/validation.yaml' |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - 'src/store/src/Bridge/**/composer.json' |
| 12 | + - 'src/ai-bundle/config/options.php' |
| 13 | + - '.github/workflows/validation.yaml' |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + validate_stores: |
| 21 | + name: Validate Store Bridge Naming |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v5 |
| 26 | + |
| 27 | + - name: Validate store bridge naming conventions |
| 28 | + run: | |
| 29 | + #!/bin/bash |
| 30 | + set -e |
| 31 | +
|
| 32 | + ERRORS=0 |
| 33 | +
|
| 34 | + # Find all store bridges with composer.json |
| 35 | + for composer_file in src/store/src/Bridge/*/composer.json; do |
| 36 | + if [[ ! -f "$composer_file" ]]; then |
| 37 | + continue |
| 38 | + fi |
| 39 | +
|
| 40 | + # Get the bridge directory name (e.g., ChromaDb) |
| 41 | + bridge_dir=$(dirname "$composer_file") |
| 42 | + bridge_name=$(basename "$bridge_dir") |
| 43 | +
|
| 44 | + # Get the package name from composer.json |
| 45 | + package_name=$(jq -r '.name' "$composer_file") |
| 46 | +
|
| 47 | + # Expected package name format: symfony/ai-{lowercase-with-dashes}-store |
| 48 | + # Convert PascalCase to kebab-case (e.g., ChromaDb -> chroma-db) |
| 49 | + expected_kebab=$(echo "$bridge_name" | sed 's/\([a-z]\)\([A-Z]\)/\1-\2/g' | tr '[:upper:]' '[:lower:]') |
| 50 | + expected_package="symfony/ai-${expected_kebab}-store" |
| 51 | +
|
| 52 | + if [[ "$package_name" != "$expected_package" ]]; then |
| 53 | + echo "::error file=$composer_file::Package name '$package_name' does not match expected '$expected_package' for bridge '$bridge_name'" |
| 54 | + ERRORS=$((ERRORS + 1)) |
| 55 | + else |
| 56 | + echo "✓ $bridge_name: package name '$package_name' is correct" |
| 57 | + fi |
| 58 | +
|
| 59 | + # Check options.php for the config key (should be lowercase without dashes/underscores) |
| 60 | + expected_config_key=$(echo "$bridge_name" | tr '[:upper:]' '[:lower:]') |
| 61 | + options_file="src/ai-bundle/config/options.php" |
| 62 | +
|
| 63 | + if [[ -f "$options_file" ]]; then |
| 64 | + # Look for ->arrayNode('configkey') under the store section |
| 65 | + if ! grep -q -- "->arrayNode('$expected_config_key')" "$options_file"; then |
| 66 | + echo "::error file=$options_file::Missing or incorrect config key for bridge '$bridge_name'. Expected '->arrayNode('$expected_config_key')' in store configuration" |
| 67 | + ERRORS=$((ERRORS + 1)) |
| 68 | + else |
| 69 | + echo "✓ $bridge_name: config key '$expected_config_key' found in options.php" |
| 70 | + fi |
| 71 | + fi |
| 72 | + done |
| 73 | +
|
| 74 | + if [[ $ERRORS -gt 0 ]]; then |
| 75 | + echo "" |
| 76 | + echo "::error::Found $ERRORS naming convention violation(s)" |
| 77 | + exit 1 |
| 78 | + fi |
| 79 | +
|
| 80 | + echo "" |
| 81 | + echo "All store bridge naming conventions are valid!" |
0 commit comments