diff --git a/.github/workflows/repository-quality-reusable.yml b/.github/workflows/repository-quality-reusable.yml new file mode 100644 index 0000000..8601a47 --- /dev/null +++ b/.github/workflows/repository-quality-reusable.yml @@ -0,0 +1,55 @@ +name: Reusable repository quality + +on: + workflow_call: + +permissions: + contents: read + +jobs: + repository-quality: + name: repository-quality + runs-on: ubuntu-24.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Verify governance baseline + shell: bash + run: | + set -euo pipefail + for file in README.md LICENSE CONTRIBUTING.md LICENSING.md NOTICE.md; do + test -s "$file" || { + echo "::error file=$file::$file is missing or empty" + exit 1 + } + done + + - name: Reject unresolved merge markers + shell: bash + run: | + set -euo pipefail + if git grep -nE '^(<<<<<<<|=======|>>>>>>>)' -- ':!*.patch' ':!*.diff' ':!*.md' ':!**/*.md'; then + echo "::error::Unresolved merge-conflict marker detected" + exit 1 + fi + + - name: Validate tracked JSON and XML + shell: python + run: | + import json + import subprocess + import xml.etree.ElementTree as ET + + def tracked(pattern): + output = subprocess.check_output( + ["git", "ls-files", pattern], text=True + ) + return [line for line in output.splitlines() if line] + + for path in tracked("*.json"): + with open(path, encoding="utf-8") as stream: + json.load(stream) + + for path in tracked("*.xml"): + ET.parse(path) diff --git a/.github/workflows/repository-quality.yml b/.github/workflows/repository-quality.yml index 2703d9f..d01ecc4 100644 --- a/.github/workflows/repository-quality.yml +++ b/.github/workflows/repository-quality.yml @@ -10,47 +10,5 @@ permissions: jobs: repository-quality: - runs-on: ubuntu-24.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Verify governance baseline - shell: bash - run: | - set -euo pipefail - for file in README.md LICENSE CONTRIBUTING.md LICENSING.md NOTICE.md; do - test -s "$file" || { - echo "::error file=$file::$file is missing or empty" - exit 1 - } - done - - - name: Reject unresolved merge markers - shell: bash - run: | - set -euo pipefail - if git grep -nE '^(<<<<<<<|=======|>>>>>>>)' -- ':!*.patch' ':!*.diff' ':!*.md' ':!**/*.md'; then - echo "::error::Unresolved merge-conflict marker detected" - exit 1 - fi - - - name: Validate tracked JSON and XML - shell: python - run: | - import json - import subprocess - import xml.etree.ElementTree as ET - - def tracked(pattern): - output = subprocess.check_output( - ["git", "ls-files", pattern], text=True - ) - return [line for line in output.splitlines() if line] - - for path in tracked("*.json"): - with open(path, encoding="utf-8") as stream: - json.load(stream) - - for path in tracked("*.xml"): - ET.parse(path) + name: repository-quality + uses: ./.github/workflows/repository-quality-reusable.yml