diff --git a/.github/workflows/toolkit-kits-code-quality.yaml b/.github/workflows/toolkit-kits-code-quality.yaml deleted file mode 100644 index 0ed5ccfc968..00000000000 --- a/.github/workflows/toolkit-kits-code-quality.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Toolkit Kits Code Quality - -on: - push: - paths: - - 'src/Toolkit/kits/**' - pull_request: - paths: - - 'src/Toolkit/kits/**' - -jobs: - kits-cs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - - - name: Install composer packages - uses: ramsey/composer-install@v3 - with: - working-directory: src/Toolkit - - - name: Check kits code style - run: php vendor/bin/twig-cs-fixer check kits - working-directory: src/Toolkit diff --git a/.github/workflows/toolkit-kits-lint.yaml b/.github/workflows/toolkit-kits-lint.yaml new file mode 100644 index 00000000000..e6708b56451 --- /dev/null +++ b/.github/workflows/toolkit-kits-lint.yaml @@ -0,0 +1,50 @@ +name: Toolkit Kits Linting + +on: + push: + paths: + - 'src/Toolkit/**' + - '.github/workflows/toolkit-kits-lint.yaml' + pull_request: + paths: + - 'src/Toolkit/**' + - '.github/workflows/toolkit-kits-lint.yaml' + +jobs: + get-matrix: + runs-on: ubuntu-latest + outputs: + kits: ${{ steps.set-kits.outputs.kits }} + steps: + - uses: actions/checkout@v4 + + - name: Set kits output + id: set-kits + run: | + KITS_JSON=$(find src/Toolkit/kits -mindepth 1 -maxdepth 1 -type d -printf '"%f",' | sed 's/,$//') + echo "kits=[${KITS_JSON}]" >> $GITHUB_OUTPUT + + lint: + runs-on: ubuntu-latest + needs: get-matrix + strategy: + fail-fast: false + matrix: + kit: ${{ fromJson(needs.get-matrix.outputs.kits) }} + + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + + - name: Install composer packages + uses: ramsey/composer-install@v3 + with: + working-directory: src/Toolkit + + - name: Ensure Twig files are nicely formatted + run: php vendor/bin/twig-cs-fixer lint kits/${{ matrix.kit }} + working-directory: src/Toolkit diff --git a/src/Toolkit/.twig-cs-fixer.dist.php b/src/Toolkit/.twig-cs-fixer.dist.php new file mode 100644 index 00000000000..7507f17c83c --- /dev/null +++ b/src/Toolkit/.twig-cs-fixer.dist.php @@ -0,0 +1,19 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +$ruleset = new TwigCsFixer\Ruleset\Ruleset(); +$ruleset->addStandard(new TwigCsFixer\Standard\TwigCsFixer()); + +$config = new TwigCsFixer\Config\Config(); +$config->setCacheFile('.twig-cs-fixer.cache'); +$config->setRuleset($ruleset); + +return $config; diff --git a/src/Toolkit/composer.json b/src/Toolkit/composer.json index 1b8a15949b8..b8b991a7f83 100644 --- a/src/Toolkit/composer.json +++ b/src/Toolkit/composer.json @@ -45,7 +45,7 @@ "symfony/http-client": "6.4|^7.0|^8.0", "symfony/stopwatch": "^6.4|^7.0|^8.0", "symfony/phpunit-bridge": "^7.2|^8.0", - "vincentlanglet/twig-cs-fixer": "^3.5", + "vincentlanglet/twig-cs-fixer": "^3.9", "spatie/phpunit-snapshot-assertions": "^4.2.17", "phpunit/phpunit": "^9.6.22", "symfony/ux-icons": "^2.18", diff --git a/src/Toolkit/kits/shadcn/templates/components/Alert.html.twig b/src/Toolkit/kits/shadcn/templates/components/Alert.html.twig index d5ae97b9894..cee7937e9e7 100644 --- a/src/Toolkit/kits/shadcn/templates/components/Alert.html.twig +++ b/src/Toolkit/kits/shadcn/templates/components/Alert.html.twig @@ -10,7 +10,7 @@ ) -%}