KB-5019

S129C Investigation Report — E2E Post-Deploy Lost

6 min read Revision 1
reports129cinvestigatione2eregressiondieu30

S129C — ĐIỀU TRA GỐC: E2E SAU DEPLOY BỊ MẤT

Agent: Claude Code | Phiên: S129C | Ngày: 2026-03-23 Repo điều tra: web-test (Nuxt frontend) — KHÔNG phải agent-data-test Kết luận: BUG REGRESSION — workflow_run trigger bị xóa vô tình trong PR #567 (S160)


Git History Evidence

Điều tra 1: E2E trigger workflow_run bị xóa ở đâu?

TRƯỚC Điều 30 (commit d2d3e78, PR #536 S132-B):

# .github/workflows/e2e-test.yml
on:
  workflow_run:
    workflows: ["Deploy to VPS"]
    types: [completed]
    branches: [main]
  workflow_dispatch:

jobs:
  e2e:
    if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}

→ E2E chạy SAU deploy thành công. Kiểm tra production URLs (Super Session, Directus health, public collections, restricted collections).

PR #567 (commit 34dc0be, S160 — "guard registries regressions with playwright"):

on:
  pull_request:
    branches: [main]
  workflow_dispatch:

XÓA TOÀN BỘ workflow_run trigger. Thay thế bằng Playwright local tests. → Xóa luôn production smoke checks (curl against VPS URLs). → E2E không còn chạy sau deploy. Không còn kiểm tra production.

PR #569 (commit 1e7bf9b, S160 — "enforce dieu30 e2e gate"):

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

→ Thêm lại push trigger nhưng KHÔNG khôi phục workflow_run. → E2E chạy song song với deploy (cùng trigger push), KHÔNG đợi deploy xong.

KẾT LUẬN: PR #567 xóa workflow_run trigger — đây là regression vô tình khi rewrite e2e-test.yml từ "production smoke" sang "Playwright local tests". Hai chức năng khác nhau bị gộp chung, chức năng cũ bị mất.

Điều tra 2: deploy-vps.yml — smoke trước đây có không?

Thời điểm Có post-deploy smoke?
Trước PR #573 KHÔNG — deploy-vps.yml chỉ có health check inline
PR #573 (Codex S129A) THÊM MỚI "Copy smoke script + Post-deploy smoke test"

smoke-test.sh được tạo mới tại PR #537 (S135e, commit 3d787be). Trước đó script không tồn tại.

KẾT LUẬN: Codex PR #573 THÊM MỚI (không khôi phục). Đây là workaround đúng hướng nhưng không fix gốc.

Điều tra 3: Thanh tra chéo PR #573 (Codex S129A)

PR #573: ci(dieu30): add post-deploy smoke to deploy workflow — Merged 2026-03-23T02:17:36Z

Vấn đề phát hiện:

  1. Code duplication (DRY violation): 4 steps copy-paste giống hệt vào CẢ 2 jobs (direct deploy job + artifact deploy job):

    • "Copy smoke script to VPS" (scp-action)
    • "Post-deploy smoke test" (ssh-action) → Nên extract thành reusable composite action hoặc dùng scripts/ rsync.
  2. Workaround thay vì fix gốc: Deploy rsync EXCLUDE scripts/ folder. Codex dùng scp-action riêng để copy smoke-test.sh → đúng kết quả nhưng tạo complexity thừa. Fix gốc = thêm scripts/smoke-test.sh vào rsync include.

  3. Không điều tra WHY script không có trên VPS: Codex phát hiện script thiếu → workaround ngay, không tìm nguyên nhân (rsync exclude).

  4. if: success() redundant: GitHub Actions mặc định chỉ chạy step khi các step trước success. if: success() là no-op.

Tuy nhiên: Script smoke-test.sh viết tốt — kiểm tra đầy đủ infrastructure, API, pages, security. Exit code handling đúng.


Bảng tổng kết

# Câu hỏi Kết quả
1 Đã đọc SSOT + Điều 30?
2 Git history e2e-test.yml: trigger nào bị xóa? PR nào? workflow_run bị xóa tại PR #567 (S160)
3 Git history deploy-vps.yml: smoke từng có chưa? CHƯA — PR #573 thêm mới
4 Codex PR #573: có vấn đề gì không? DRY violation + workaround thay vì fix gốc
5 Kết luận gốc: bug hay cố ý? BUG REGRESSION — vô tình xóa khi rewrite
6 Nếu bug → đã khôi phục? PR? CI GREEN? ⚠️ CẦN TẠO PR — xem đề xuất bên dưới
7 Report tại reports/s129c-investigate-report.md?

ĐỀ XUẤT HÀNH ĐỘNG

Fix 1: Khôi phục post-deploy E2E (QUAN TRỌNG NHẤT)

Tạo workflow mới post-deploy-e2e.yml trong web-test repo:

name: Post-Deploy E2E
on:
  workflow_run:
    workflows: ["Deploy to VPS"]
    types: [completed]
    branches: [main]
  workflow_dispatch:

jobs:
  post-deploy:
    runs-on: ubuntu-latest
    if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
    steps:
      - uses: actions/checkout@v4
      - name: Wait for deployment propagation
        run: sleep 30
      - name: Run smoke test
        run: bash scripts/smoke-test.sh

Lý do tách file mới: Giữ nguyên e2e-test.yml (Playwright tests on PR/push) + thêm post-deploy-e2e.yml (production smoke after deploy). Hai chức năng khác nhau, nên tách file.

Fix 2: Cleanup PR #573 duplication (NHỎ)

Gộp 2 cặp steps thành 1 reusable flow, hoặc thêm scripts/smoke-test.sh vào rsync include để bỏ scp step.

Quyết định cần từ user:

  • Fix 1 nằm trong web-test repo, không phải agent-data-test. Cần xác nhận trước khi tạo PR ở repo khác.
  • Fix 2 có thể gộp chung PR hoặc tách riêng.