When the internal git reference is nonexistent, GitHub Actions seems to convert that value into a hash made up of only zeroes. As that hash will be commit-ish it will pass verification. git cat-file will fail if the provided reference cannot be resolved in the repository so should be the safer choice.
69 lines
2.3 KiB
YAML
69 lines
2.3 KiB
YAML
name: Validate UI XML
|
|
description: Validates Qt UI XML files
|
|
inputs:
|
|
failCondition:
|
|
description: Controls whether failed checks also fail the workflow run
|
|
required: false
|
|
default: never
|
|
workingDirectory:
|
|
description: Working directory for checks
|
|
required: false
|
|
default: ${{ github.workspace }}
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Check Runner Operating System 🏃♂️
|
|
if: runner.os == 'Windows'
|
|
shell: bash
|
|
run: |
|
|
: Check Runner Operating System 🏃♂️
|
|
echo "::notice::qt-xml-validator action requires an Linux-based or macOS-based runner."
|
|
exit 2
|
|
|
|
- name: Install xmllint 🕵️
|
|
if: runner.os == 'Linux'
|
|
shell: bash
|
|
run: |
|
|
: Install xmllint 🕵️
|
|
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
|
|
|
|
echo ::group::Installing libxml2-utils
|
|
sudo apt-get -qq update
|
|
sudo apt-get install --no-install-recommends -y libxml2-utils
|
|
echo ::endgroup::
|
|
|
|
- name: Register Annotations 📝
|
|
uses: korelstar/xmllint-problem-matcher@22352420d1d3e8f18d311d76284c4f5f71982222
|
|
|
|
- name: Validate XML 💯
|
|
shell: bash
|
|
env:
|
|
GITHUB_EVENT_FORCED: ${{ github.event.forced }}
|
|
GITHUB_REF_BEFORE: ${{ github.event.before }}
|
|
run: |
|
|
: Validate XML 💯
|
|
if [[ "${RUNNER_DEBUG}" ]]; then set -x; fi
|
|
shopt -s extglob
|
|
shopt -s globstar
|
|
|
|
if ! git cat-file -e "${GITHUB_REF_BEFORE}" &> /dev/null; then
|
|
GITHUB_REF_BEFORE='4b825dc642cb6eb9a060e54bf8d69288fbee4904'
|
|
fi
|
|
|
|
changes=($(git diff --name-only HEAD~1 HEAD -- UI/forms/**/*.ui))
|
|
case "${GITHUB_EVENT_NAME}" in
|
|
pull_request) changes=($(git diff --name-only origin/"${GITHUB_BASE_REF}" HEAD -- UI/forms/**/*.ui)) ;;
|
|
push)
|
|
if [[ "${GITHUB_EVENT_FORCED}" == false ]]; then
|
|
changes=($(git diff --name-only ${GITHUB_REF_BEFORE} HEAD -- UI/forms/**/*.ui))
|
|
fi
|
|
;;
|
|
*) ;;
|
|
esac
|
|
|
|
if (( ${#changes[@]} )); then
|
|
if [[ '${{ inputs.failCondition }}' == never ]]; then set +e; fi
|
|
xmllint \
|
|
--schema ${{ github.workspace }}/UI/forms/XML-Schema-Qt5.15.xsd \
|
|
--noout "${changes[@]}"
|
|
fi
|