diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml new file mode 100644 index 0000000000..69b31b74be --- /dev/null +++ b/.github/workflows/yaml-lint.yml @@ -0,0 +1,39 @@ +--- +name: GH Action YAML linter + +on: + pull_request: + paths: + - ".github/**/**.yml" + - ".github/**/**.yaml" + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + main: + name: YAML Lint + runs-on: ubuntu-20.04 + steps: + - name: GIT | Checkout source code + uses: actions/checkout@v3 + with: + repository: Cardinal-Cryptography/aleph-node + token: ${{ secrets.CI_GH_TOKEN }} + + - name: GIT | Check diff + id: check-diff + run: | + git fetch --quiet origin ${GITHUB_BASE_REF}:refs/remotes/origin/${GITHUB_BASE_REF} + YAML_FILES=`git --no-pager diff origin/${GITHUB_BASE_REF} --name-only \ + | grep -E ".github\/.*\/.*(.yaml|.yml)" | tr '\n' ' '` + echo "Changed YAML files: ${YAML_FILES}" + echo "YAML_FILES=`echo $YAML_FILES`" >> $GITHUB_ENV + + - name: LINT | Execute yaml-lint + uses: ibiqlik/action-yamllint@v3.1.1 + with: + strict: true + file_or_dir: ${{ env.YAML_FILES }} + config_file: .yamllint diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000000..e53f35d245 --- /dev/null +++ b/.yamllint @@ -0,0 +1,57 @@ +--- +extends: default + +rules: + braces: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + max-spaces-before: 0 + max-spaces-after: 1 + commas: + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + level: warning + require-starting-space: true + min-spaces-from-content: 2 + comments-indentation: disable + document-end: disable + document-start: enable + empty-lines: + max: 2 + max-start: 1 + max-end: 1 + empty-values: + forbid-in-block-mappings: false + forbid-in-flow-mappings: false + hyphens: + max-spaces-after: 1 + indentation: + spaces: consistent + indent-sequences: true + check-multi-line-strings: false + key-duplicates: enable + key-ordering: disable + line-length: + max: 100 + level: error + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: false + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: + allowed-values: + - "true" + - "false" + check-keys: false