-
-
Notifications
You must be signed in to change notification settings - Fork 406
228 lines (196 loc) · 9.79 KB
/
code-quality.yaml
File metadata and controls
228 lines (196 loc) · 9.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Code Quality
on:
push:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
- '.github/workflows/app-tests.yaml'
pull_request:
paths-ignore:
- 'src/*/doc/**'
- 'src/**/*.md'
- '.github/workflows/app-tests.yaml'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
validate-packages:
name: Validate packages definition
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check all composer.json have label "symfony-ux"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '.keywords | index("symfony-ux")' "$file" > /dev/null; then
echo "File $file does not have the keyword 'symfony-ux' in its composer.json";
exit 1;
fi
done
- name: Check all composer.json have license "MIT"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '.license == "MIT"' "$file" > /dev/null; then
echo "File $file does not have the license 'MIT' in its composer.json";
exit 1;
fi
done
- name: Check all composer.json have minimum-stability "dev"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '."minimum-stability" == "dev"' "$file" > /dev/null; then
echo "File $file does not have the minimum-stability 'dev' in its composer.json";
exit 1;
fi
done
- name: Check all composer.json have dependency to "php" >=8.1
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name composer.json); do
if ! jq -e '.require.php | test(">=8.1")' "$file" > /dev/null; then
echo "File $file does not have the dependency 'php' >=8.1 in its composer.json";
exit 1;
fi
done
- name: Check all package.json have license "MIT"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.license == "MIT"' "$file" > /dev/null; then
echo "File $file does not have the license 'MIT' in its package.json";
exit 1;
fi
done
- name: Check all package.json have keywords including "symfony-ux"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.keywords | index("symfony-ux")' "$file" > /dev/null; then
echo "File $file does not have the keyword 'symfony-ux' in its package.json";
exit 1;
fi
done
- name: Check all package.json have type "module"
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.type == "module"' "$file" > /dev/null; then
echo "File $file does not have the type 'module' in its package.json";
exit 1;
fi
done
- name: Check all package.json have files '["dist"]'
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
if ! jq -e '.files | index("dist")' "$file" > /dev/null; then
echo "File $file does not have the files 'dist' in its package.json";
exit 1;
fi
done
- name: Check all package.json peerDependencies are present in devDependencies and importmap to the exact same version
if: always()
run: |
for file in $(find src/ -mindepth 2 -type f -name package.json -not -path "*/tests/*"); do
peerDependencies=$(jq -r '.peerDependencies | keys[]' "$file")
for peerDependency in $peerDependencies; do
peerDependencyVersion=$(jq -r --arg dep "$peerDependency" '.peerDependencies[$dep]' "$file")
importmapVersion=$(jq -r ".symfony.importmap.\"$peerDependency\" | if type == \"string\" then . else .version end" "$file")
if [ "$importmapVersion" == null ]; then
echo "File $file does not have the peerDependency '$peerDependency' in its symfony.importmap, skipping version check";
continue
fi
if [ "$peerDependencyVersion" != "$importmapVersion" ]; then
echo "File $file has a mismatch for $peerDependency: peerDependency version is '$peerDependencyVersion' but symfony.importmap version is '$importmapVersion'";
exit 1;
fi
done
done
code-format-js:
name: JavaScript Coding Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm i -g corepack && corepack enable
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install root JS dependencies
run: pnpm install --frozen-lockfile
- run: pnpm run fmt:check
code-linting-js:
name: JavaScript Coding Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm i -g corepack && corepack enable
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install root JS dependencies
run: pnpm install --frozen-lockfile
- run: pnpm run lint
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1']
dependency-version: ['']
symfony-version: ['']
minimum-stability: ['stable']
include:
# dev packages (probably not needed to have multiple such jobs)
- minimum-stability: 'dev'
php-version: 8.5
# lowest deps
- dependency-version: 'lowest'
# LTS version of Symfony
- symfony-version: '6.4.*'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure environment
run: |
echo COLUMNS=120 >> $GITHUB_ENV
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
echo PHPUNIT_INSTALL='vendor/bin/simple-phpunit install' >> $GITHUB_ENV
echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV
# TODO: Only Turbo has PHPStan configuration, let's improve this later :)
PACKAGES=Turbo
#PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -printf '%h\n' | sed 's/^src\///' | sort | tr '\n' ' ')
echo "Packages: $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: flex
- name: Get composer cache directory
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache packages dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}-${{ hashFiles('src/**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-packages-${{ matrix.php-version }}-${{ matrix.dependency-version }}-${{ matrix.symfony-version }}-${{ matrix.minimum-stability }}
- name: Install root dependencies
uses: ramsey/composer-install@v3
with:
working-directory: ${{ github.workspace }}
- name: Build root packages
run: php .github/build-packages.php
- name: Run PHPStan on packages
run: |
source .github/workflows/.utils.sh
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT_INSTALL && $PHPSTAN)'"