Skip to content

Commit 5c709ee

Browse files
Fix logs
1 parent 0a71feb commit 5c709ee

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

.github/workflows/deploy.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,21 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
test:
14+
name: Test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Run tests
22+
run: make test
23+
1324
deploy:
1425
name: Deploy
1526
runs-on: ubuntu-latest
27+
needs: test
1628

1729
steps:
1830
- name: Checkout code
@@ -104,12 +116,13 @@ jobs:
104116
--output text)
105117
106118
if [ -n "$TASK_ARN" ] && [ "$TASK_ARN" != "None" ]; then
107-
echo "--- Recent logs ---"
108-
aws logs tail /ecs/${{ vars.ECS_CLUSTER_NAME }} \
109-
--log-stream-name-prefix "ecs/api" \
119+
TASK_ID=$(echo $TASK_ARN | rev | cut -d'/' -f1 | rev)
120+
echo "--- Recent logs from task $TASK_ID ---"
121+
aws logs tail /ecs/policyengine-api-v2-alpha \
122+
--log-stream-name-prefix "api/$TASK_ID" \
110123
--since 30s \
111124
--format short \
112-
--region ${{ vars.AWS_REGION }} 2>/dev/null || true
125+
--region ${{ vars.AWS_REGION }} 2>&1 || echo "No logs available yet"
113126
echo "---"
114127
fi
115128
@@ -149,12 +162,13 @@ jobs:
149162
--output text)
150163
151164
if [ -n "$TASK_ARN" ] && [ "$TASK_ARN" != "None" ]; then
152-
echo "--- Recent logs ---"
153-
aws logs tail /ecs/${{ vars.ECS_CLUSTER_NAME }} \
154-
--log-stream-name-prefix "ecs/worker" \
165+
TASK_ID=$(echo $TASK_ARN | rev | cut -d'/' -f1 | rev)
166+
echo "--- Recent logs from task $TASK_ID ---"
167+
aws logs tail /ecs/policyengine-api-v2-alpha \
168+
--log-stream-name-prefix "worker/$TASK_ID" \
155169
--since 30s \
156170
--format short \
157-
--region ${{ vars.AWS_REGION }} 2>/dev/null || true
171+
--region ${{ vars.AWS_REGION }} 2>&1 || echo "No logs available yet"
158172
echo "---"
159173
fi
160174

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches-ignore:
7+
- main
8+
9+
jobs:
10+
test:
11+
name: Run tests
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Run tests
19+
run: make test
20+
21+
- name: Report test results
22+
if: always()
23+
run: |
24+
if [ $? -eq 0 ]; then
25+
echo "✅ All tests passed"
26+
else
27+
echo "❌ Tests failed"
28+
exit 1
29+
fi

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
redis:
3030
condition: service_healthy
3131
healthcheck:
32-
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
32+
test: ["CMD", "python", "-c", "import httpx; exit(0 if httpx.get('http://localhost:8000/health', timeout=2).status_code == 200 else 1)"]
3333
interval: 5s
3434
timeout: 3s
3535
retries: 10

0 commit comments

Comments
 (0)