Update GitHub action #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Bundle Installation Test in a Symfony Project | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - dev | |
| pull_request: | |
| branches: | |
| - main | |
| - dev | |
| jobs: | |
| install-test: | |
| name: Symfony ${{ matrix.symfony }} / PHP ${{ matrix.php }} | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - php: '8.1' | |
| symfony: '6.4.*' | |
| - php: '8.2' | |
| symfony: '6.4.*' | |
| - php: '8.3' | |
| symfony: '6.4.*' | |
| # Symfony 7.x | |
| - php: '8.2' | |
| symfony: '7.1.*' | |
| - php: '8.3' | |
| symfony: '7.2.*' | |
| - php: '8.4' | |
| symfony: '7.2.*' | |
| # Symfony 8.x | |
| - php: '8.4' | |
| symfony: '8.0.*' | |
| steps: | |
| - name: Checkout bundle | |
| uses: actions/checkout@v4 | |
| with: | |
| path: bundle | |
| - name: Checkout recipes-contrib | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: symfony/recipes-contrib | |
| path: recipes-contrib | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| extensions: mbstring, xml, ctype, iconv, intl, dom, filter, json | |
| env: | |
| update: true | |
| - name: Check PHP Version | |
| run: php -v | |
| - name: Create Symfony project | |
| run: | | |
| composer create-project symfony/skeleton:"${{ matrix.symfony }}" test-project --no-interaction --prefer-dist | |
| cd test-project | |
| composer require symfony/framework-bundle symfony/twig-bundle symfony/yaml --no-interaction | |
| - name: Configure composer to use local bundle | |
| working-directory: test-project | |
| run: | | |
| composer config repositories.local '{"type": "path", "url": "../bundle", "options": {"symlink": true}}' | |
| composer config minimum-stability dev | |
| composer config prefer-stable true | |
| - name: Install the bundle | |
| working-directory: test-project | |
| run: | | |
| composer require ehyiah/apidoc-bundle:@dev --no-interaction | |
| - name: Apply recipe manually from recipes-contrib | |
| working-directory: test-project | |
| run: | | |
| RECIPE_PATH="../recipes-contrib/ehyiah/apidoc-bundle" | |
| # Find the latest version of the recipe | |
| RECIPE_VERSION=$(ls -1 "$RECIPE_PATH" | sort -V | tail -n1) | |
| echo "Applying recipe version: $RECIPE_VERSION" | |
| RECIPE_DIR="$RECIPE_PATH/$RECIPE_VERSION" | |
| # Copy recipe files if they exist | |
| if [ -d "$RECIPE_DIR" ]; then | |
| # Copy config files | |
| if [ -d "$RECIPE_DIR/config" ]; then | |
| cp -rv "$RECIPE_DIR/config/"* config/ 2>/dev/null || true | |
| fi | |
| # Copy src files | |
| if [ -d "$RECIPE_DIR/src" ]; then | |
| cp -rv "$RECIPE_DIR/src/"* src/ 2>/dev/null || true | |
| fi | |
| # Apply manifest.json env vars to .env | |
| if [ -f "$RECIPE_DIR/manifest.json" ]; then | |
| echo "Processing manifest.json..." | |
| ENV_VARS=$(cat "$RECIPE_DIR/manifest.json" | python3 -c "import sys,json; m=json.load(sys.stdin); [print(f'{k}={v}') for k,v in m.get('env',{}).items()]" 2>/dev/null || true) | |
| if [ -n "$ENV_VARS" ]; then | |
| echo "" >> .env | |
| echo "###> ehyiah/apidoc-bundle ###" >> .env | |
| echo "$ENV_VARS" >> .env | |
| echo "###< ehyiah/apidoc-bundle ###" >> .env | |
| fi | |
| fi | |
| echo "✓ Recipe applied successfully" | |
| else | |
| echo "✗ Recipe directory not found: $RECIPE_DIR" | |
| ls -la "$RECIPE_PATH" || true | |
| fi | |
| - name: Verify recipe files | |
| working-directory: test-project | |
| run: | | |
| echo "Checking recipe files..." | |
| test -f config/routes/ehyiah_api_doc.yaml && echo "✓ Routes file created" || echo "✗ Routes file missing" | |
| test -d src/Swagger && echo "✓ Swagger directory created" || echo "✗ Swagger directory missing" | |
| test -f .env && grep -q "APIDOC" .env && echo "✓ Environment variables added" || echo "✗ Environment variables missing" | |
| ls -la config/routes/ || true | |
| ls -la src/Swagger/ || true | |
| echo "--- .env content ---" | |
| cat .env | grep -A5 "apidoc-bundle" || true | |
| - name: Verify bundle is registered | |
| working-directory: test-project | |
| run: | | |
| php bin/console debug:container --env=dev | grep -i "ehyiah" || echo "Checking services..." | |
| php bin/console debug:container Ehyiah\\ApiDocBundle\\Controller\\ApiDocController --env=dev | |
| - name: Verify routes are registered | |
| working-directory: test-project | |
| run: | | |
| php bin/console debug:router --env=dev | grep -i "apidoc" || php bin/console debug:router --env=dev | |
| - name: Verify commands are available | |
| working-directory: test-project | |
| run: | | |
| php bin/console list apidocbundle --env=dev | |
| - name: Test generate command | |
| working-directory: test-project | |
| run: | | |
| mkdir -p src/Swagger | |
| php bin/console apidocbundle:api-doc:generate --format=json --env=dev || true | |
| - name: Clear cache (smoke test) | |
| working-directory: test-project | |
| run: | | |
| php bin/console cache:clear --env=dev | |
| php bin/console cache:clear --env=prod |