diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e69dbe2a..4375aab5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,6 +1,12 @@ name: Continuous Integration on: + push: + branches: + - main + paths-ignore: + - "docs/**" + - "*.md" pull_request: paths-ignore: - "docs/**" @@ -8,20 +14,74 @@ on: workflow_dispatch: ~ workflow_call: ~ +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - static-checks: + static-analysis: + name: "Static Analysis & Quality" + runs-on: ubuntu-latest + env: + APP_ENV: test + COMPOSER_ROOT_VERSION: "dev-main" + steps: + - name: "Checkout" + uses: actions/checkout@v7 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: "8.4" + tools: "symfony, composer:v2" + coverage: none + + - name: "Get Composer cache directory" + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Setup Composer cache" + uses: actions/cache@v6 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php8.4-static-${{ hashFiles('composer.json') }} + restore-keys: | + ${{ runner.os }}-php8.4-static- + + - name: "Install dependencies" + run: composer update --no-interaction --no-scripts --prefer-dist --no-progress + + - name: "Validate composer.json" + run: composer validate --strict --no-check-version + + - name: "Check for security vulnerabilities" + run: symfony security:check + + - name: "Validate coding standard" + run: vendor/bin/ecs check + + - name: "Validate package versions" + run: vendor/bin/monorepo-builder validate + + - name: "Run PHPStan" + run: vendor/bin/phpstan analyse + + app-tests: + name: "App Tests (PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }})" runs-on: ubuntu-latest strategy: fail-fast: false matrix: - php: [ "8.2", "8.3" ] - postgres: [ "16" ] - symfony: [ "^6.4", "^7.4" ] + php: ["8.2", "8.3"] + postgres: ["16"] + symfony: ["^6.4", "^7.4"] include: - - php: '8.4' - postgres: "14.6" + - php: "8.4" + postgres: "16" symfony: "^8.1" - name: "PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }}" env: APP_ENV: test COMPOSER_ROOT_VERSION: "dev-main" @@ -39,162 +99,168 @@ jobs: --health-cmd="pg_isready -U postgres" --health-interval=10s --health-timeout=5s - --health-retries=5 + --health-retries=5 steps: - - name: "Checkout" - uses: actions/checkout@v3 - - - name: "Setup PHP" - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ matrix.php }}" - tools: 'symfony, composer:v2, flex' - coverage: none - - - name: Shutdown default MySQL - run: sudo service mysql stop - - - name: "Restrict packages' versions" - run: composer config extra.symfony.require "${{ matrix.symfony }}" - - - name: Get Composer cache directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - - - name: "Setup cache" - uses: actions/cache@v3 - with: - path: | - ${{ steps.composer-cache.outputs.dir }} - key: ${{ github.run_id }}-${{ runner.os }}-${{ hashFiles('composer.json') }}-symfony-${{ matrix.symfony }} - - - name: "Install dependencies" - run: composer update --no-interaction --no-scripts - - - name: "Validate composer.json" - run: composer validate --strict --no-check-version - - - name: "Check for security vulnerabilities" - run: symfony security:check - - - name: "Validate coding standard" - run: vendor/bin/ecs check - - - name: "Validate Container" - run: bin/console lint:container - - - name: Validate Package versions - run: vendor/bin/monorepo-builder validate - - - name: Run PHPStan - run: vendor/bin/phpstan analyse - - - name: Create Testing database - run: | - bin/console doctrine:database:create - bin/console doctrine:schema:create - - - name: "Install & compile assets" - run: | - bin/console importmap:install - bin/console tailwind:build - bin/console asset-map:compile - - - name: Run PHPUnit - run: vendor/bin/phpunit - - - name: Run Translations Test Suite with PHPUnit - run: | - APP_LOCALE=fr vendor/bin/phpunit --testsuite="TranslationsTestSuite" - - - name: "Restrict packages' versions (Admin Ui)" + - name: "Checkout" + uses: actions/checkout@v7 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + extensions: pdo_pgsql, intl + tools: "symfony, composer:v2, flex" + coverage: none + + - name: "Shutdown default MySQL" + run: sudo service mysql stop + + - name: "Restrict packages' versions" + run: composer config extra.symfony.require "${{ matrix.symfony }}" + + - name: "Get Composer cache directory" + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Setup Composer cache" + uses: actions/cache@v6 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php${{ matrix.php }}-symfony-${{ matrix.symfony }}-${{ hashFiles('composer.json') }} + restore-keys: | + ${{ runner.os }}-php${{ matrix.php }}-symfony-${{ matrix.symfony }}- + ${{ runner.os }}-php${{ matrix.php }}- + + - name: "Install dependencies" + run: composer update --no-interaction --no-scripts --prefer-dist --no-progress + + - name: "Validate Container" + run: bin/console lint:container + + - name: "Create testing database" run: | - (cd src/AdminUi/ && composer config --no-plugins allow-plugins.symfony/runtime true) - (cd src/AdminUi/ && composer config extra.symfony.require "${{ matrix.symfony }}") - - - name: "Install dependencies (Admin Ui)" - run: (cd src/AdminUi/ && composer update --no-interaction --no-scripts) - - - name: Run PHPUnit (Admin Ui) - run: (cd src/AdminUi/ && vendor/bin/phpunit) + bin/console doctrine:database:create + bin/console doctrine:schema:create - - name: "Restrict packages' versions (Bootstrap Admin Ui)" + - name: "Install & compile assets" run: | - (cd src/BootstrapAdminUi/ && composer config --no-plugins allow-plugins.symfony/runtime true) - (cd src/BootstrapAdminUi/ && composer config extra.symfony.require "${{ matrix.symfony }}") - - - name: "Install dependencies (Bootstrap Admin Ui)" - run: (cd src/BootstrapAdminUi/ && composer update --no-interaction --no-scripts) - - - name: Run PHPUnit (Bootstrap Admin Ui) - run: (cd src/BootstrapAdminUi/ && vendor/bin/phpunit) + bin/console importmap:install + bin/console tailwind:build + bin/console asset-map:compile - - name: Setup Node.js for Bootstrap Admin UI tests - if: matrix.php == '8.3' && matrix.symfony == '^7.4' - uses: actions/setup-node@v4 - with: - node-version: '24' + - name: "Run PHPUnit" + run: vendor/bin/phpunit - - name: Run JavaScript tests (Bootstrap Admin UI) - if: matrix.php == '8.3' && matrix.symfony == '^7.4' - working-directory: src/BootstrapAdminUi - run: | - yarn install --frozen-lockfile --non-interactive - yarn test + - name: "Run Translations Test Suite" + env: + APP_LOCALE: fr + run: vendor/bin/phpunit --testsuite="TranslationsTestSuite" - - name: "Restrict packages' versions (Shadcn Admin Ui)" + packages-tests: + name: "${{ matrix.package }} (PHP ${{ matrix.php }} / Symfony ${{ matrix.symfony }})" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: + - AdminUi + - BootstrapAdminUi + - ShadcnAdminUi + - TwigHooks + - TwigExtra + - UiTranslations + php: ["8.2", "8.3"] + symfony: ["^6.4", "^7.4"] + include: + - package: AdminUi + php: "8.4" + symfony: "^8.1" + - package: BootstrapAdminUi + php: "8.4" + symfony: "^8.1" + - package: ShadcnAdminUi + php: "8.4" + symfony: "^8.1" + - package: TwigHooks + php: "8.4" + symfony: "^8.1" + - package: TwigExtra + php: "8.4" + symfony: "^8.1" + - package: UiTranslations + php: "8.4" + symfony: "^8.1" + env: + APP_ENV: test + COMPOSER_ROOT_VERSION: "dev-main" + defaults: + run: + working-directory: src/${{ matrix.package }} + steps: + - name: "Checkout" + uses: actions/checkout@v7 + + - name: "Setup PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: "${{ matrix.php }}" + tools: "composer:v2, flex" + coverage: none + + - name: "Get Composer cache directory" + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Setup Composer cache" + uses: actions/cache@v6 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-pkg-${{ matrix.package }}-php${{ matrix.php }}-symfony-${{ matrix.symfony }}-${{ hashFiles(format('src/{0}/composer.json', matrix.package)) }} + restore-keys: | + ${{ runner.os }}-pkg-${{ matrix.package }}-php${{ matrix.php }}- + ${{ runner.os }}-php${{ matrix.php }}- + + - name: "Configure Composer & Symfony constraints" run: | - (cd src/ShadcnAdminUi/ && composer config --no-plugins allow-plugins.symfony/runtime true) - (cd src/ShadcnAdminUi/ && composer config extra.symfony.require "${{ matrix.symfony }}") - - - name: "Install dependencies (Shadcn Admin Ui)" - run: (cd src/ShadcnAdminUi/ && composer update --no-interaction --no-scripts) - - - name: "Build the assets (Shadcn Admin Ui)" - run: | - (cd src/ShadcnAdminUi/ && APP_ENV=test php tests/Functional/.application/bin/console importmap:install) - (cd src/ShadcnAdminUi/ && APP_ENV=test php tests/Functional/.application/bin/console tailwind:build) + composer config --no-plugins allow-plugins.symfony/runtime true + composer config extra.symfony.require "${{ matrix.symfony }}" - - name: Run PHPUnit (Shadcn Admin Ui) - run: (cd src/ShadcnAdminUi/ && vendor/bin/phpunit) + - name: "Install dependencies" + run: composer update --no-interaction --no-scripts --prefer-dist --no-progress - - name: Run JavaScript tests (Shadcn Admin UI) - if: matrix.php == '8.3' && matrix.symfony == '^7.4' - working-directory: src/ShadcnAdminUi - run: | - yarn install --frozen-lockfile --non-interactive - yarn test - - - name: "Restrict packages' versions (Twig Hooks)" + - name: "Build assets (ShadcnAdminUi)" + if: matrix.package == 'ShadcnAdminUi' run: | - (cd src/TwigHooks/ && composer config --no-plugins allow-plugins.symfony/runtime true) - (cd src/TwigHooks/ && composer config extra.symfony.require "${{ matrix.symfony }}") - - - name: "Install dependencies (Twig Hooks)" - run: (cd src/TwigHooks/ && composer update --no-interaction --no-scripts) + php tests/Functional/.application/bin/console importmap:install + php tests/Functional/.application/bin/console tailwind:build - - name: Run PHPUnit (Twig Hooks) - run: (cd src/TwigHooks/ && vendor/bin/phpunit) - - - name: "Restrict packages' versions (Twig Extra)" - run: | - (cd src/TwigExtra/ && composer config --no-plugins allow-plugins.symfony/runtime true) - (cd src/TwigExtra/ && composer config extra.symfony.require "${{ matrix.symfony }}") + - name: "Run PHPUnit" + run: vendor/bin/phpunit - - name: "Install dependencies (Twig Extra)" - run: (cd src/TwigExtra/ && composer update --no-interaction --no-scripts) + js-tests: + name: "JS Tests (${{ matrix.package }})" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: + - BootstrapAdminUi + - ShadcnAdminUi + defaults: + run: + working-directory: src/${{ matrix.package }} + steps: + - name: "Checkout" + uses: actions/checkout@v7 - - name: Run PHPUnit (Twig Extra) - run: (cd src/TwigExtra/ && vendor/bin/phpunit) + - name: "Setup Node.js" + uses: actions/setup-node@v7 + with: + node-version: "24" + cache: "yarn" + cache-dependency-path: src/${{ matrix.package }}/yarn.lock - - name: "Restrict packages' versions (Ui Translations)" + - name: "Install dependencies & run tests" run: | - (cd src/UiTranslations/ && composer config --no-plugins allow-plugins.symfony/runtime true) - (cd src/UiTranslations/ && composer config extra.symfony.require "${{ matrix.symfony }}") - - - name: "Install dependencies (Ui Translations)" - run: (cd src/UiTranslations/ && composer update --no-interaction --no-scripts) - - - name: Run PHPUnit (Ui Translations) - run: (cd src/UiTranslations/ && vendor/bin/phpunit) - + yarn install --frozen-lockfile --non-interactive + yarn test