From f15106cdec44036180019b0db26f70fe071b1b9b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 10 Nov 2023 20:07:22 +0100 Subject: [PATCH] GH Actions: add Yamllint to `validate` workflow ... to loosely safeguard valid and consistent yaml files and prevent issues like seen in PR 68. Includes adding a configuration file which loosens up the `default` ruleset to a degree I'm comfortable with. Ref: https://yamllint.readthedocs.io/ --- .gitattributes | 1 + .github/workflows/validate.yml | 15 +++++++++++++++ .yamllint.yml | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 .yamllint.yml diff --git a/.gitattributes b/.gitattributes index 3fd67cf09b..ca33149203 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,6 +12,7 @@ tests/ export-ignore .cspell.json export-ignore .gitattributes export-ignore .gitignore export-ignore +.yamllint.yml export-ignore phpcs.xml.dist export-ignore phpstan.neon.dist export-ignore phpunit.xml.dist export-ignore diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 2f86c5da4f..15e086be9f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -62,3 +62,18 @@ jobs: diff -B ./src/Standards/PSR12/ruleset.xml <(xmllint --format "./src/Standards/PSR12/ruleset.xml") diff -B ./src/Standards/Squiz/ruleset.xml <(xmllint --format "./src/Standards/Squiz/ruleset.xml") diff -B ./src/Standards/Zend/ruleset.xml <(xmllint --format "./src/Standards/Zend/ruleset.xml") + + yamllint: + name: 'Lint Yaml' + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run Yamllint on all yaml files in repo + run: yamllint . --format colored --strict + + - name: Pipe Yamllint results on to GH for inline display + if: ${{ failure() }} + run: yamllint . --format github --strict diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 0000000000..76ea3dce5f --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,23 @@ +# Details on the default config: +# https://yamllint.readthedocs.io/en/stable/configuration.html#default-configuration +extends: default + +yaml-files: + - '*.yaml' + - '*.yml' + - '.yamllint' + - 'phpstan.neon' + +# Rule documentation: https://yamllint.readthedocs.io/en/stable/rules.html +rules: + colons: + max-spaces-after: -1 # Disabled to allow aligning of values. + comments: + min-spaces-from-content: 1 + comments-indentation: {} + document-start: + present: false + line-length: + max: 150 + truthy: + allowed-values: ["true", "false", "on", "off"]