Skip to content

Commit faeee5e

Browse files
devantlerclaude
andauthored
fix(ci): use shared manifest naming validation (#165)
* fix(ci): use shared manifest naming validation * test(ci): seed a naming violation for hosted RED proof * fix(ci): remove the seeded naming-gate fixture now its RED proof is recorded The fixture exists to make the hosted gate fail on purpose, proving the shared validation actually bites. Its own header says it was to be removed before review; the run that added it ended first, so the gate has been correctly failing on it since. The RED proof is permanent in the run history (run 34062330530 reports "1 naming violation(s)" naming exactly this file), so removing the file keeps the evidence and clears the check. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(security): pin the template's own naming gate to the template-owned config The template-only job selected its config with a hashFiles() fallback to .github/manifest-naming.local.yaml. That fallback exists so a tenant can override the synced config in its own repository, and the tenant job in validate-naming.yaml keeps it. In the template's own repository it is a hole: the paths filter already runs this job when .github/manifest-naming*.yaml changes, so a pull request could add manifest-naming.local.yaml with a narrower resource-roots and have the gate read the config that PR supplied — the check validating itself away. Behaviour is unchanged today: no manifest-naming.local.yaml exists here, so the expression already resolved to manifest-naming.yaml. Addresses CodeRabbit's Major finding on ci.yaml:81. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 2239faa commit faeee5e

6 files changed

Lines changed: 73 additions & 384 deletions

File tree

‎.github/manifest-naming.yaml‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 1
2+
resource-roots: [k8s]
3+
patch-roots: ["talos*"]
4+
multi-resource-files:
5+
- k8s/bases/infrastructure/controllers/cdi/cdi-operator.yaml
6+
- k8s/bases/infrastructure/controllers/kubevirt/kubevirt-operator.yaml
7+
kind-prefix-exempt-files:
8+
- k8s/bases/bootstrap/variables-base-config-map.yaml
9+
- k8s/bases/bootstrap/variables-base-secret.enc.yaml
10+
- k8s/clusters/*/bootstrap/variables-cluster-config-map.yaml
11+
- k8s/clusters/*/bootstrap/variables-cluster-secret.enc.yaml
12+
filename-exempt-directories:
13+
- k8s/bases/infrastructure/controllers/testkube/custom-resource-definitions
14+
cr-directories:
15+
- k8s/bases/bootstrap/priority-classes
16+
- k8s/bases/infrastructure/alerts
17+
- k8s/bases/infrastructure/cluster-policies
18+
- k8s/bases/infrastructure/cluster-role-bindings
19+
- k8s/bases/infrastructure/cluster-roles
20+
- k8s/bases/infrastructure/cluster-secret-stores
21+
- k8s/bases/infrastructure/cluster-security-exceptions
22+
- k8s/bases/infrastructure/controllers/testkube/custom-resource-definitions
23+
- k8s/bases/infrastructure/external-secrets
24+
- k8s/bases/infrastructure/http-scaled-objects
25+
- k8s/bases/infrastructure/tracing-policies
26+
- k8s/providers/docker/infrastructure/cluster-issuers
27+
- k8s/providers/hetzner/infrastructure/cluster-issuers

‎.github/workflows/ci.yaml‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@ jobs:
4545
# directory, and instances add environments as talos-<env>/.
4646
- 'talos*/**'
4747
- '.github/workflows/ci.yaml'
48-
- 'scripts/validate-naming.sh'
48+
- '.github/manifest-naming*.yaml'
49+
- '.github/workflows/validate-naming.yaml'
4950
5051
validate-naming:
5152
name: 🏷️ Validate Naming Conventions
5253
needs: [changes]
5354
# Static folder/file naming gate: kebab-case dirs, one-resource-per-file,
5455
# Kind-led filenames, CR-folder plurals, patch/talos intent naming, and
5556
# flux-kustomization disambiguation — the reference platform's conventions
56-
# (platform#2315), ported to bash. No cluster, no secrets, no network, so
57-
# it also runs on fork PRs and returns in seconds. Template-repo-only:
57+
# (platform#2315), shared through devantler-tech/actions. No cluster or
58+
# secrets; Go setup/build can download dependencies. Template-repo-only:
5859
# instances run the gate via the template-synced validate-naming.yaml
5960
# (their ci.yaml is instance-owned), so without this guard every instance
60-
# k8s PR would run the same script twice.
61+
# k8s PR would run the same gate twice.
6162
if: github.repository == 'devantler-tech/platform-template' && github.event_name == 'pull_request' && needs.changes.outputs.k8s == 'true'
6263
runs-on: ubuntu-latest
6364
permissions:
@@ -74,7 +75,10 @@ jobs:
7475
persist-credentials: false
7576

7677
- name: 🏷️ Validate naming conventions
77-
run: ./scripts/validate-naming.sh
78+
uses: devantler-tech/actions/validate-naming@883d891a0e6a2c9420d2b60aea9d5f47c20ce803 # v13.5.0
79+
with:
80+
enabled: "true"
81+
config-file: .github/manifest-naming.yaml
7882

7983
system-test:
8084
name: 🧪 System Test

‎.github/workflows/validate-naming.yaml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
paths:
1313
- "k8s/**"
1414
- "talos*/**"
15-
- "scripts/validate-naming.sh"
15+
- ".github/manifest-naming*.yaml"
1616
- ".github/workflows/validate-naming.yaml"
1717

1818
permissions: {}
@@ -25,9 +25,17 @@ jobs:
2525
permissions:
2626
contents: read
2727
steps:
28+
- name: 🛡️ Harden runner
29+
uses: step-security/harden-runner@05e31511f85b41b11d1cf0ef85d0992719546e2c # v2.21.0
30+
with:
31+
egress-policy: audit
32+
2833
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2934
with:
3035
persist-credentials: false
3136

3237
- name: 🏷️ Validate naming conventions
33-
run: ./scripts/validate-naming.sh
38+
uses: devantler-tech/actions/validate-naming@883d891a0e6a2c9420d2b60aea9d5f47c20ce803 # v13.5.0
39+
with:
40+
enabled: "true"
41+
config-file: ${{ hashFiles('.github/manifest-naming.local.yaml') != '' && '.github/manifest-naming.local.yaml' || '.github/manifest-naming.yaml' }}

‎.templatesyncignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ SECURITY.md
2323
# --- CI / release / dependency config the instance tailors ---
2424
.github/workflows/ci.yaml
2525
.github/dependabot.yml
26+
# The shared defaults are template-owned. This optional full override is never
27+
# shipped by the template, so existing instances can also tailor it safely.
28+
.github/manifest-naming.local.yaml
2629
.releaserc
2730
.gitignore
2831
.cspell.json

‎AGENTS.md‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ same-repo (non-fork) PRs; let CI run it, do not attempt it locally.
154154
### File and directory naming conventions
155155

156156
Manifest naming follows the reference platform's conventions (platform#2315),
157-
enforced by `./scripts/validate-naming.sh` (a CI gate on every `k8s/**` PR):
157+
enforced by the shared `devantler-tech/actions/validate-naming` action (a CI gate
158+
on manifest, naming-configuration, and naming-workflow changes):
158159

159160
- **Kebab-case** directories and file stems everywhere under `k8s/` and `talos*/`
160161
(vendored upstream files inside CR folders — e.g. the testkube CRD dumps —
@@ -168,7 +169,7 @@ enforced by `./scripts/validate-naming.sh` (a CI gate on every `k8s/**` PR):
168169
- **CR folders** (a folder grouping instances of one non-workload Kind) are named
169170
the Kind's kebab-case plural (`cluster-security-exceptions/`, `external-secrets/`)
170171
and their files are named by intent, not Kind — the folder already says the Kind.
171-
New plural-Kind folders are registered in the gate's `cr_dir_paths` list.
172+
New plural-Kind folders are registered in the configuration's `cr-directories` list.
172173
- **Patch fragments** live under a `patches/` directory, named by intent as
173174
`<verb>-<purpose>.yaml` (`store-data-on-hcloud.yaml`) — never a redundant
174175
`-patch` suffix and never led by the patched Kind.
@@ -179,7 +180,27 @@ enforced by `./scripts/validate-naming.sh` (a CI gate on every `k8s/**` PR):
179180
template-sync overwrite an instance's tailored values with template defaults
180181
(the gate carries an explicit exemption list for them).
181182

182-
Run the gate locally before any manifest PR: `./scripts/validate-naming.sh`.
183+
Shared defaults live in [`.github/manifest-naming.yaml`](.github/manifest-naming.yaml)
184+
and are template-owned. An instance that needs different roots or exceptions
185+
copies that file to `.github/manifest-naming.local.yaml`, edits the copy, and
186+
commits it. CI uses the override when present. The template never ships that
187+
override, and `.templatesyncignore` protects it, so syncs update shared defaults
188+
without overwriting an instance's tailored configuration. `patch-roots: ["talos*"]`
189+
continues to cover new machine-config environments automatically.
190+
191+
Run the same pinned gate locally before a manifest PR, with Go installed:
192+
193+
```bash
194+
actions_dir="$(mktemp -d)"
195+
git clone --quiet --depth 1 --branch v13.5.0 https://github.com/devantler-tech/actions.git "$actions_dir"
196+
git -C "$actions_dir" checkout --quiet --detach 883d891a0e6a2c9420d2b60aea9d5f47c20ce803
197+
GOWORK=off go -C "$actions_dir/validate-naming" run -mod=readonly . \
198+
--root "$PWD" --config .github/manifest-naming.yaml
199+
```
200+
201+
Pass `.github/manifest-naming.local.yaml` instead when using an instance override.
202+
Go setup and dependency downloads need network access; validation itself is
203+
offline and never contacts a cluster.
183204

184205
## Maintenance (autonomous AI assistant)
185206

0 commit comments

Comments
 (0)