Skip to content

Commit 2e63612

Browse files
committed
[Toolkit][CI] Improve CI workflows for linting Kits
1 parent c523696 commit 2e63612

File tree

8 files changed

+74
-33
lines changed

8 files changed

+74
-33
lines changed

.github/workflows/toolkit-kits-code-quality.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Toolkit Kits Linting
2+
3+
on:
4+
push:
5+
paths:
6+
- 'src/Toolkit/**'
7+
- '.github/workflows/toolkit-kits-lint.yaml'
8+
pull_request:
9+
paths:
10+
- 'src/Toolkit/**'
11+
- '.github/workflows/toolkit-kits-lint.yaml'
12+
13+
jobs:
14+
get-matrix:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
kits: ${{ steps.set-kits.outputs.kits }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set kits output
22+
id: set-kits
23+
run: |
24+
KITS_JSON=$(find src/Toolkit/kits -mindepth 1 -maxdepth 1 -type d -printf '"%f",' | sed 's/,$//')
25+
echo "kits=[${KITS_JSON}]" >> $GITHUB_OUTPUT
26+
27+
lint:
28+
runs-on: ubuntu-latest
29+
needs: get-matrix
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
kit: ${{ fromJson(needs.get-matrix.outputs.kits) }}
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: 8.1
42+
43+
- name: Install composer packages
44+
uses: ramsey/composer-install@v3
45+
with:
46+
working-directory: src/Toolkit
47+
48+
- name: Ensure Twig files are nicely formatted
49+
run: php vendor/bin/twig-cs-fixer lint kits/${{ matrix.kit }}
50+
working-directory: src/Toolkit

src/Toolkit/.twig-cs-fixer.dist.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
$ruleset = new TwigCsFixer\Ruleset\Ruleset();
13+
$ruleset->addStandard(new TwigCsFixer\Standard\TwigCsFixer());
14+
15+
$config = new TwigCsFixer\Config\Config();
16+
$config->setCacheFile('.twig-cs-fixer.cache');
17+
$config->setRuleset($ruleset);
18+
19+
return $config;

src/Toolkit/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"symfony/http-client": "6.4|^7.0|^8.0",
4646
"symfony/stopwatch": "^6.4|^7.0|^8.0",
4747
"symfony/phpunit-bridge": "^7.2|^8.0",
48-
"vincentlanglet/twig-cs-fixer": "^3.5",
48+
"vincentlanglet/twig-cs-fixer": "^3.9",
4949
"spatie/phpunit-snapshot-assertions": "^4.2.17",
5050
"phpunit/phpunit": "^9.6.22",
5151
"symfony/ux-icons": "^2.18",

src/Toolkit/kits/shadcn/templates/components/Alert.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
) -%}
1111

1212
<div
13-
class="{{ style.apply({variant}, attributes.render('class'))|tailwind_merge }}"
13+
class="{{ style.apply({variant: variant}, attributes.render('class'))|tailwind_merge }}"
1414
role="alert"
1515
{{ attributes }}
1616
>

src/Toolkit/kits/shadcn/templates/components/Badge.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
) -%}
1313
<div
14-
class="{{ style.apply({variant, outline}, attributes.render('class'))|tailwind_merge }}"
14+
class="{{ style.apply({variant: variant, outline: outline}, attributes.render('class'))|tailwind_merge }}"
1515
{{ attributes }}
1616
>
1717
{%- block content %}{% endblock -%}

src/Toolkit/kits/shadcn/templates/components/Button.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
) -%}
2121

2222
<{{ as }}
23-
class="{{ style.apply({variant, outline, size}, attributes.render('class'))|tailwind_merge }}"
23+
class="{{ style.apply({variant: variant, outline: outline, size: size}, attributes.render('class'))|tailwind_merge }}"
2424
{{ attributes }}
2525
>
2626
{%- block content %}{% endblock -%}

src/Toolkit/kits/shadcn/templates/components/Separator.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
) -%}
1111
<div
12-
class="{{ style.apply({orientation, decorative}, attributes.render('class'))|tailwind_merge }}"
12+
class="{{ style.apply({orientation: orientation, decorative: decorative}, attributes.render('class'))|tailwind_merge }}"
1313
{{ attributes.defaults({
1414
role: decorative ? 'none' : 'separator',
1515
'aria-orientation': decorative ? false : orientation,

0 commit comments

Comments
 (0)