diff --git a/.github/workflows/hygiene.yml b/.github/workflows/hygiene.yml new file mode 100644 index 0000000..585eec3 --- /dev/null +++ b/.github/workflows/hygiene.yml @@ -0,0 +1,43 @@ +name: Repository hygiene + +# Fast checks on tracked files that need no Rust toolchain and no network: +# merge-conflict markers, broken relative Markdown links and invalid workflow +# YAML (scripts/audit/docs_hygiene.py). A second, advisory step warns when +# source or script changes arrive without a CHANGELOG.md update; it never fails. + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +concurrency: + group: hygiene-${{ github.ref }} + cancel-in-progress: true + +jobs: + hygiene: + name: Repository hygiene + runs-on: ubuntu-24.04-arm + timeout-minutes: 5 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + fetch-depth: 0 + - name: Install PyYAML + run: python3 -c 'import yaml' 2>/dev/null || python3 -m pip install --user --break-system-packages pyyaml + - name: Check documentation and workflow files + run: python3 scripts/audit/docs_hygiene.py --require-yaml + - name: Remind about the changelog (advisory) + if: github.event_name == 'pull_request' + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + changed="$(git diff --name-only "$BASE_SHA"...HEAD || true)" + if printf '%s\n' "$changed" | grep -Eq '^(crates|scripts|shaders|fixtures)/' \ + && ! printf '%s\n' "$changed" | grep -qx 'CHANGELOG.md'; then + echo "::warning title=Changelog::Source or script files changed without a CHANGELOG.md update." + fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 4948cdb..321161a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ exact revision and known limitations. Guest execution uses original, purpose-built test programs. Commercial Xbox game execution remains unsupported. +### Added +- Added a fast "Repository hygiene" check (`.github/workflows/hygiene.yml`, `scripts/audit/docs_hygiene.py`). It runs on Ubuntu without a Rust toolchain or network access and fails only on merge-conflict markers, broken relative Markdown links and invalid workflow YAML in tracked files. A separate advisory step warns, without failing, when source or script changes have no changelog entry. A local run over the 626 tracked files found no problems, and planted failures of each kind were caught; it has not yet run on GitHub. + ### Removed - Removed the "PR template" check (`.github/workflows/pr-template.yml`, `scripts/pr_template_check.py` and its tests) and its CI test step. Also removed `.github/PULL_REQUEST_TEMPLATE.md`. Pull request descriptions are no longer validated or pre-filled; CONTRIBUTING.md still asks for the same information and the claim-first rule still applies. diff --git a/scripts/audit/docs_hygiene.py b/scripts/audit/docs_hygiene.py new file mode 100644 index 0000000..e8dc127 --- /dev/null +++ b/scripts/audit/docs_hygiene.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python3 +"""Fast, deterministic documentation and repository hygiene checks. + +Checks only tracked files: + 1. no merge-conflict markers in tracked text files; + 2. every relative Markdown link points at a tracked file or directory; + 3. every workflow file under .github/workflows parses as YAML. + +External URLs and in-page anchors are not fetched or validated, so the result +does not depend on the network. Exit status is 1 when a problem is found. Pass --require-yaml to fail, not skip, +when PyYAML is missing. +""" +import re +import subprocess +import sys +from pathlib import Path, PurePosixPath +from urllib.parse import unquote + +ROOT = Path(__file__).resolve().parents[2] +MARKER = re.compile(r"^(<{7}( |$)|={7}$|>{7}( |$))") +LINK = re.compile(r"(?