Skip to content

Commit 0de5a7d

Browse files
Add reusable workflows
0 parents  commit 0de5a7d

File tree

3 files changed

+343
-0
lines changed

3 files changed

+343
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Cleanup Flex testing endpoint
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
flex-cleanup:
8+
name: Cleanup Flex testing endpoint
9+
runs-on: Ubuntu-20.04
10+
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v2
15+
16+
-
17+
name: Cleanup Flex testing endpoint
18+
run: |
19+
git push origin :flex/pull-${{ github.event.number }} || true
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Update Flex endpoint
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
default: main
8+
required: false
9+
type: string
10+
contrib:
11+
required: false
12+
type: boolean
13+
versions_json:
14+
required: false
15+
type: string
16+
17+
jobs:
18+
flex-update:
19+
name: Update Flex endpoint
20+
runs-on: Ubuntu-20.04
21+
22+
steps:
23+
-
24+
name: Checkout
25+
uses: actions/checkout@v2
26+
id: checkout
27+
with:
28+
fetch-depth: 0
29+
30+
-
31+
name: Install tools
32+
run: |
33+
git config --global user.email ""
34+
git config --global user.name "github-action[bot]"
35+
cd .github
36+
wget -q -O recipes-checker.zip https://codeload.github.com/symfony-tools/recipes-checker/zip/refs/heads/main
37+
unzip recipes-checker.zip
38+
cd recipes-checker-main
39+
composer install --ansi --no-dev
40+
41+
-
42+
name: Update Flex endpoint
43+
run: |
44+
mkdir .github/flex-endpoint
45+
git ls-tree HEAD */*/* | php .github/recipes-checker-main/run generate:flex-endpoint ${{ github.repository }} ${{ inputs.branch }} flex/main .github/flex-endpoint ${{ inputs.versions_json }} ${{ inputs.contrib && '--contrib' || '' }}
46+
git switch flex/main
47+
git rm -q *.json
48+
mv .github/flex-endpoint/*.json .
49+
git add *.json
50+
git commit -m 'Update Flex endpoint' || true
51+
git push origin -f flex/main

.github/workflows/callable-qa.yml

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
name: Q&A
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
default: main
8+
required: false
9+
type: string
10+
contrib:
11+
required: false
12+
type: boolean
13+
find_yaml:
14+
required: false
15+
type: string
16+
create_project_php:
17+
default: '7.4'
18+
required: false
19+
type: string
20+
21+
jobs:
22+
run-checks:
23+
name: Run checks
24+
runs-on: Ubuntu-20.04
25+
26+
steps:
27+
-
28+
name: Checkout
29+
uses: actions/checkout@v2
30+
id: checkout
31+
with:
32+
fetch-depth: 0
33+
ref: 'refs/pull/${{ github.event.number }}/merge'
34+
35+
-
36+
name: Install tools
37+
run: |
38+
git config --global user.email ""
39+
git config --global user.name "github-action[bot]"
40+
cd .github
41+
wget -q -O recipes-checker.zip https://codeload.github.com/symfony-tools/recipes-checker/zip/refs/heads/main
42+
unzip recipes-checker.zip
43+
cd recipes-checker-main
44+
composer install --ansi --no-dev
45+
46+
-
47+
name: Check manifest.json files
48+
if: "always() && steps.checkout.outcome == 'success'"
49+
run: |
50+
.github/recipes-checker-main/run lint:manifests ${{ inputs.contrib && '--contrib' || '' }}
51+
52+
-
53+
name: Remove non-patched packages
54+
if: "always() && steps.checkout.outcome == 'success'"
55+
run: |
56+
.github/recipes-checker-main/run list-unpatched-packages $GITHUB_EVENT_PATH ${{ secrets.GITHUB_TOKEN }} | xargs -r -n10 rm -rf
57+
58+
-
59+
name: Generate Flex testing endpoint
60+
if: "always() && steps.checkout.outcome == 'success' && github.base_ref == inputs.branch"
61+
run: |
62+
mkdir .github/flex-endpoint
63+
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' || '' }}
64+
git stash
65+
git switch -c pr
66+
git switch --orphan flex/pull-${{ github.event.number }}
67+
git reset --hard -q
68+
mv .github/flex-endpoint/*.json .
69+
git add *.json
70+
git commit -m 'Create Flex endpoint' || true
71+
git push origin -f flex/pull-${{ github.event.number }}
72+
git switch pr
73+
git stash pop -q
74+
75+
-
76+
name: Compute diff between recipe versions
77+
if: "always() && steps.checkout.outcome == 'success'"
78+
run: |
79+
find * -mindepth 1 -maxdepth 1 -type d | sort \
80+
| .github/recipes-checker-main/run diff-recipe-versions 'https://api.github.com/repos/${{ github.repository }}/contents/index.json?ref=flex/pull-${{ github.event.number }}' \
81+
> .github/diff-recipe-versions.md
82+
83+
-
84+
name: Post diff between recipe versions
85+
if: "always() && steps.checkout.outcome == 'success'"
86+
uses: marocchino/sticky-pull-request-comment@v2
87+
with:
88+
path: .github/diff-recipe-versions.md
89+
90+
-
91+
name: No symlinks
92+
if: "always() && steps.checkout.outcome == 'success'"
93+
run: |
94+
SYMLINKS=$(find * -type l)
95+
96+
if [[ "" != "$SYMLINKS" ]]; then echo -e "::error::Symlinks are not allowed\nFound $SYMLINKS\n"; exit 1; fi
97+
98+
-
99+
name: No .yml, use .yaml
100+
if: "always() && steps.checkout.outcome == 'success'"
101+
run: |
102+
YMLS=$(find * -name '*.yml' ${{ inputs.find_yaml }})
103+
104+
if [[ "" != "$YMLS" ]]; then echo -e "::error::*.yml files should renamed to *.yaml\nFound $YMLS\n"; exit 1; fi
105+
106+
-
107+
name: No .gitkeep, use .gitignore
108+
if: "always() && steps.checkout.outcome == 'success'"
109+
run: |
110+
GITKEEPS=$(find * -name .gitkeep)
111+
112+
if [[ "" != "$GITKEEPS" ]]; then echo -e "::error::.gitkeep files should be renamed to .gitignore\nFound $GITKEEPS\n"; exit 1; fi
113+
114+
-
115+
name: 4 spaces indentation
116+
if: "always() && steps.checkout.outcome == 'success'"
117+
run: |
118+
ERRORS=$(find * -name '*.yaml' -or -name '*.json' \
119+
| xargs -n1 grep -P -H -n -v '^(( )*[^ \t]|$)' \
120+
| cut -d: -f1-2 \
121+
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Indendation must be a multiple of 4 spaces/' || true)
122+
123+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
124+
125+
-
126+
name: Text files end with a newline
127+
if: "always() && steps.checkout.outcome == 'success'"
128+
run: |
129+
ERRORS=$(find * -name '*.yaml' -or -name '*.yml' -or -name '*.txt' -or -name '*.md' -or -name '*.markdown' \
130+
-or -name '*.json' -or -name '*.rst' -or -name '*.php' -or -name '*.js' -or -name '*.css' -or -name '*.twig' \
131+
| xargs -n1 -I{} bash -c '[ -n "$(tail -c1 {})" ] && echo ::error file={},line=$((1 + `wc -l {} | cut -d" " -f1`))::Should end with a newline' || true)
132+
133+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
134+
135+
-
136+
name: Use https when referencing symfony.com
137+
if: "always() && steps.checkout.outcome == 'success'"
138+
run: |
139+
ERRORS=$(grep -H -n 'http://.*symfony\.com' * -r \
140+
| cut -d: -f1-2 \
141+
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Use https when referencing symfony.com/' || true)
142+
143+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
144+
145+
-
146+
name: manifest.json is found
147+
if: "always() && steps.checkout.outcome == 'success'"
148+
run: |
149+
MISSING=$(find * -mindepth 2 -maxdepth 2 -type d '!' -exec test -f '{}/manifest.json' ';' -print)
150+
151+
if [[ "" != "$MISSING" ]]; then echo -e "::error::Recipes must define a \"manifest.json\" file\nFile not found in $MISSING\n"; exit 1; fi
152+
153+
-
154+
name: JSON files are valid
155+
if: "always() && steps.checkout.outcome == 'success'"
156+
run: |
157+
ERRORS=$(find * -name '*.json' | parallel -j+3 -i{} -n1 bash -c 'ERR=$(python -mjson.tool {} 2>&1 1> /dev/null) || echo \\n::error file={},line=`echo "${ERR#*: line }" | cut -d" " -f 1`::${ERR%%: line *}')
158+
159+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
160+
161+
-
162+
name: YAML files are valid
163+
if: "always() && steps.checkout.outcome == 'success'"
164+
run: |
165+
find * -name '*.yaml' -or -name '*.yml' | .github/recipes-checker-main/run lint:yaml
166+
167+
-
168+
name: Packages exist on packagist.org
169+
if: "always() && steps.checkout.outcome == 'success'"
170+
run: |
171+
.github/recipes-checker-main/run lint:packages
172+
173+
-
174+
name: Contribution is under MIT and has no merge commits
175+
if: "always() && steps.checkout.outcome == 'success'"
176+
run: |
177+
.github/recipes-checker-main/run lint:pull-request $GITHUB_EVENT_PATH ${{ secrets.GITHUB_TOKEN }}
178+
179+
-
180+
name: Parameters should be defined via the "container" configurator
181+
if: "always() && steps.checkout.outcome == 'success'"
182+
run: |
183+
ERRORS=$(find */*/*/config/packages/ -name '*.yaml' -or -name '*.yml' \
184+
| xargs -n1 grep -P -H -n '^parameters:' \
185+
| cut -d: -f1-2 \
186+
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::"parameters" should be defined via the "container" configurator instead/' || true)
187+
188+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
189+
190+
-
191+
name: Underscore notation under config/
192+
if: "always() && steps.checkout.outcome == 'success'"
193+
run: |
194+
ERRORS=$(find */*/*/config -type f \
195+
| grep -v -P '[^/]+/[^/]+/[^/]+/config/[0-9a-z_./]+$' \
196+
| xargs -n1 -I{} echo "::error file={}::Underscore notation is required for file and directory names under config/" || true)
197+
198+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
199+
200+
-
201+
name: Yaml nulls should not be "~"
202+
if: "always() && steps.checkout.outcome == 'success'"
203+
run: |
204+
ERRORS=$(find * -name '*.yaml' -or -name '*.yml' \
205+
| xargs -n1 grep -F -H -n ': ~'\
206+
| cut -d: -f1-2 \
207+
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::"~" should be replaced with "null"/' || true)
208+
209+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
210+
211+
-
212+
name: Symfony commands should not be wrapped in a Makefile
213+
if: "always() && steps.checkout.outcome == 'success'"
214+
run: |
215+
ERRORS=$(find * -name Makefile \
216+
| xargs -n1 grep -P -H -n 'bin/console|\$\(CONSOLE\)' \
217+
| cut -d: -f1-2 \
218+
| sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Symfony commands should not be wrapped in a Makefile/' || true)
219+
220+
if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi
221+
222+
create-project:
223+
needs: run-checks
224+
name: Run updated recipes
225+
runs-on: Ubuntu-20.04
226+
227+
steps:
228+
-
229+
name: Setup PHP
230+
uses: shivammathur/setup-php@v2
231+
with:
232+
coverage: "none"
233+
php-version: "${{ inputs.create_project_php }}"
234+
235+
-
236+
name: Export configuration
237+
continue-on-error: true
238+
id: config
239+
run: |
240+
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(" ")')
241+
echo PACKAGES=$PACKAGES >> $GITHUB_ENV
242+
[[ "" != "$PACKAGES" ]]
243+
244+
-
245+
name: Create-project with skeleton ^4
246+
if: "always() && steps.config.outcome == 'success'"
247+
run: |
248+
set -x
249+
composer create-project --ansi "symfony/skeleton:^4" v4
250+
cd v4
251+
composer config extra.symfony.allow-contrib ${{ inputs.contrib && 'true' || 'false' }}
252+
composer config minimum-stability dev
253+
export SYMFONY_ENDPOINT=https://api.github.com/repos/${{ github.repository }}/contents/index.json?ref=flex/pull-${{ github.event.number }}
254+
composer require -W --ansi $PACKAGES
255+
EXIT_CODE=$?
256+
257+
if [[ EXIT_CODE -eq 2 ]]; then
258+
echo -e "\n#\n#\n# You can ignore this error if your package does not support Symfony 4\n#\n#\n#\n"
259+
fi
260+
261+
exit $EXIT_CODE
262+
263+
-
264+
name: Create-project with skeleton ^5
265+
if: "always() && steps.config.outcome == 'success'"
266+
run: |
267+
set -x
268+
composer create-project --ansi "symfony/skeleton:^5" v5
269+
cd v5
270+
composer config extra.symfony.allow-contrib ${{ inputs.contrib && 'true' || 'false' }}
271+
composer config minimum-stability dev
272+
export SYMFONY_ENDPOINT=https://api.github.com/repos/${{ github.repository }}/contents/index.json?ref=flex/pull-${{ github.event.number }}
273+
composer require -W --ansi $PACKAGES

0 commit comments

Comments
 (0)