action.yaml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. name: Validate UI XML
  2. description: Validates Qt UI XML files
  3. inputs:
  4. failCondition:
  5. description: Controls whether failed checks also fail the workflow run
  6. required: false
  7. default: never
  8. workingDirectory:
  9. description: Working directory for checks
  10. required: false
  11. default: ${{ github.workspace }}
  12. runs:
  13. using: composite
  14. steps:
  15. - name: Check Runner Operating System 🏃‍♂️
  16. if: runner.os == 'Windows'
  17. shell: bash
  18. run: |
  19. : Check Runner Operating System 🏃‍♂️
  20. echo "::notice::qt-xml-validator action requires an Linux-based or macOS-based runner."
  21. exit 2
  22. - name: Install xmllint 🕵️
  23. if: runner.os == 'Linux'
  24. shell: bash
  25. run: |
  26. : Install xmllint 🕵️
  27. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  28. echo ::group::Installing libxml2-utils
  29. sudo apt-get -qq update
  30. sudo apt-get install --no-install-recommends -y libxml2-utils
  31. echo ::endgroup::
  32. - name: Register Annotations 📝
  33. uses: korelstar/xmllint-problem-matcher@1bd292d642ddf3d369d02aaa8b262834d61198c0
  34. - name: Check for Changed Files ✅
  35. uses: ./.github/actions/check-changes
  36. id: checks
  37. with:
  38. checkGlob: 'frontend/forms/**/*.ui'
  39. - name: Validate XML 💯
  40. if: fromJSON(steps.checks.outputs.hasChangedFiles)
  41. id: result
  42. shell: bash
  43. env:
  44. CHANGED_FILES: ${{ steps.checks.outputs.changedFiles }}
  45. run: |
  46. : Validate XML 💯
  47. if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
  48. CHANGED_FILES=($(echo "${CHANGED_FILES//[\[\]\'\"]/}" | tr "," "\n"))
  49. if (( ${#CHANGED_FILES[@]} )); then
  50. if [[ '${{ inputs.failCondition }}' == never ]]; then set +e; fi
  51. xmllint \
  52. --schema ${{ github.workspace }}/frontend/forms/XML-Schema-Qt5.15.xsd \
  53. --noout "${CHANGED_FILES[@]}"
  54. fi