|
1 | 1 | name: Q&A
|
2 | 2 |
|
3 | 3 | on:
|
4 |
| - pull_request: |
| 4 | + pull_request: |
5 | 5 |
|
6 | 6 | defaults:
|
7 |
| - run: |
8 |
| - shell: bash |
| 7 | + run: |
| 8 | + shell: bash |
9 | 9 |
|
10 | 10 | jobs:
|
11 | 11 |
|
12 |
| - tests: |
13 |
| - name: Checks |
14 |
| - runs-on: Ubuntu-20.04 |
15 |
| - |
16 |
| - steps: |
17 |
| - - name: Checkout |
18 |
| - uses: actions/checkout@v2 |
19 |
| - |
20 |
| - - name: No symlinks |
21 |
| - run: | |
22 |
| - SYMLINKS=$(find -type l) |
23 |
| - if [[ "" != "$SYMLINKS" ]]; then |
24 |
| - echo "::error::Symlinks are not allowed" |
25 |
| - echo "Found $SYMLINKS" |
26 |
| - fi |
| 12 | + tests: |
| 13 | + name: Checks |
| 14 | + runs-on: Ubuntu-20.04 |
| 15 | + |
| 16 | + steps: |
| 17 | + - |
| 18 | + name: Checkout |
| 19 | + uses: actions/checkout@v2 |
| 20 | + id: checkout |
| 21 | + |
| 22 | + - |
| 23 | + name: Install tools |
| 24 | + run: | |
| 25 | + cd .github |
| 26 | + wget -q -O recipes-checker.zip https://codeload.github.com/symfony-tools/recipes-checker/zip/refs/heads/main |
| 27 | + unzip recipes-checker.zip |
| 28 | + cd recipes-checker-main |
| 29 | + composer install --no-dev |
| 30 | +
|
| 31 | + - |
| 32 | + name: Check manifest.json files |
| 33 | + if: "always() && steps.checkout.outcome == 'success'" |
| 34 | + run: | |
| 35 | + .github/recipes-checker-main/run lint:manifests |
| 36 | +
|
| 37 | + - |
| 38 | + name: Remove non-patched packages |
| 39 | + if: "always() && steps.checkout.outcome == 'success'" |
| 40 | + run: | |
| 41 | + .github/recipes-checker-main/run list-unpatched-packages $GITHUB_EVENT_PATH ${{ secrets.GITHUB_TOKEN }} | xargs -n10 rm -rf |
| 42 | +
|
| 43 | + - |
| 44 | + name: No symlinks |
| 45 | + if: "always() && steps.checkout.outcome == 'success'" |
| 46 | + run: | |
| 47 | + SYMLINKS=$(find * -type l) |
| 48 | +
|
| 49 | + if [[ "" != "$SYMLINKS" ]]; then echo -e "::error::Symlinks are not allowed\nFound $SYMLINKS\n"; exit 1; fi |
| 50 | +
|
| 51 | + - |
| 52 | + name: No .yml, use .yaml |
| 53 | + if: "always() && steps.checkout.outcome == 'success'" |
| 54 | + run: | |
| 55 | + YMLS=$(find * -name '*.yml') |
| 56 | +
|
| 57 | + if [[ "" != "$YMLS" ]]; then echo -e "::error::*.yml files should renamed to *.yaml\nFound $YMLS\n"; exit 1; fi |
| 58 | +
|
| 59 | + - |
| 60 | + name: No .gitkeep, use .gitignore |
| 61 | + if: "always() && steps.checkout.outcome == 'success'" |
| 62 | + run: | |
| 63 | + GITKEEPS=$(find * -name .gitkeep) |
| 64 | +
|
| 65 | + if [[ "" != "$GITKEEPS" ]]; then echo -e "::error::.gitkeep files should be renamed to .gitignore\nFound $GITKEEPS\n"; exit 1; fi |
| 66 | +
|
| 67 | + - |
| 68 | + name: 4 spaces indentation |
| 69 | + if: "always() && steps.checkout.outcome == 'success'" |
| 70 | + run: | |
| 71 | + ERRORS=$(find * -name '*.yaml' -or -name '*.json' \ |
| 72 | + | xargs -n1 grep -P -H -n -v '^(( )*[^ \t]|$)' \ |
| 73 | + | cut -d: -f1-2 \ |
| 74 | + | sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Indendation must be a multiple of 4 spaces/' || true) |
| 75 | +
|
| 76 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
| 77 | +
|
| 78 | + - |
| 79 | + name: Text files end with a newline |
| 80 | + if: "always() && steps.checkout.outcome == 'success'" |
| 81 | + run: | |
| 82 | + ERRORS=$(find * -name '*.yaml' -or -name '*.yml' -or -name '*.txt' -or -name '*.md' -or -name '*.markdown' \ |
| 83 | + -or -name '*.json' -or -name '*.rst' -or -name '*.php' -or -name '*.js' -or -name '*.css' -or -name '*.twig' \ |
| 84 | + | xargs -n1 -I{} bash -c '[ -n "$(tail -c1 {})" ] && echo ::error file={},line=$((1 + `wc -l {} | cut -d" " -f1`))::Should end with a newline' || true) |
| 85 | +
|
| 86 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
| 87 | +
|
| 88 | + - |
| 89 | + name: Use https when referencing symfony.com |
| 90 | + if: "always() && steps.checkout.outcome == 'success'" |
| 91 | + run: | |
| 92 | + ERRORS=$(grep -H -n 'http://.*symfony\.com' * -r \ |
| 93 | + | cut -d: -f1-2 \ |
| 94 | + | sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Use https when referencing symfony.com/' || true) |
| 95 | +
|
| 96 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
| 97 | +
|
| 98 | + - |
| 99 | + name: manifest.json is found |
| 100 | + if: "always() && steps.checkout.outcome == 'success'" |
| 101 | + run: | |
| 102 | + MISSING=$(find * -mindepth 2 -maxdepth 2 -type d '!' -exec test -f '{}/manifest.json' ';' -print) |
| 103 | +
|
| 104 | + if [[ "" != "$MISSING" ]]; then echo -e "::error::Recipes must define a \"manifest.json\" file\nFile not found in $MISSING\n"; exit 1; fi |
| 105 | +
|
| 106 | + - |
| 107 | + name: JSON files are valid |
| 108 | + if: "always() && steps.checkout.outcome == 'success'" |
| 109 | + run: | |
| 110 | + 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 *}') |
| 111 | +
|
| 112 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
| 113 | +
|
| 114 | + - |
| 115 | + name: YAML files are valid |
| 116 | + if: "always() && steps.checkout.outcome == 'success'" |
| 117 | + run: | |
| 118 | + find * -name '*.yaml' -or -name '*.yml' | .github/recipes-checker-main/run lint:yaml |
| 119 | +
|
| 120 | + - |
| 121 | + name: Packages exist on packagist.org |
| 122 | + if: "always() && steps.checkout.outcome == 'success'" |
| 123 | + run: | |
| 124 | + .github/recipes-checker-main/run lint:packages |
| 125 | +
|
| 126 | + - |
| 127 | + name: Contribution is under MIT and has no merge commits |
| 128 | + if: "always() && steps.checkout.outcome == 'success'" |
| 129 | + run: | |
| 130 | + .github/recipes-checker-main/run lint:pull-request $GITHUB_EVENT_PATH ${{ secrets.GITHUB_TOKEN }} |
| 131 | +
|
| 132 | + - |
| 133 | + name: Parameters should be defined via the "container" configurator |
| 134 | + if: "always() && steps.checkout.outcome == 'success'" |
| 135 | + run: | |
| 136 | + ERRORS=$(find */*/*/config/packages/ -name '*.yaml' -or -name '*.yml' \ |
| 137 | + | xargs -n1 grep -P -H -n '^parameters:' \ |
| 138 | + | cut -d: -f1-2 \ |
| 139 | + | sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::"parameters" should be defined via the "container" configurator instead/' || true) |
| 140 | +
|
| 141 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
| 142 | +
|
| 143 | + - |
| 144 | + name: Underscore notation under config/ |
| 145 | + if: "always() && steps.checkout.outcome == 'success'" |
| 146 | + run: | |
| 147 | + ERRORS=$(find */*/*/config -type f \ |
| 148 | + | grep -v -P '[^/]+/[^/]+/[^/]+/config/[0-9a-z_./]+$' \ |
| 149 | + | xargs -n1 -I{} echo "::error file={}::Underscore notation is required for file and directory names under config/" || true) |
| 150 | +
|
| 151 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
| 152 | +
|
| 153 | + - |
| 154 | + name: Yaml nulls should not be "~" |
| 155 | + if: "always() && steps.checkout.outcome == 'success'" |
| 156 | + run: | |
| 157 | + ERRORS=$(find * -name '*.yaml' -or -name '*.yml' \ |
| 158 | + | xargs -n1 grep -F -H -n ': ~'\ |
| 159 | + | cut -d: -f1-2 \ |
| 160 | + | sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::"~" should be replaced with "null"/' || true) |
| 161 | +
|
| 162 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
| 163 | +
|
| 164 | + - |
| 165 | + name: Symfony commands should not be wrapped in a Makefile |
| 166 | + if: "always() && steps.checkout.outcome == 'success'" |
| 167 | + run: | |
| 168 | + ERRORS=$(find * -name Makefile \ |
| 169 | + | xargs -n1 grep -P -H -n 'bin/console|\$\(CONSOLE\)' \ |
| 170 | + | cut -d: -f1-2 \ |
| 171 | + | sed 's/\(.*\):\([0-9]*\)$/\\n::error file=\1,line=\2::Symfony commands should not be wrapped in a Makefile/' || true) |
| 172 | +
|
| 173 | + if [[ "" != "$ERRORS" ]]; then echo -e "$ERRORS\n"; exit 1; fi |
0 commit comments