CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
34 lines
1.8 KiB
JavaScript
34 lines
1.8 KiB
JavaScript
export const code = async (inputs) => {
|
|
// Alert state machine (ops-automation-phase1 design D4): alert on a state change only after
|
|
// TWO consecutive identical results; one recovery message; reminder while critical stays open.
|
|
const REMINDER_MS = Number(inputs.reminderMinutes ?? 720) * 60000;
|
|
const result = typeof inputs.result === 'string' ? JSON.parse(inputs.result) : inputs.result;
|
|
let prev = inputs.prev;
|
|
if (typeof prev === 'string') { try { prev = JSON.parse(prev); } catch { prev = null; } }
|
|
const now = new Date().toISOString();
|
|
const cur = result.status;
|
|
const state = prev && prev.status ? prev
|
|
: { status: 'ok', since: now, lastAlertAt: null, pending: null, pendingCount: 0 };
|
|
let next = { ...state };
|
|
let alert = null;
|
|
if (cur === state.status) {
|
|
next.pending = null; next.pendingCount = 0;
|
|
if (cur === 'critical' && state.lastAlertAt && Date.parse(now) - Date.parse(state.lastAlertAt) >= REMINDER_MS) {
|
|
alert = { kind: 'reminder', level: 'critical' }; next.lastAlertAt = now;
|
|
}
|
|
} else if (cur === 'ok') {
|
|
next = { status: 'ok', since: now, lastAlertAt: null, pending: null, pendingCount: 0 };
|
|
alert = { kind: 'recovery', level: 'ok' };
|
|
} else {
|
|
if (state.pending === cur) next.pendingCount = (state.pendingCount || 0) + 1;
|
|
else { next.pending = cur; next.pendingCount = 1; }
|
|
if (next.pendingCount >= 2) {
|
|
next = { status: cur, since: now, lastAlertAt: now, pending: null, pendingCount: 0 };
|
|
alert = { kind: 'change', level: cur };
|
|
}
|
|
}
|
|
const title = alert ? `[${alert.level}] ${result.check} ${result.target}` : '';
|
|
const message = alert ? `${alert.kind}: ${JSON.stringify(result.values)}` : '';
|
|
return { nextJson: JSON.stringify(next), hasAlert: !!alert, title, message, status: cur };
|
|
};
|