forked from ratmie/times-all-bot-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (64 loc) · 2.76 KB
/
_reusable_lambda_rie_test.yml
File metadata and controls
78 lines (64 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Reusable - Lambda RIE Test
on:
workflow_call:
jobs:
lambda-rie-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "24.14.1"
cache: npm
cache-dependency-path: package-lock.json
- run: npm ci
- name: Bundle handler
run: npx esbuild src/handler.ts --bundle --platform=node --target=node24 --external:@slack/bolt --outfile=dist/index.js
- name: Prepare Lambda artifact
run: cp -R node_modules dist/
- name: Start Lambda RIE container
run: |
docker run -d --name lambda-rie \
-p 9000:8080 \
-v ${{ github.workspace }}/dist:/var/task:ro \
-e SLACK_SIGNING_SECRET=test-signing-secret \
-e SLACK_BOT_TOKEN=xoxb-test-token \
-e TIMES_ALL_CHANNEL_ID=C0000000000 \
-e WORKSPACE_URL=https://test.slack.com \
public.ecr.aws/lambda/nodejs:24 \
index.handler
- name: Test handler invocation
run: |
echo "--- Lambda RIE ハンドラー動作検証 ---"
echo "検証内容: ハンドラーがLambdaランタイム上でロード・実行できることを確認"
echo "※ テストリクエストにSlackヘッダーがないためアプリケーションエラーは想定通り発生します"
echo ""
# コンテナの起動を待つ
READY=false
for i in $(seq 1 10); do
if curl -s -o /dev/null http://localhost:9000/2015-03-31/functions/function/invocations 2>/dev/null; then
READY=true
break
fi
sleep 1
done
if [ "$READY" != "true" ]; then
echo "::error::Lambda RIEコンテナの起動に失敗しました"
docker logs lambda-rie
exit 1
fi
RESPONSE=$(curl -s -X POST \
"http://localhost:9000/2015-03-31/functions/function/invocations" \
-d '{"body": "test"}')
# Lambdaランタイムレベルのエラー (Runtime.CallbackHandlerDeprecated等) がないことを確認
if echo "$RESPONSE" | grep -q '"errorType":"Runtime\.' ; then
echo "::error::Lambdaランタイムエラーが検出されました: $RESPONSE"
docker logs lambda-rie
exit 1
fi
echo "OK: ランタイムエラーなし (ハンドラーは正常にロード・実行されました)"
- name: Cleanup Lambda RIE container
if: always()
run: docker rm -f lambda-rie 2>/dev/null || true