-
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (50 loc) · 2.15 KB
/
Copy pathgovernance-baseline-impl.yml
File metadata and controls
50 lines (50 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# SPDX-License-Identifier: MPL-2.0
#
# Local reusable backing `governance-baseline.yml`. Its single job is named
# "Validate Hypatia baseline" so that, when called from a job with id
# `governance`, GitHub reports the check context
# `governance / Validate Hypatia baseline` — the estate-standard name pinned by
# branch protection.
#
# It is a genuine (if lightweight) gate: when a `.hypatia-baseline.json` is
# present it must be well-formed JSON, and any baseline entry that points at a
# now-absent file is surfaced as a warning. With no baseline file present
# (this repo's preferred state) it passes with a notice. Uses `jq` only — no
# npm (npm is banned in this repo; `jq` ships on the runner).
#
# Deliberately declares NO `concurrency:` — see the BP008 note in the caller.
name: Governance Baseline (impl)
on:
workflow_call:
permissions:
contents: read
jobs:
validate:
name: Validate Hypatia baseline
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate .hypatia-baseline.json (if present)
run: |
set -euo pipefail
if [ ! -f .hypatia-baseline.json ]; then
echo "::notice::No .hypatia-baseline.json present — nothing to validate."
exit 0
fi
echo "Found .hypatia-baseline.json — verifying it is well-formed JSON."
if ! jq empty .hypatia-baseline.json; then
echo "::error file=.hypatia-baseline.json::.hypatia-baseline.json is not valid JSON."
exit 1
fi
echo "Scanning for stale baseline entries (referenced files that no longer exist)."
stale=0
while IFS= read -r f; do
if [ -n "$f" ] && [ ! -e "$f" ]; then
echo "::warning file=.hypatia-baseline.json::Stale baseline entry: $f no longer exists."
stale=$((stale + 1))
fi
done < <(jq -r '.. | objects | .file? // empty' .hypatia-baseline.json 2>/dev/null || true)
echo "Stale entries: ${stale} (warnings only, non-blocking)."
echo "Baseline validation passed."