yamllint 940 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  4. source "${SCRIPTDIR}/.validate"
  5. if [ -n "${TEST_FORCE_VALIDATE:-}" ]; then
  6. files=(docs/api/*.yaml)
  7. else
  8. IFS=$'\n'
  9. files=($(validate_diff --diff-filter=ACMR --name-only -- docs/*.yaml || true))
  10. unset IFS
  11. fi
  12. # validate the yamllint configuration file before anything else
  13. if out=$(yamllint -f parsable -d "{extends: default, rules: {document-start: disable}}" "${SCRIPTDIR}"/yamllint.yaml); then
  14. echo "Congratulations! yamllint config file formatted correctly"
  15. else
  16. echo "${out}" >&2
  17. false
  18. fi
  19. # Then validate GitHub actions workflows, and conditionally lint the swagger
  20. # files in the docs directory, as these are large files and take some time.
  21. if out=$(yamllint -f parsable -c "${SCRIPTDIR}"/yamllint.yaml .github/workflows/*.yml "${files[@]}"); then
  22. echo "Congratulations! YAML files are formatted correctly"
  23. else
  24. echo "${out}" >&2
  25. false
  26. fi