Skip to content

Commit fe6bd04

Browse files
authored
ci: samcli automation fixes (#339)
Minor fixes for SAMcli automation workflows, including better failure handling and explicit role duration. Signed-off-by: ayush-panta <[email protected]>
1 parent 8a121b6 commit fe6bd04

File tree

3 files changed

+44
-12
lines changed

3 files changed

+44
-12
lines changed

.github/workflows/samcli-direct.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name: samcli-direct
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
4+
schedule:
5+
- cron: '0 8 * * *'
76
workflow_dispatch:
87

98
env:

.github/workflows/samcli-vm.yaml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: samcli-vm
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
74
schedule:
85
- cron: '0 8 * * *'
96
workflow_dispatch:
@@ -138,6 +135,7 @@ jobs:
138135
role-to-assume: ${{ secrets.SAMCLI_VM_ROLE_SYNC }}
139136
role-session-name: samcli-finch-vm-sequential-tests
140137
aws-region: ${{ secrets.REGION }}
138+
role-duration-seconds: 14400
141139

142140
- name: Install Docker CLI for SAM CLI compatibility
143141
run: |
@@ -172,34 +170,50 @@ jobs:
172170

173171
- name: Run unit tests
174172
continue-on-error: true
175-
run: ./scripts/samcli-vm/run-unit-tests.sh
173+
run: |
174+
./scripts/samcli-vm/run-unit-tests.sh
175+
echo "UNIT_EXIT_CODE=$(cat /tmp/unit_exit_code 2>/dev/null || echo 1)" >> $GITHUB_ENV
176176
177177
- name: Run sync tests
178178
continue-on-error: true
179-
run: ./scripts/samcli-vm/run-sync-tests.sh
179+
run: |
180+
./scripts/samcli-vm/run-sync-tests.sh
181+
echo "SYNC_EXIT_CODE=$(cat /tmp/sync_exit_code 2>/dev/null || echo 1)" >> $GITHUB_ENV
180182
181183
- name: Run package tests
182184
continue-on-error: true
183-
run: ./scripts/samcli-vm/run-package-tests.sh
185+
run: |
186+
./scripts/samcli-vm/run-package-tests.sh
187+
echo "PACKAGE_EXIT_CODE=$(cat /tmp/package_exit_code 2>/dev/null || echo 1)" >> $GITHUB_ENV
184188
185189
- name: Run start-api tests
186190
continue-on-error: true
187-
run: ./scripts/samcli-vm/run-start-api-tests.sh
191+
run: |
192+
./scripts/samcli-vm/run-start-api-tests.sh
193+
echo "START_API_EXIT_CODE=$(cat /tmp/start_api_exit_code 2>/dev/null || echo 1)" >> $GITHUB_ENV
188194
189195
- name: Run start-lambda tests
190196
continue-on-error: true
191-
run: ./scripts/samcli-vm/run-start-lambda-tests.sh
197+
run: |
198+
./scripts/samcli-vm/run-start-lambda-tests.sh
199+
echo "START_LAMBDA_EXIT_CODE=$(cat /tmp/start_lambda_exit_code 2>/dev/null || echo 1)" >> $GITHUB_ENV
192200
193201
- name: Patch SAM CLI for Docker image cleanup
194202
continue-on-error: true
195203
run: |
196204
# Apply git patch to handle ImageNotFound exceptions for all Docker tests
197205
su ec2-user -c 'cd /Users/ec2-user/aws-sam-cli && git apply ${{ github.workspace }}/scripts/samcli-vm/invoke-teardown.patch'
206+
echo "PATCH_EXIT_CODE=$?" >> $GITHUB_ENV
198207
shell: bash
199208

200209
- name: Run invoke tests
201210
continue-on-error: true
202-
run: ./scripts/samcli-vm/run-invoke-tests.sh
211+
run: |
212+
./scripts/samcli-vm/run-invoke-tests.sh
213+
echo "INVOKE_EXIT_CODE=$(cat /tmp/invoke_exit_code 2>/dev/null || echo 1)" >> $GITHUB_ENV
214+
215+
- name: Check test results
216+
run: ./scripts/samcli-vm/check-test-results.sh
203217

204218
# ensuring resources are clean post-test
205219
cleanup:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "=== Test Results Summary ==="
5+
echo "Unit tests: ${UNIT_EXIT_CODE:-1}"
6+
echo "Sync tests: ${SYNC_EXIT_CODE:-1}"
7+
echo "Package tests: ${PACKAGE_EXIT_CODE:-1}"
8+
echo "Start-API tests: ${START_API_EXIT_CODE:-1}"
9+
echo "Start-Lambda tests: ${START_LAMBDA_EXIT_CODE:-1}"
10+
echo "Patch: ${PATCH_EXIT_CODE:-1}"
11+
echo "Invoke tests: ${INVOKE_EXIT_CODE:-1}"
12+
13+
# Check if any tests failed
14+
if [ "${UNIT_EXIT_CODE:-1}" -ne 0 ] || [ "${SYNC_EXIT_CODE:-1}" -ne 0 ] || [ "${PACKAGE_EXIT_CODE:-1}" -ne 0 ] || [ "${START_API_EXIT_CODE:-1}" -ne 0 ] || [ "${START_LAMBDA_EXIT_CODE:-1}" -ne 0 ] || [ "${PATCH_EXIT_CODE:-1}" -ne 0 ] || [ "${INVOKE_EXIT_CODE:-1}" -ne 0 ]; then
15+
echo "❌ One or more tests failed"
16+
exit 1
17+
else
18+
echo "✅ All tests passed"
19+
fi

0 commit comments

Comments
 (0)