-
-
Notifications
You must be signed in to change notification settings - Fork 481
290 lines (245 loc) · 13.1 KB
/
callable-qa.yml
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
name: Q&A
on:
workflow_call:
inputs:
branch:
default: main
required: false
type: string
contrib:
required: false
type: boolean
find_yaml:
required: false
type: string
secrets:
token:
required: true
jobs:
run-checks:
name: Run checks
runs-on: Ubuntu-20.04
steps:
-
name: Checkout
uses: actions/checkout@v3
id: checkout
with:
fetch-depth: 0
ref: 'refs/pull/${{ github.event.number }}/merge'
-
name: Install tools
run: |
git config --global user.email ""
git config --global user.name "github-action[bot]"
cd .github
wget -q -O recipes-checker.zip https://codeload.github.com/symfony-tools/recipes-checker/zip/refs/heads/main
unzip recipes-checker.zip
cd recipes-checker-main
composer install --ansi --no-dev
-
name: Check manifest.json files
if: "always() && steps.checkout.outcome == 'success'"
run: |
.github/recipes-checker-main/run lint:manifests ${{ inputs.contrib && '--contrib' || '' }}
-
name: Remove non-patched packages
if: "always() && steps.checkout.outcome == 'success'"
run: |
.github/recipes-checker-main/run list-unpatched-packages $GITHUB_EVENT_PATH ${{ secrets.token }} | xargs -r -n10 rm -rf
-
name: Generate Flex testing endpoint
if: "always() && steps.checkout.outcome == 'success' && github.base_ref == inputs.branch"
run: |
mkdir .github/flex-endpoint
git ls-tree HEAD */*/* | php .github/recipes-checker-main/run generate:flex-endpoint ${{ github.repository }} ${{ inputs.branch }} flex/pull-${{ github.event.number }} .github/flex-endpoint ${{ inputs.contrib && '--contrib' || '' }}
git stash
git switch -c pr
git switch --orphan flex/pull-${{ github.event.number }}
git reset --hard -q
mv .github/flex-endpoint/*.json .
git add *.json
git commit -m 'Create Flex endpoint' || true
git push origin -f flex/pull-${{ github.event.number }}
git switch pr
git stash pop -q
-
name: Enable Automerge
if: "always() && steps.checkout.outcome == 'success'"
run: gh pr merge --auto --squash ${{ github.event.number }}
env:
GITHUB_TOKEN: ${{ secrets.token }}
-
name: Compute diff between recipe versions
if: "always() && steps.checkout.outcome == 'success'"
run: |
find * -mindepth 1 -maxdepth 1 -type d | sort \
| .github/recipes-checker-main/run diff-recipe-versions 'https://raw.githubusercontent.com/${{ github.repository }}/flex/pull-${{ github.event.number }}/index.json' \
> .github/diff-recipe-versions.md
-
name: Post diff between recipe versions
if: "always() && steps.checkout.outcome == 'success'"
uses: marocchino/sticky-pull-request-comment@v2
with:
path: .github/diff-recipe-versions.md
-
name: No symlinks
if: "always() && steps.checkout.outcome == 'success'"
run: |
SYMLINKS=$(find * -type l)
if [[ "" != "$SYMLINKS" ]]; then echo -e "::error::Symlinks are not allowed\nFound $SYMLINKS\n"; exit 1; fi
-
name: No .yml, use .yaml
if: "always() && steps.checkout.outcome == 'success'"
run: |
YMLS=$(find * -name '*.yml' ${{ inputs.find_yaml }})
if [[ "" != "$YMLS" ]]; then echo -e "::error::*.yml files should renamed to *.yaml\nFound $YMLS\n"; exit 1; fi
-
name: No .gitkeep, use .gitignore
if: "always() && steps.checkout.outcome == 'success'"
run: |
GITKEEPS=$(find * -name .gitkeep)
if [[ "" != "$GITKEEPS" ]]; then echo -e "::error::.gitkeep files should be renamed to .gitignore\nFound $GITKEEPS\n"; exit 1; fi
-
name: 4 spaces indentation
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(find * -name '*.yaml' -or -name '*.json' \
| xargs -n1 grep -P -H -n -v '^(( )*[^ \t]|$)' \
| cut -d: -f1-2 \
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Indendation must be a multiple of 4 spaces/' || true)
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
-
name: Text files end with a newline
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(find * -name '*.yaml' -or -name '*.yml' -or -name '*.txt' -or -name '*.md' -or -name '*.markdown' \
-or -name '*.json' -or -name '*.rst' -or -name '*.php' -or -name '*.js' -or -name '*.css' -or -name '*.twig' \
| xargs -n1 -P0 bash -c '[ -n "$(tail -c1 "$0")" ] && echo ::error file="$0",line=$((1 + `wc -l "$0" | cut -d" " -f1`))::Should end with a newline' || true)
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
-
name: Use https when referencing symfony.com
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(grep -H -n 'http://.*symfony\.com' * -r \
| cut -d: -f1-2 \
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Use https when referencing symfony.com/' || true)
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
-
name: manifest.json is found
if: "always() && steps.checkout.outcome == 'success'"
run: |
MISSING=$(find * -mindepth 2 -maxdepth 2 -type d '!' -exec test -f '{}/manifest.json' ';' -print)
if [[ "" != "$MISSING" ]]; then echo -e "::error::Recipes must define a \"manifest.json\" file\nFile not found in $MISSING\n"; exit 1; fi
-
name: JSON files are valid
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(find * -name '*.json' | xargs -n1 -P0 bash -c 'ERR=$(cd / && python -mjson.tool '$(pwd)'/"$0" 2>&1 1> /dev/null) || echo \\n::error file="$0",line=`echo "${ERR#*: line }" | cut -d" " -f 1`::${ERR%%: line *}')
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
-
name: YAML files are valid
if: "always() && steps.checkout.outcome == 'success'"
run: |
find * -name '*.yaml' -or -name '*.yml' | .github/recipes-checker-main/run lint:yaml
-
name: Packages exist on packagist.org
if: "always() && steps.checkout.outcome == 'success'"
run: |
.github/recipes-checker-main/run lint:packages
-
name: Contribution is under MIT and has no merge commits
if: "always() && steps.checkout.outcome == 'success'"
run: |
.github/recipes-checker-main/run lint:pull-request --license=MIT $GITHUB_EVENT_PATH ${{ secrets.token }}
-
name: Parameters should be defined via the "container" configurator
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(find */*/*/config/packages/ -name '*.yaml' -or -name '*.yml' \
| xargs -n1 grep -P -H -n '^parameters:' \
| cut -d: -f1-2 \
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::"parameters" should be defined via the "container" configurator instead/' || true)
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
-
name: Underscore notation under config/
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(find */*/*/config -type f \
| grep -v -P '[^/]+/[^/]+/[^/]+/config/[0-9a-z_./]+$' \
| xargs -n1 -I{} echo "::error file={}::Underscore notation is required for file and directory names under config/" || true)
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
-
name: Yaml nulls should not be "~"
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(find * -name '*.yaml' -or -name '*.yml' \
| xargs -n1 grep -F -H -n ': ~'\
| cut -d: -f1-2 \
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::"~" should be replaced with "null"/' || true)
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
-
name: Symfony commands should not be wrapped in a Makefile
if: "always() && steps.checkout.outcome == 'success'"
run: |
ERRORS=$(find * -name Makefile \
| xargs -n1 grep -P -H -n 'bin/console|\$\(CONSOLE\)' \
| cut -d: -f1-2 \
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Symfony commands should not be wrapped in a Makefile/' || true)
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
create-project:
needs: run-checks
name: Run updated recipes
runs-on: Ubuntu-20.04
steps:
-
name: Export configuration
continue-on-error: true
id: config
run: |
PACKAGES=$(curl -s https://raw.githubusercontent.com/${{ github.repository }}/flex/pull-${{ github.event.number }}/index.json | jq -r '.recipes | to_entries | map(.key+":^"+.value[-1]) | join(" ")')
echo PACKAGES=$PACKAGES >> $GITHUB_ENV
[[ "" != "$PACKAGES" ]]
-
name: Setup PHP 7.4
if: "always() && steps.config.outcome == 'success'"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "7.4"
-
name: Create-project with skeleton ^5
if: "always() && steps.config.outcome == 'success'"
run: |
set -x
php -v
composer create-project --ansi "symfony/skeleton:^5" v5
cd v5
composer config extra.symfony.allow-contrib ${{ inputs.contrib && 'true' || 'false' }}
composer config minimum-stability dev
export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/${{ github.repository }}/flex/pull-${{ github.event.number }}/index.json
composer require -W --ansi $PACKAGES
EXIT_CODE=$?
if [[ EXIT_CODE -eq 2 ]]; then
echo -e "\n#\n#\n# You can ignore this error if your package does not support Symfony 5\n#\n#\n#\n"
fi
exit $EXIT_CODE
-
name: Setup PHP 8.1
if: "always() && steps.config.outcome == 'success'"
uses: shivammathur/setup-php@v2
with:
coverage: "none"
php-version: "8.1"
-
name: Create-project with skeleton ^6
if: "always() && steps.config.outcome == 'success'"
run: |
set -x
php -v
composer create-project --ansi "symfony/skeleton:^6" v6
cd v6
composer config extra.symfony.allow-contrib ${{ inputs.contrib && 'true' || 'false' }}
composer config minimum-stability dev
export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/${{ github.repository }}/flex/pull-${{ github.event.number }}/index.json
composer require -W --ansi $PACKAGES