Remove repo reports and add recurrence guard
This commit is contained in:
@@ -18,9 +18,10 @@ import {
|
||||
import { activeReportLifecycle } from "../../internal/dev-report-lifecycle.mjs";
|
||||
import { DEV_ENDPOINT, ENVIRONMENT_DEV, SERVICE_IDS } from "../../internal/protocol/index.mjs";
|
||||
import { requireDevCdTransactionForSideEffect } from "./dev-cd-transaction-guard.mjs";
|
||||
import { ensureNotRepoReportsPath, tempReportPath } from "./report-paths.mjs";
|
||||
|
||||
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
const reportPath = "reports/dev-gate/dev-deploy-report.json";
|
||||
const defaultReportPath = tempReportPath("dev-deploy-report.json");
|
||||
const namespace = "hwlab-dev";
|
||||
const healthPath = "/health/live";
|
||||
const defaultD601KubeconfigPath = "/etc/rancher/k3s/k3s.yaml";
|
||||
@@ -73,9 +74,9 @@ const requiredValidationCommands = [
|
||||
"node --check scripts/src/dev-deploy-apply.mjs",
|
||||
"node scripts/dev-deploy-apply.mjs --dry-run --expect-blocked"
|
||||
];
|
||||
const applyCommand = "node scripts/dev-cd-apply.mjs --apply --confirm-dev --confirmed-non-production --write-report";
|
||||
const dryRunPlanCommand = "node scripts/dev-deploy-apply.mjs --dry-run --write-report";
|
||||
const blockedDryRunCommand = "node scripts/dev-deploy-apply.mjs --dry-run --expect-blocked --write-report";
|
||||
const applyCommand = `node scripts/dev-cd-apply.mjs --apply --confirm-dev --confirmed-non-production --report ${tempReportPath("dev-cd-apply.json")}`;
|
||||
const dryRunPlanCommand = `node scripts/dev-deploy-apply.mjs --dry-run --report ${defaultReportPath}`;
|
||||
const blockedDryRunCommand = `node scripts/dev-deploy-apply.mjs --dry-run --expect-blocked --report ${defaultReportPath}`;
|
||||
const forbiddenActions = [
|
||||
"prod-deploy",
|
||||
"secret-read",
|
||||
@@ -93,6 +94,7 @@ export function parseArgs(argv) {
|
||||
const errors = [];
|
||||
let kubeconfig = null;
|
||||
let kubeconfigSpecified = false;
|
||||
let reportPath = defaultReportPath;
|
||||
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index];
|
||||
@@ -118,6 +120,27 @@ export function parseArgs(argv) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (arg === "--report") {
|
||||
flags.add("--report");
|
||||
const next = argv[index + 1];
|
||||
if (typeof next !== "string" || next.startsWith("--")) {
|
||||
errors.push("--report requires a non-empty path value");
|
||||
} else {
|
||||
reportPath = next;
|
||||
flags.add("--report-output");
|
||||
index += 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (arg.startsWith("--report=")) {
|
||||
flags.add("--report");
|
||||
reportPath = arg.slice("--report=".length);
|
||||
flags.add("--report-output");
|
||||
if (!reportPath.trim()) {
|
||||
errors.push("--report requires a non-empty path value");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
flags.add(arg);
|
||||
}
|
||||
|
||||
@@ -126,7 +149,8 @@ export function parseArgs(argv) {
|
||||
dryRun: !flags.has("--apply"),
|
||||
expectBlocked: flags.has("--expect-blocked"),
|
||||
skipLiveProbe: flags.has("--skip-live-probe"),
|
||||
writeReport: flags.has("--write-report"),
|
||||
writeReport: flags.has("--report-output"),
|
||||
reportPath,
|
||||
kubeconfig,
|
||||
kubeconfigSpecified,
|
||||
errors,
|
||||
@@ -1052,7 +1076,8 @@ function buildPlanConclusion(status, blockers) {
|
||||
|
||||
function validateArgs(args, blockers) {
|
||||
for (const error of args.errors ?? []) {
|
||||
addBlocker(blockers, "safety_blocker", "kubeconfig-argument", error);
|
||||
const scope = error.startsWith("--report") ? "report-argument" : "kubeconfig-argument";
|
||||
addBlocker(blockers, "safety_blocker", scope, error);
|
||||
}
|
||||
for (const forbidden of ["--prod", "--production", "--read-secret", "--force-push", "--heavyweight-e2e"]) {
|
||||
if (args.flags.has(forbidden)) {
|
||||
@@ -1898,7 +1923,7 @@ export async function runDevDeployApply(argv, io = {}) {
|
||||
|
||||
const report = {
|
||||
$schema: "https://hwlab.pikastech.local/schemas/dev-gate-report.schema.json",
|
||||
$id: "https://hwlab.pikastech.local/reports/dev-gate/dev-deploy-report.json",
|
||||
$id: "https://hwlab.pikastech.local/dev-cd/dev-deploy-report.json",
|
||||
reportVersion: "v1",
|
||||
issue: "pikasTech/HWLAB#33",
|
||||
supports: ["pikasTech/HWLAB#164", "pikasTech/HWLAB#143", "pikasTech/HWLAB#99", "pikasTech/HWLAB#63", "pikasTech/HWLAB#50", "pikasTech/HWLAB#7", "pikasTech/HWLAB#33", "pikasTech/HWLAB#17", "pikasTech/HWLAB#32", "pikasTech/HWLAB#30"],
|
||||
@@ -2009,7 +2034,9 @@ export async function runDevDeployApply(argv, io = {}) {
|
||||
};
|
||||
|
||||
if (args.writeReport) {
|
||||
await writeFile(path.join(repoRoot, reportPath), `${JSON.stringify(report, null, 2)}\n`);
|
||||
const absoluteReportPath = ensureNotRepoReportsPath(repoRoot, args.reportPath, "--report");
|
||||
await mkdir(path.dirname(absoluteReportPath), { recursive: true });
|
||||
await writeFile(absoluteReportPath, `${JSON.stringify(report, null, 2)}\n`);
|
||||
}
|
||||
|
||||
stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
||||
|
||||
Reference in New Issue
Block a user