fix: manifest check in Node (python3 absent on slim runner)
This commit is contained in:
@@ -37,28 +37,18 @@ jobs:
|
|||||||
- name: Validate Kubernetes manifest
|
- name: Validate Kubernetes manifest
|
||||||
run: |
|
run: |
|
||||||
# Offline check only: the runner has no cluster. The real apply happens
|
# Offline check only: the runner has no cluster. The real apply happens
|
||||||
# in the deploy job using the KUBE_CONFIG secret.
|
# in the deploy job using the KUBE_CONFIG secret. Node is already
|
||||||
python3 - <<'PY'
|
# installed in the verify job, so use it (no python on the slim image).
|
||||||
import sys, subprocess
|
node -e '
|
||||||
try:
|
const fs = require("fs");
|
||||||
import yaml
|
const txt = fs.readFileSync("deploy/havenllo.yaml", "utf8");
|
||||||
except ImportError:
|
const docs = txt.split(/\n---\n/).map(s => s.trim()).filter(Boolean);
|
||||||
subprocess.run(["apk", "add", "--no-cache", "py3-yaml"], check=False)
|
const kinds = docs.map(d => { const m = d.match(/^kind:\s*(\S+)/m); return m ? m[1] : null; });
|
||||||
import importlib
|
const req = ["PersistentVolumeClaim", "Deployment", "Service", "Ingress"];
|
||||||
yaml = importlib.import_module("yaml")
|
const miss = req.filter(k => !kinds.includes(k));
|
||||||
kinds = []
|
console.log("docs:", docs.length, "kinds:", kinds.join(", "));
|
||||||
with open("deploy/havenllo.yaml") as f:
|
if (miss.length) { console.error("MISSING KINDS:", miss.join(", ")); process.exit(1); }
|
||||||
for doc in yaml.safe_load_all(f):
|
'
|
||||||
if doc is None:
|
|
||||||
continue
|
|
||||||
kinds.append(doc.get("kind"))
|
|
||||||
required = ["PersistentVolumeClaim", "Deployment", "Service", "Ingress"]
|
|
||||||
missing = [k for k in required if k not in kinds]
|
|
||||||
if missing:
|
|
||||||
print("MISSING KINDS:", missing)
|
|
||||||
sys.exit(1)
|
|
||||||
print("manifest docs OK:", kinds)
|
|
||||||
PY
|
|
||||||
build:
|
build:
|
||||||
name: Build and push image
|
name: Build and push image
|
||||||
needs: verify
|
needs: verify
|
||||||
|
|||||||
Reference in New Issue
Block a user