fix(p37): cd.yaml SPA shadow grep pipefail bug — 真正修好 CD failure
All checks were successful
CD Pipeline / deploy (push) Successful in 2m29s
All checks were successful
CD Pipeline / deploy (push) Successful in 2m29s
P34/P36 都沒打到的 root cause:
ETAG=$(echo "$HDR" | grep -i '^etag:' | ...)
當 grep 找不到匹配 (mo.wooo.work /health 不帶 etag header),
grep exit 1 → bash pipefail → 變數賦值整行 exit 1 →
set -e 殺掉整個 script → run 280/281 同樣位置死。
修:每個 grep pipeline 結尾補 `|| true` 兜底,empty result 不殺 script。
本機 bash -eo pipefail 模擬實 prod /health response:
ETAG=[] CLEN=[64] XPT=[]
FLASK_OK=1 (CLEN=64 != 7480 觸發 PASS)
✅ 預期下個 CD run 該 step 綠
This commit is contained in:
@@ -336,9 +336,10 @@ jobs:
|
||||
SPA_LEN='7480'
|
||||
# 用 /health(純 Flask,不會被 SPA 路徑攔)做基準探針
|
||||
HDR=$(curl -sS -D - -o /dev/null --max-time 10 https://mo.wooo.work/health 2>/dev/null || echo "")
|
||||
ETAG=$(echo "$HDR" | grep -i '^etag:' | tr -d '"\r' | awk '{print $2}' | tr 'A-Z' 'a-z')
|
||||
CLEN=$(echo "$HDR" | grep -i '^content-length:' | awk '{print $2}' | tr -d '\r')
|
||||
XPT=$(echo "$HDR" | grep -i '^x-process-time:' | awk '{print $2}' | tr -d '\r')
|
||||
# P37: grep 沒匹配返回 1,pipefail+set -e 會殺整段腳本 — 全部加 || true
|
||||
ETAG=$(echo "$HDR" | grep -i '^etag:' 2>/dev/null | tr -d '"\r' | awk '{print $2}' | tr 'A-Z' 'a-z' || true)
|
||||
CLEN=$(echo "$HDR" | grep -i '^content-length:' 2>/dev/null | awk '{print $2}' | tr -d '\r' || true)
|
||||
XPT=$(echo "$HDR" | grep -i '^x-process-time:' 2>/dev/null | awk '{print $2}' | tr -d '\r' || true)
|
||||
FLASK_OK=0
|
||||
# P36 修:用 if/then 而非 && 串連,避免 bash -e 在第一條 false 就 exit
|
||||
if [ -n "$XPT" ] && [ "$XPT" != "0" ] && [ "$XPT" != "0.0" ]; then FLASK_OK=1; fi
|
||||
|
||||
Reference in New Issue
Block a user