سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 17:00 UTC
test: lock release and QA safety invariants
davoodmehraban89 committed
Oct 1, 2026 at 23:59 UTC
6f50ed10770a05f3cad7d516e6fa18bb6bec4ef0
1 file changed
+32
scripts/release-safety-check.mjs
new
+32
@@ -0,0 +1,32 @@
1
+import fs from 'node:fs';
2
+
3
+const qa = fs.readFileSync('.github/workflows/qa.yml', 'utf8');
4
+const security = fs.readFileSync('.github/workflows/security.yml', 'utf8');
5
+const gate = fs.existsSync('.github/workflows/release-gate.yml')
6
+ ? fs.readFileSync('.github/workflows/release-gate.yml', 'utf8')
7
+ : '';
8
+
9
+function must(condition, message) {
10
+ if (!condition) throw new Error(`Release safety invariant failed: ${message}`);
11
+}
12
+
13
+must(!/continue-on-error\s*:\s*true/i.test(qa), 'manual QA must never continue after Playwright failure');
14
+must(/Require live QA credentials/.test(qa), 'live/all suites must hard-fail when credentials are absent');
15
+must(/inputs\.suite == 'live' \|\| inputs\.suite == 'all'/.test(qa), 'credential gate must cover both live and all suites');
16
+must(/Validate requested QA target before credentials/.test(qa), 'BASE_URL must be validated before credential-bearing steps');
17
+must(/allowedLiveOrigins/.test(qa) && /Refusing to expose live-test credentials/.test(qa), 'live credential origins must be explicitly allowlisted');
18
+must(/assertAllowedOrigin\(page\.url\(\)\)/.test(qa), 'browser origin must be re-asserted before/after authenticated navigation');
19
+must(!/\.click\([^\n]*\)\.catch\(\(\)\s*=>\s*\{\}\)/.test(qa), 'menu click failures must not be swallowed');
20
+must(/menu item did not change navigation\/view state/.test(qa), 'menu crawl must assert a real navigation/view-state change');
21
+must(/retention-days:\s*3/.test(qa), 'QA evidence retention must remain minimal');
22
+
23
+must(!/continue-on-error\s*:\s*true/i.test(security), 'security workflow must not fail open');
24
+must(/Dependency review \(fail closed\)/.test(security), 'dependency review must be explicitly fail closed');
25
+
26
+must(gate.length > 0, 'exact-SHA promotion gate workflow must exist');
27
+must(/workflow_run/.test(gate), 'promotion gate must be driven by completed required workflows');
28
+must(/head_sha/.test(gate), 'promotion gate must bind evidence to the exact tested SHA');
29
+must(/d1-request-database/.test(gate) && /c8-policy-database/.test(gate), 'promotion gate must verify database jobs, not only top-level workflow conclusion');
30
+must(/Security checks/.test(gate) && /Quality checks/.test(gate), 'promotion gate must require both Quality and Security');
31
+
32
+console.log('Release/QA safety invariants: PASS');