synapse-hub 0.0.0-stage → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/agents/failure-analyst.md +47 -0
- package/.agents/agents/live-explorer.md +41 -0
- package/.agents/agents/orchestrator.md +43 -0
- package/.agents/agents/pom-crafter.md +81 -0
- package/.agents/agents/quality-gatekeeper.md +47 -0
- package/.agents/agents/test-runner.md +43 -0
- package/.agents/rules/context-engineering.md +88 -0
- package/.agents/rules/git-push-protocol.md +101 -0
- package/.agents/rules/graphify.md +14 -0
- package/.agents/rules/lessons-learned.md +23 -0
- package/.agents/rules/mandatory-playwright-live.md +29 -0
- package/.agents/rules/skill-precedence.md +42 -0
- package/.agents/rules/systematic-debugging.md +99 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/SKILL.md +239 -0
- package/.agents/skills/antigravity-test-sentinel/SKILL.md +64 -0
- package/.agents/skills/api-network-mocking-interception/SKILL.md +142 -0
- package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +70 -0
- package/.agents/skills/architecture-decision-records/SKILL.md +441 -0
- package/.agents/skills/auth-session-and-cookie-manager/SKILL.md +72 -0
- package/.agents/skills/backend-load-and-stress-patterns/SKILL.md +214 -0
- package/.agents/skills/bats-testing-patterns/SKILL.md +100 -0
- package/.agents/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/.agents/skills/clean-pom-crafter/SKILL.md +75 -0
- package/.agents/skills/clean-pom-crafter/examples/standard_test_case.groovy +28 -0
- package/.agents/skills/clean-pom-crafter/references/pom_patterns.groovy +138 -0
- package/.agents/skills/code-refactoring-refactor-clean/SKILL.md +64 -0
- package/.agents/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +879 -0
- package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +123 -0
- package/.agents/skills/e2e-testing-patterns/SKILL.md +103 -0
- package/.agents/skills/e2e-testing-patterns/resources/implementation-playbook.md +522 -0
- package/.agents/skills/failure-autopsy-and-healing/SKILL.md +54 -0
- package/.agents/skills/failure-autopsy-and-healing/references/healing_matrix.md +64 -0
- package/.agents/skills/failure-autopsy-and-healing/references/qa_investigation_protocol.md +56 -0
- package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +98 -0
- package/.agents/skills/file-and-report-validator/SKILL.md +90 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/SKILL.md +114 -0
- package/.agents/skills/github-actions-templates/SKILL.md +334 -0
- package/.agents/skills/graphify-impact-analyzer/SKILL.md +78 -0
- package/.agents/skills/katalon-cli-runner/SKILL.md +76 -0
- package/.agents/skills/katalon-cli-runner/references/groovy-patterns.md +209 -0
- package/.agents/skills/katalon-cli-runner/references/katalon-api.md +155 -0
- package/.agents/skills/katalon-cli-runner/references/runner_commands.md +67 -0
- package/.agents/skills/lam-script-generator/SKILL.md +83 -0
- package/.agents/skills/playwright-live-interaction/SKILL.md +86 -0
- package/.agents/skills/playwright-live-interaction/references/advanced_superpowers.md +160 -0
- package/.agents/skills/playwright-live-interaction/references/compact_accessibility_snapshots.md +75 -0
- package/.agents/skills/playwright-live-interaction/references/recipes.md +388 -0
- package/.agents/skills/playwright-live-interaction/references/swarm_orchestration.md +134 -0
- package/.agents/skills/security-dast-sentinel/SKILL.md +176 -0
- package/.agents/skills/self-healing-locator/SKILL.md +73 -0
- package/.agents/skills/synthetic-test-data-generator/SKILL.md +135 -0
- package/.agents/skills/token-and-context-optimizer/SKILL.md +70 -0
- package/.agents/skills/visual-regression-sentinel/SKILL.md +62 -0
- package/.agents/skills/wcag-audit-patterns/SKILL.md +77 -0
- package/.agents/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/.agents/skills/web-vitals-and-performance-profiler/SKILL.md +65 -0
- package/.agents/templates/completion_report.md +57 -0
- package/.agents/workflows/graphify.md +10 -0
- package/.agents/workflows/test-impact.md +15 -0
- package/.agents/workflows/verify.md +34 -0
- package/AGENTS.md +115 -0
- package/README.md +394 -2
- package/bin/agent-qa.js +90 -0
- package/package.json +59 -4
- package/skills_manifest.json +262 -0
- package/templates/PROJECT_AI_GUIDE_TEMPLATE.md +97 -0
- package/templates/PROJECT_STATE_TEMPLATE.md +20 -0
- package/tools/TOOLS_RUNBOOK.md +298 -0
- package/tools/agent_canary.py +501 -0
- package/tools/analyze_project.py +242 -0
- package/tools/api_drift_sentinel.py +208 -0
- package/tools/auto_heal.py +189 -0
- package/tools/browser_helpers.js +593 -0
- package/tools/bug_reporter.py +224 -0
- package/tools/cache_resolver.py +846 -0
- package/tools/check_env.py +288 -0
- package/tools/ci_healing_hook.py +128 -0
- package/tools/cli.py +402 -0
- package/tools/config_decoupler.py +253 -0
- package/tools/db_sandbox.py +341 -0
- package/tools/distill_log.py +152 -0
- package/tools/e2e_flow_prober.ps1 +65 -0
- package/tools/flaky_detector.py +222 -0
- package/tools/fuzz_payloads.py +197 -0
- package/tools/generate_allure_report.ps1 +30 -0
- package/tools/generate_api_matrix.py +193 -0
- package/tools/generate_tc_from_story.py +182 -0
- package/tools/generate_test_reports.ps1 +135 -0
- package/tools/git_pre_commit_guard.py +203 -0
- package/tools/heal_pr_automator.py +195 -0
- package/tools/heuristic_locator_matcher.py +202 -0
- package/tools/infer_linter.py +238 -0
- package/tools/lint_ai_docs.py +254 -0
- package/tools/lookup_tc.py +165 -0
- package/tools/lookup_xpath.py +167 -0
- package/tools/matrix_sharder.py +146 -0
- package/tools/mcp_excel_server.ps1 +251 -0
- package/tools/mcp_server.py +490 -0
- package/tools/micro_mutator.py +309 -0
- package/tools/network_mock_shield.py +170 -0
- package/tools/omni_emitter.py +500 -0
- package/tools/omni_parser.py +435 -0
- package/tools/omni_transpiler.py +168 -0
- package/tools/pinpoint_failure.py +88 -0
- package/tools/project_state.py +169 -0
- package/tools/repo_map.json +12 -0
- package/tools/repo_map.py +277 -0
- package/tools/repo_map.txt +7 -0
- package/tools/safety_firewall.py +245 -0
- package/tools/setup_project.py +265 -0
- package/tools/smart_visual_masker.py +134 -0
- package/tools/test_impact.py +321 -0
- package/tools/tms_sync_bridge.py +342 -0
- package/tools/trace_data_flow.py +240 -0
- package/tools/traffic_session_converter.py +256 -0
- package/tools/universal_ir.py +480 -0
- package/tools/validate_groovy_scripts.py +173 -0
- package/tools/verify_all.py +496 -0
- package/tools/verify_all.sh +4 -0
- package/tools/visual_diff_canvas.py +142 -0
- package/tools/visual_som_helper.py +418 -0
- package/tools/wcag_audit.py +214 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Triage Failures Script for Enterprise Automation
|
|
3
|
+
# Cross-platform: Compatible with macOS, Linux CI, and Windows Git Bash
|
|
4
|
+
|
|
5
|
+
WORKSPACE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd)"
|
|
6
|
+
SCREENSHOT_DIR="$WORKSPACE_DIR/Screenshots"
|
|
7
|
+
REPORTS_DIR="$WORKSPACE_DIR/Reports"
|
|
8
|
+
|
|
9
|
+
echo "=========================================================="
|
|
10
|
+
echo " 🔬 ENTERPRISE FAILURE AUTOPSY & TRIAGE SCANNER (CROSS-PLATFORM)"
|
|
11
|
+
echo " Workspace: $WORKSPACE_DIR"
|
|
12
|
+
echo "=========================================================="
|
|
13
|
+
|
|
14
|
+
# 1. Quét báo cáo JUnit XML gần nhất
|
|
15
|
+
LATEST_JUNIT=$(find "$REPORTS_DIR" -type f -name "JUnit_Report.xml" 2>/dev/null | sort -r | head -n 1)
|
|
16
|
+
|
|
17
|
+
if [ -n "$LATEST_JUNIT" ]; then
|
|
18
|
+
echo "📊 Báo cáo JUnit gần nhất: $(basename "$(dirname "$LATEST_JUNIT")")/JUnit_Report.xml"
|
|
19
|
+
FAILED_JUNIT_TESTS=$(grep -B 1 '<failure' "$LATEST_JUNIT" 2>/dev/null | grep '<testcase' | sed -n 's/.*name="\([^"]*\)".*/\1/p')
|
|
20
|
+
if [ -n "$FAILED_JUNIT_TESTS" ]; then
|
|
21
|
+
echo "🚨 Các Test Cases báo FAILED trong JUnit XML:"
|
|
22
|
+
echo "$FAILED_JUNIT_TESTS" | while read -r tc; do
|
|
23
|
+
echo " ❌ $tc"
|
|
24
|
+
done
|
|
25
|
+
echo "----------------------------------------------------------"
|
|
26
|
+
else
|
|
27
|
+
echo "✅ Không phát hiện ca thất bại nào trong JUnit XML gần nhất."
|
|
28
|
+
echo "----------------------------------------------------------"
|
|
29
|
+
fi
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
# 2. Quét ảnh chụp FAILED_*.png
|
|
33
|
+
if [ ! -d "$SCREENSHOT_DIR" ]; then
|
|
34
|
+
echo "ℹ️ Không tìm thấy thư mục Screenshots. Dự án đang sạch lỗi!"
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
FAILED_COUNT=$(find "$SCREENSHOT_DIR" -maxdepth 1 -name "FAILED_*.png" 2>/dev/null | wc -l | tr -d ' ')
|
|
39
|
+
|
|
40
|
+
if [ "$FAILED_COUNT" -eq "0" ]; then
|
|
41
|
+
echo "✅ Tuyệt vời! Không có ảnh lỗi nào trong $SCREENSHOT_DIR."
|
|
42
|
+
exit 0
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
echo "⚠️ Phát hiện $FAILED_COUNT ảnh lỗi kịch bản gần nhất:"
|
|
46
|
+
echo "----------------------------------------------------------"
|
|
47
|
+
|
|
48
|
+
# Hàm lấy thông tin file đa nền tảng (hỗ trợ Linux GNU stat, macOS BSD stat và fallback ls)
|
|
49
|
+
list_recent_screenshots() {
|
|
50
|
+
if stat --version 2>&1 | grep -q "GNU"; then
|
|
51
|
+
# Linux (GNU stat)
|
|
52
|
+
find "$SCREENSHOT_DIR" -maxdepth 1 -name "FAILED_*.png" -type f -exec stat -c "%Y %y %n" {} + 2>/dev/null | \
|
|
53
|
+
sort -rn | head -n 10 | awk '{print $1, $2, $3, $NF}'
|
|
54
|
+
elif stat -f "%m" . >/dev/null 2>&1; then
|
|
55
|
+
# macOS / BSD stat
|
|
56
|
+
find "$SCREENSHOT_DIR" -maxdepth 1 -name "FAILED_*.png" -type f -exec stat -f "%m %Sm %N" -t "%Y-%m-%d %H:%M:%S" {} + 2>/dev/null | \
|
|
57
|
+
sort -rn | head -n 10
|
|
58
|
+
else
|
|
59
|
+
# Fallback (POSIX ls)
|
|
60
|
+
ls -lt "$SCREENSHOT_DIR"/FAILED_*.png 2>/dev/null | head -n 10 | awk '{print "0", $6, $7, $NF}'
|
|
61
|
+
fi
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
list_recent_screenshots | while read -r epoch date time filepath; do
|
|
65
|
+
filename=$(basename "$filepath")
|
|
66
|
+
|
|
67
|
+
# Ánh xạ Page Class gợi ý dựa trên mã Test Case (Dynamic Pattern Matching)
|
|
68
|
+
suggested_page="BasePage.groovy"
|
|
69
|
+
if [[ "$filename" =~ TC-([0-9]+) ]]; then
|
|
70
|
+
tc_num="${BASH_REMATCH[1]}"
|
|
71
|
+
if [ "$tc_num" -ge 1 ] && [ "$tc_num" -le 7 ]; then
|
|
72
|
+
suggested_page="TargetPlanPage.groovy"
|
|
73
|
+
elif [ "$tc_num" -ge 8 ] && [ "$tc_num" -le 12 ]; then
|
|
74
|
+
suggested_page="LoginPage.groovy"
|
|
75
|
+
elif [ "$tc_num" -ge 13 ] && [ "$tc_num" -le 16 ]; then
|
|
76
|
+
suggested_page="UserAdminPage.groovy"
|
|
77
|
+
elif [ "$tc_num" -ge 17 ] && [ "$tc_num" -le 28 ]; then
|
|
78
|
+
suggested_page="CommonCategoryPage.groovy"
|
|
79
|
+
elif [ "$tc_num" -ge 29 ] && [ "$tc_num" -le 92 ]; then
|
|
80
|
+
suggested_page="IndustryCategoryPage.groovy"
|
|
81
|
+
elif [ "$tc_num" -ge 93 ] && [ "$tc_num" -le 122 ]; then
|
|
82
|
+
suggested_page="PlanningPage.groovy"
|
|
83
|
+
elif [ "$tc_num" -ge 123 ] && [ "$tc_num" -le 247 ]; then
|
|
84
|
+
suggested_page="DataMiningPage.groovy"
|
|
85
|
+
elif [ "$tc_num" -ge 248 ] && [ "$tc_num" -le 249 ]; then
|
|
86
|
+
suggested_page="ReportPage.groovy"
|
|
87
|
+
elif [ "$tc_num" -ge 250 ] && [ "$tc_num" -le 259 ]; then
|
|
88
|
+
suggested_page="TokenMgmtPage.groovy"
|
|
89
|
+
fi
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
echo "📸 [$date $time] $filename"
|
|
93
|
+
echo " -> Đường dẫn ảnh : $filepath"
|
|
94
|
+
echo " -> Page Class cần vá : Keywords/pages/$suggested_page"
|
|
95
|
+
done
|
|
96
|
+
|
|
97
|
+
echo "----------------------------------------------------------"
|
|
98
|
+
echo "💡 Gợi ý AI: Dùng tool read_file mở ảnh hoặc dùng Playwright Live giữ nguyên browser để xác thực và vá Page Class."
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: file-and-report-validator
|
|
3
|
+
description: Validate uploaded and downloaded enterprise files (Excel .xlsx/.xls, CSV, PDF) for correct schemas, row counts, tabular data integrity, and PDF text/layout. Use on-demand when testing export/import workflows.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# File & Report Validator Skill
|
|
7
|
+
|
|
8
|
+
> **Target:** Eliminate superficial testing of file exports and imports by inspecting and asserting exact file contents, schemas, formulas, and values across Excel, CSV, and PDF formats.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. Core Principles
|
|
13
|
+
|
|
14
|
+
1. **Verify Binary Contents, Not Just Download Events:**
|
|
15
|
+
- Catching the browser `download` event is insufficient. The downloaded file must be opened, parsed, and its tabular records cross-referenced against expected database or UI table states.
|
|
16
|
+
2. **Schema & Header Conformance:**
|
|
17
|
+
- Assert exact column headers, cell data formats (dates, currencies, numeric precision), and sheet names.
|
|
18
|
+
3. **Idempotent File Lifecycle:**
|
|
19
|
+
- Store temporary test downloads in a sandboxed scratch folder and purge them during teardown.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Standard Playwright Download Handling
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { test, expect } from '@playwright/test';
|
|
27
|
+
import path from 'path';
|
|
28
|
+
|
|
29
|
+
test('export and verify financial report', async ({ page }) => {
|
|
30
|
+
const downloadPromise = page.waitForEvent('download');
|
|
31
|
+
await page.click('button#export-excel');
|
|
32
|
+
const download = await downloadPromise;
|
|
33
|
+
|
|
34
|
+
const savePath = path.join('temp_downloads', download.suggestedFilename());
|
|
35
|
+
await download.saveAs(savePath);
|
|
36
|
+
|
|
37
|
+
expect(download.suggestedFilename()).toMatch(/^Report_\d{8}\.xlsx$/);
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## 3. Deep Content Inspection Recipes (Python)
|
|
44
|
+
|
|
45
|
+
### Pattern A: Excel (.xlsx / .xls) Schema & Data Assertion
|
|
46
|
+
```python
|
|
47
|
+
import pandas as pd
|
|
48
|
+
|
|
49
|
+
def validate_excel_report(file_path: str, expected_min_rows: int = 1):
|
|
50
|
+
df = pd.read_excel(file_path)
|
|
51
|
+
|
|
52
|
+
# 1. Assert header schema
|
|
53
|
+
expected_headers = ["ID", "Customer Name", "Total Amount", "Status"]
|
|
54
|
+
assert list(df.columns) == expected_headers, f"Header mismatch: {df.columns}"
|
|
55
|
+
|
|
56
|
+
# 2. Assert row counts and non-empty values
|
|
57
|
+
assert len(df) >= expected_min_rows, f"Expected at least {expected_min_rows} rows, got {len(df)}"
|
|
58
|
+
assert not df["ID"].isnull().any(), "Found NULL values in ID column"
|
|
59
|
+
print(f"[PASS] Successfully verified {len(df)} rows in {file_path}")
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Pattern B: CSV Chunk Streaming (For Big Data Exports > 100k Rows)
|
|
63
|
+
```python
|
|
64
|
+
import csv
|
|
65
|
+
|
|
66
|
+
def validate_large_csv_stream(file_path: str, expected_header: list):
|
|
67
|
+
row_count = 0
|
|
68
|
+
with open(file_path, mode='r', encoding='utf-8') as f:
|
|
69
|
+
reader = csv.reader(f)
|
|
70
|
+
header = next(reader)
|
|
71
|
+
assert header == expected_header, f"CSV Header mismatch: {header}"
|
|
72
|
+
for row in reader:
|
|
73
|
+
row_count += 1
|
|
74
|
+
assert len(row) == len(header), f"Malformed row at line {row_count}"
|
|
75
|
+
print(f"[PASS] Verified {row_count} streamed CSV rows without memory overflow.")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Pattern C: PDF Document Text & Metadata Extraction
|
|
79
|
+
```python
|
|
80
|
+
import pypdf
|
|
81
|
+
|
|
82
|
+
def assert_pdf_contains_text(pdf_path: str, expected_keywords: list):
|
|
83
|
+
reader = pypdf.PdfReader(pdf_path)
|
|
84
|
+
assert len(reader.pages) > 0, "PDF is empty (0 pages)!"
|
|
85
|
+
|
|
86
|
+
full_text = "\n".join([page.extract_text() or "" for page in reader.pages])
|
|
87
|
+
for kw in expected_keywords:
|
|
88
|
+
assert kw in full_text, f"PDF assertion failed: Keyword '{kw}' missing in {pdf_path}"
|
|
89
|
+
print(f"[PASS] Verified keywords {expected_keywords} across {len(reader.pages)} PDF pages.")
|
|
90
|
+
```
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flaky-test-sentinel-and-quarantine
|
|
3
|
+
description: Enterprise flaky test detection, scoring, and automated quarantine governance. Detects non-deterministic test behavior via multi-run repetition (e.g., 5 iterations), computes flakiness index, isolates unstable tests from blocking CI/CD merges via quarantine tagging (@quarantine / @flaky), and tracks MTBF until remediation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Flaky Test Sentinel & Quarantine Protocol
|
|
7
|
+
|
|
8
|
+
> **Purpose:** Master flaky test governance, automated quarantine isolation, and non-deterministic test remediation. Eliminates false-positive CI/CD pipeline blockers by identifying unstable tests through repeated execution ($N=5$), moving them into isolated quarantine suites, and tracking remediation until graduation.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 1. The Flaky Test Dilemma & The 5-Stage Quarantine Lifecycle
|
|
13
|
+
|
|
14
|
+
In large enterprise test suites (hundreds to thousands of test cases), non-deterministic tests ("flaky tests" that intermittently pass and fail without code changes) erode trust in CI/CD, slow down deployments, and cause developers to ignore test results.
|
|
15
|
+
|
|
16
|
+
```mermaid
|
|
17
|
+
flowchart TD
|
|
18
|
+
A["<b>1. Detection Engine</b><br/>Run test N=5 iterations<br/>Identify Pass/Fail flips"] --> B["<b>2. Automated Quarantine</b><br/>Tag test with @quarantine<br/>Isolate from main suite"]
|
|
19
|
+
B --> C["<b>3. Unblocked PR Pipeline</b><br/>PR merge runs stable tests only<br/>CI/CD remains green"]
|
|
20
|
+
B --> D["<b>4. Quarantine Lab</b><br/>Runs in parallel/nightly<br/>Logs failure autopsy"]
|
|
21
|
+
D --> E["<b>5. Graduation DoD Gate</b><br/>Must achieve 10/10 consecutive passes<br/>Graduates back to main"]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2. Flakiness Scoring Formula & Classification
|
|
27
|
+
|
|
28
|
+
$$P = \frac{\text{Passed Executions}}{N} \times 100\% \quad \text{where } N \ge 5$$
|
|
29
|
+
|
|
30
|
+
$$\text{Flip Rate} = \frac{\text{Status Transitions (Pass} \leftrightarrow \text{Fail)}}{N - 1} \times 100\%$$
|
|
31
|
+
|
|
32
|
+
| Health Tier | Pass Rate ($P$) | Flip Count ($N=5$) | Action Required | Pipeline Impact |
|
|
33
|
+
| :--- | :--- | :--- | :--- | :--- |
|
|
34
|
+
| **STABLE (Green)** | $100\%$ | 0 flips | Kept in standard regression suite | Blocks PR on real bug |
|
|
35
|
+
| **MILD FLAKE** | $80\% \le P < 100\%$ | 1 - 2 flips | Log warning; monitor over 24 hours | Kept in suite with watchpoint |
|
|
36
|
+
| **SEVERE FLAKE** | $P < 80\%$ | $\ge 2$ flips | **Immediate Quarantine Tagging (`@quarantine`)** | Excluded from PR merge blocker |
|
|
37
|
+
| **DEAD TEST / BROKEN**| $0\%$ | 0 flips | File critical AUT/Test bug defect | Regular test failure |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 3. Quarantine Tagging & Execution Strategies
|
|
42
|
+
|
|
43
|
+
### Playwright / TypeScript Quarantine Tagging
|
|
44
|
+
```typescript
|
|
45
|
+
import { test, expect } from '@playwright/test';
|
|
46
|
+
|
|
47
|
+
// Before Quarantine: Unstable test intermittently blocking main PRs
|
|
48
|
+
// test('TC-104: Submit monthly reconciliation report', async ({ page }) => { ... });
|
|
49
|
+
|
|
50
|
+
// After Quarantine: Tagged with @quarantine metadata
|
|
51
|
+
test('TC-104: Submit monthly reconciliation report @quarantine', async ({ page }) => {
|
|
52
|
+
// Test code remains intact for debugging
|
|
53
|
+
await page.goto('/reports/reconciliation');
|
|
54
|
+
// ...
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### CI/CD Filter Configuration
|
|
59
|
+
```bash
|
|
60
|
+
# 1. Main PR Blocker Suite: Runs ONLY 100% stable tests (Zero Flaky Disruptions)
|
|
61
|
+
npx playwright test --grep-invert "@quarantine"
|
|
62
|
+
|
|
63
|
+
# 2. Nightly Quarantine Lab: Runs quarantined tests to collect diagnostics & heal
|
|
64
|
+
npx playwright test --grep "@quarantine" --reporter=json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## 4. Automated Multi-Run Flakiness Detector Tool
|
|
70
|
+
|
|
71
|
+
This repository provides an automated flakiness analyzer in `tools/flaky_detector.py`.
|
|
72
|
+
|
|
73
|
+
### Running 5-Iteration Flakiness Benchmark
|
|
74
|
+
```bash
|
|
75
|
+
# Run a specific test script 5 consecutive times to benchmark stability
|
|
76
|
+
python tools/flaky_detector.py --repeat 5 --cmd "npm test -- tests/e2e/TC-104.spec.ts"
|
|
77
|
+
|
|
78
|
+
# Or parse existing test execution history
|
|
79
|
+
python tools/flaky_detector.py --reports "reports/**/junit*.xml"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Output Report (`reports/quarantine_board.json`):
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"test_id": "TC-104",
|
|
86
|
+
"iterations": 5,
|
|
87
|
+
"passes": 3,
|
|
88
|
+
"failures": 2,
|
|
89
|
+
"pass_rate": 60.0,
|
|
90
|
+
"flakiness_status": "SEVERE_FLAKE",
|
|
91
|
+
"quarantine_recommended": true,
|
|
92
|
+
"probable_cause": "Angular PrimeNG animation fade-out / missing smart wait"
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 5. Root-Cause Remediation Guide (Heal & Graduate)
|
|
99
|
+
|
|
100
|
+
| Flakiness Root Cause | Anti-Pattern | Mandatory Remediation |
|
|
101
|
+
| :--- | :--- | :--- |
|
|
102
|
+
| **Race Condition** | Static `Thread.sleep(3000)` or blind delays | Replace with Smart Wait: `waitForLoadState('networkidle')` or Angular `zone.isStable()`. |
|
|
103
|
+
| **Database Collision** | Reusing static IDs (`"ORDER_001"`) | Use dynamic identifiers: `BasePage.uniqueCode("AUTO_")` paired with Idempotent Teardown. |
|
|
104
|
+
| **Animation Interference**| Clicking during backdrop fade | Use `BasePage.clickJS()` or await overlay invisibility (`.p-component-overlay`). |
|
|
105
|
+
| **DOM Re-render Drift** | Direct click after async API fetch | Encapsulate 3-attempt retry loop with AOM Role fallback in Page Class. |
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 6. Graduation Definition of Done (DoD) Gate
|
|
110
|
+
|
|
111
|
+
Before removing the `@quarantine` tag and restoring a test to the main PR suite:
|
|
112
|
+
1. **Verification Run:** The healed test must execute **10 consecutive iterations** in headless mode with **100% Pass Rate** (`10/10 PASS`).
|
|
113
|
+
2. **Code Standards:** 100% UTF-8 No BOM, Clean POM flat architecture, zero hardcoded XPaths.
|
|
114
|
+
3. **Artifact Update:** Update `reports/quarantine_board.json` to mark status as `GRADUATED`.
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-actions-templates
|
|
3
|
+
description: Create production-ready GitHub Actions workflows for automated testing, building, and deploying applications. Use when setting up CI/CD with GitHub Actions, automating development workflows, or creating reusable workflow templates.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitHub Actions Templates
|
|
7
|
+
|
|
8
|
+
Production-ready GitHub Actions workflow patterns for testing, building, and deploying applications.
|
|
9
|
+
|
|
10
|
+
## Do not use this skill when
|
|
11
|
+
|
|
12
|
+
- The task is unrelated to github actions templates
|
|
13
|
+
- You need a different domain or tool outside this scope
|
|
14
|
+
|
|
15
|
+
## Instructions
|
|
16
|
+
|
|
17
|
+
- Clarify goals, constraints, and required inputs.
|
|
18
|
+
- Apply relevant best practices and validate outcomes.
|
|
19
|
+
- Provide actionable steps and verification.
|
|
20
|
+
|
|
21
|
+
## Purpose
|
|
22
|
+
|
|
23
|
+
Create efficient, secure GitHub Actions workflows for continuous integration and deployment across various tech stacks.
|
|
24
|
+
|
|
25
|
+
## Use this skill when
|
|
26
|
+
|
|
27
|
+
- Automate testing and deployment
|
|
28
|
+
- Build Docker images and push to registries
|
|
29
|
+
- Deploy to Kubernetes clusters
|
|
30
|
+
- Run security scans
|
|
31
|
+
- Implement matrix builds for multiple environments
|
|
32
|
+
|
|
33
|
+
## Common Workflow Patterns
|
|
34
|
+
|
|
35
|
+
### Pattern 1: Test Workflow
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
name: Test
|
|
39
|
+
|
|
40
|
+
on:
|
|
41
|
+
push:
|
|
42
|
+
branches: [ main, develop ]
|
|
43
|
+
pull_request:
|
|
44
|
+
branches: [ main ]
|
|
45
|
+
|
|
46
|
+
jobs:
|
|
47
|
+
test:
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
|
|
50
|
+
strategy:
|
|
51
|
+
matrix:
|
|
52
|
+
node-version: [18.x, 20.x]
|
|
53
|
+
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v4
|
|
56
|
+
|
|
57
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
58
|
+
uses: actions/setup-node@v4
|
|
59
|
+
with:
|
|
60
|
+
node-version: ${{ matrix.node-version }}
|
|
61
|
+
cache: 'npm'
|
|
62
|
+
|
|
63
|
+
- name: Install dependencies
|
|
64
|
+
run: npm ci
|
|
65
|
+
|
|
66
|
+
- name: Run linter
|
|
67
|
+
run: npm run lint
|
|
68
|
+
|
|
69
|
+
- name: Run tests
|
|
70
|
+
run: npm test
|
|
71
|
+
|
|
72
|
+
- name: Upload coverage
|
|
73
|
+
uses: codecov/codecov-action@v3
|
|
74
|
+
with:
|
|
75
|
+
files: ./coverage/lcov.info
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Pattern 2: Build and Push Docker Image
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
name: Build and Push
|
|
83
|
+
|
|
84
|
+
on:
|
|
85
|
+
push:
|
|
86
|
+
branches: [ main ]
|
|
87
|
+
tags: [ 'v*' ]
|
|
88
|
+
|
|
89
|
+
env:
|
|
90
|
+
REGISTRY: ghcr.io
|
|
91
|
+
IMAGE_NAME: ${{ github.repository }}
|
|
92
|
+
|
|
93
|
+
jobs:
|
|
94
|
+
build:
|
|
95
|
+
runs-on: ubuntu-latest
|
|
96
|
+
permissions:
|
|
97
|
+
contents: read
|
|
98
|
+
packages: write
|
|
99
|
+
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@v4
|
|
102
|
+
|
|
103
|
+
- name: Log in to Container Registry
|
|
104
|
+
uses: docker/login-action@v3
|
|
105
|
+
with:
|
|
106
|
+
registry: ${{ env.REGISTRY }}
|
|
107
|
+
username: ${{ github.actor }}
|
|
108
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
109
|
+
|
|
110
|
+
- name: Extract metadata
|
|
111
|
+
id: meta
|
|
112
|
+
uses: docker/metadata-action@v5
|
|
113
|
+
with:
|
|
114
|
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
115
|
+
tags: |
|
|
116
|
+
type=ref,event=branch
|
|
117
|
+
type=ref,event=pr
|
|
118
|
+
type=semver,pattern={{version}}
|
|
119
|
+
type=semver,pattern={{major}}.{{minor}}
|
|
120
|
+
|
|
121
|
+
- name: Build and push
|
|
122
|
+
uses: docker/build-push-action@v5
|
|
123
|
+
with:
|
|
124
|
+
context: .
|
|
125
|
+
push: true
|
|
126
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
127
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
128
|
+
cache-from: type=gha
|
|
129
|
+
cache-to: type=gha,mode=max
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
### Pattern 3: Deploy to Kubernetes
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
name: Deploy to Kubernetes
|
|
137
|
+
|
|
138
|
+
on:
|
|
139
|
+
push:
|
|
140
|
+
branches: [ main ]
|
|
141
|
+
|
|
142
|
+
jobs:
|
|
143
|
+
deploy:
|
|
144
|
+
runs-on: ubuntu-latest
|
|
145
|
+
|
|
146
|
+
steps:
|
|
147
|
+
- uses: actions/checkout@v4
|
|
148
|
+
|
|
149
|
+
- name: Configure AWS credentials
|
|
150
|
+
uses: aws-actions/configure-aws-credentials@v4
|
|
151
|
+
with:
|
|
152
|
+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
153
|
+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
154
|
+
aws-region: us-west-2
|
|
155
|
+
|
|
156
|
+
- name: Update kubeconfig
|
|
157
|
+
run: |
|
|
158
|
+
aws eks update-kubeconfig --name production-cluster --region us-west-2
|
|
159
|
+
|
|
160
|
+
- name: Deploy to Kubernetes
|
|
161
|
+
run: |
|
|
162
|
+
kubectl apply -f k8s/
|
|
163
|
+
kubectl rollout status deployment/my-app -n production
|
|
164
|
+
kubectl get services -n production
|
|
165
|
+
|
|
166
|
+
- name: Verify deployment
|
|
167
|
+
run: |
|
|
168
|
+
kubectl get pods -n production
|
|
169
|
+
kubectl describe deployment my-app -n production
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Pattern 4: Matrix Build
|
|
173
|
+
|
|
174
|
+
```yaml
|
|
175
|
+
name: Matrix Build
|
|
176
|
+
|
|
177
|
+
on: [push, pull_request]
|
|
178
|
+
|
|
179
|
+
jobs:
|
|
180
|
+
build:
|
|
181
|
+
runs-on: ${{ matrix.os }}
|
|
182
|
+
|
|
183
|
+
strategy:
|
|
184
|
+
matrix:
|
|
185
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
186
|
+
python-version: ['3.9', '3.10', '3.11', '3.12']
|
|
187
|
+
|
|
188
|
+
steps:
|
|
189
|
+
- uses: actions/checkout@v4
|
|
190
|
+
|
|
191
|
+
- name: Set up Python
|
|
192
|
+
uses: actions/setup-python@v5
|
|
193
|
+
with:
|
|
194
|
+
python-version: ${{ matrix.python-version }}
|
|
195
|
+
|
|
196
|
+
- name: Install dependencies
|
|
197
|
+
run: |
|
|
198
|
+
python -m pip install --upgrade pip
|
|
199
|
+
pip install -r requirements.txt
|
|
200
|
+
|
|
201
|
+
- name: Run tests
|
|
202
|
+
run: pytest
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## Workflow Best Practices
|
|
207
|
+
|
|
208
|
+
1. **Use specific action versions** (@v4, not @latest)
|
|
209
|
+
2. **Cache dependencies** to speed up builds
|
|
210
|
+
3. **Use secrets** for sensitive data
|
|
211
|
+
4. **Implement status checks** on PRs
|
|
212
|
+
5. **Use matrix builds** for multi-version testing
|
|
213
|
+
6. **Set appropriate permissions**
|
|
214
|
+
7. **Use reusable workflows** for common patterns
|
|
215
|
+
8. **Implement approval gates** for production
|
|
216
|
+
9. **Add notification steps** for failures
|
|
217
|
+
10. **Use self-hosted runners** for sensitive workloads
|
|
218
|
+
|
|
219
|
+
## Reusable Workflows
|
|
220
|
+
|
|
221
|
+
```yaml
|
|
222
|
+
# .github/workflows/reusable-test.yml
|
|
223
|
+
name: Reusable Test Workflow
|
|
224
|
+
|
|
225
|
+
on:
|
|
226
|
+
workflow_call:
|
|
227
|
+
inputs:
|
|
228
|
+
node-version:
|
|
229
|
+
required: true
|
|
230
|
+
type: string
|
|
231
|
+
secrets:
|
|
232
|
+
NPM_TOKEN:
|
|
233
|
+
required: true
|
|
234
|
+
|
|
235
|
+
jobs:
|
|
236
|
+
test:
|
|
237
|
+
runs-on: ubuntu-latest
|
|
238
|
+
steps:
|
|
239
|
+
- uses: actions/checkout@v4
|
|
240
|
+
- uses: actions/setup-node@v4
|
|
241
|
+
with:
|
|
242
|
+
node-version: ${{ inputs.node-version }}
|
|
243
|
+
- run: npm ci
|
|
244
|
+
- run: npm test
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Use reusable workflow:**
|
|
248
|
+
```yaml
|
|
249
|
+
jobs:
|
|
250
|
+
call-test:
|
|
251
|
+
uses: ./.github/workflows/reusable-test.yml
|
|
252
|
+
with:
|
|
253
|
+
node-version: '20.x'
|
|
254
|
+
secrets:
|
|
255
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Security Scanning
|
|
259
|
+
|
|
260
|
+
```yaml
|
|
261
|
+
name: Security Scan
|
|
262
|
+
|
|
263
|
+
on:
|
|
264
|
+
push:
|
|
265
|
+
branches: [ main ]
|
|
266
|
+
pull_request:
|
|
267
|
+
branches: [ main ]
|
|
268
|
+
|
|
269
|
+
jobs:
|
|
270
|
+
security:
|
|
271
|
+
runs-on: ubuntu-latest
|
|
272
|
+
|
|
273
|
+
steps:
|
|
274
|
+
- uses: actions/checkout@v4
|
|
275
|
+
|
|
276
|
+
- name: Run Trivy vulnerability scanner
|
|
277
|
+
uses: aquasecurity/trivy-action@master
|
|
278
|
+
with:
|
|
279
|
+
scan-type: 'fs'
|
|
280
|
+
scan-ref: '.'
|
|
281
|
+
format: 'sarif'
|
|
282
|
+
output: 'trivy-results.sarif'
|
|
283
|
+
|
|
284
|
+
- name: Upload Trivy results to GitHub Security
|
|
285
|
+
uses: github/codeql-action/upload-sarif@v2
|
|
286
|
+
with:
|
|
287
|
+
sarif_file: 'trivy-results.sarif'
|
|
288
|
+
|
|
289
|
+
- name: Run Snyk Security Scan
|
|
290
|
+
uses: snyk/actions/node@master
|
|
291
|
+
env:
|
|
292
|
+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Deployment with Approvals
|
|
296
|
+
|
|
297
|
+
```yaml
|
|
298
|
+
name: Deploy to Production
|
|
299
|
+
|
|
300
|
+
on:
|
|
301
|
+
push:
|
|
302
|
+
tags: [ 'v*' ]
|
|
303
|
+
|
|
304
|
+
jobs:
|
|
305
|
+
deploy:
|
|
306
|
+
runs-on: ubuntu-latest
|
|
307
|
+
environment:
|
|
308
|
+
name: production
|
|
309
|
+
url: https://app.example.com
|
|
310
|
+
|
|
311
|
+
steps:
|
|
312
|
+
- uses: actions/checkout@v4
|
|
313
|
+
|
|
314
|
+
- name: Deploy application
|
|
315
|
+
run: |
|
|
316
|
+
echo "Deploying to production..."
|
|
317
|
+
# Deployment commands here
|
|
318
|
+
|
|
319
|
+
- name: Notify Slack
|
|
320
|
+
if: success()
|
|
321
|
+
uses: slackapi/slack-github-action@v1
|
|
322
|
+
with:
|
|
323
|
+
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
|
|
324
|
+
payload: |
|
|
325
|
+
{
|
|
326
|
+
"text": "Deployment to production completed successfully!"
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Related Skills
|
|
331
|
+
|
|
332
|
+
- `gitlab-ci-patterns` - For GitLab CI workflows
|
|
333
|
+
- `deployment-pipeline-design` - For pipeline architecture
|
|
334
|
+
- `secrets-management` - For secrets handling
|