Skip to content

Commit e1afbbc

Browse files
Evrard-Nilclaude
andauthored
Add daily smoke tests for staging and prod (#442)
* feat: add daily smoke tests workflow and e2e testing script * fix: harden smoke tests with timeouts, error handling, and workflow fixes Address PR review feedback: - Add request timeouts (30s default, 90s streaming) to prevent indefinite hangs - Add streaming chunk limits (1000 max) as safety cap - Catch request exceptions in HTTP helpers so individual failures don't crash the suite - Wrap each test in run_test() to isolate unhandled exceptions - Mask API key in output to prevent partial secret leak in CI logs - Validate API_KEY is set before running tests - Fix workflow matrix exclude (broken with include-only matrix) using job-level if - Add job timeout-minutes: 15 to prevent 6-hour workflow hangs - Add API key validation step in workflow - Update actions/checkout@v4 to v6 for consistency - Fix Datadog curl to show errors instead of failing silently - Use tempfile instead of writing test files to CWD - Add missing expect_status to report() calls - Track conversation creation and cleanup deletes via report() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f1449fe commit e1afbbc

2 files changed

Lines changed: 695 additions & 0 deletions

File tree

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Daily Smoke Tests
2+
3+
on:
4+
schedule:
5+
# Every day at 06:00 UTC
6+
- cron: "0 6 * * *"
7+
workflow_dispatch:
8+
inputs:
9+
environment:
10+
description: "Environment to test"
11+
required: true
12+
default: both
13+
type: choice
14+
options:
15+
- both
16+
- staging
17+
- prod
18+
19+
jobs:
20+
smoke-test:
21+
name: Smoke test (${{ matrix.env_name }})
22+
runs-on: ubuntu-latest
23+
timeout-minutes: 15
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- env_name: staging
29+
api_base_url: https://cloud-stg-api.near.ai/v1
30+
api_key_secret: SMOKE_TEST_API_KEY_STAGING
31+
- env_name: prod
32+
api_base_url: https://cloud-api.near.ai/v1
33+
api_key_secret: SMOKE_TEST_API_KEY_PROD
34+
if: >-
35+
github.event_name == 'schedule'
36+
|| inputs.environment == 'both'
37+
|| inputs.environment == matrix.env_name
38+
39+
steps:
40+
- uses: actions/checkout@v6
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.12"
46+
47+
- name: Install dependencies
48+
run: pip install requests
49+
50+
- name: Validate API key exists
51+
env:
52+
API_KEY: ${{ secrets[matrix.api_key_secret] }}
53+
run: |
54+
if [ -z "$API_KEY" ]; then
55+
echo "ERROR: Secret ${{ matrix.api_key_secret }} is not configured"
56+
exit 1
57+
fi
58+
59+
- name: Run smoke tests against ${{ matrix.env_name }}
60+
env:
61+
API_BASE_URL: ${{ matrix.api_base_url }}
62+
API_KEY: ${{ secrets[matrix.api_key_secret] }}
63+
run: python tests/e2e.py
64+
65+
- name: Page via Datadog on failure
66+
if: failure()
67+
run: |
68+
curl -f -X POST "https://api.datadoghq.com/api/v1/events" \
69+
-H "DD-API-KEY: ${{ secrets.DD_API_KEY }}" \
70+
-H "Content-Type: application/json" \
71+
-d '{
72+
"title": "Cloud API smoke tests failed (${{ matrix.env_name }})",
73+
"text": "Daily smoke tests failed for ${{ matrix.env_name }}.\n\nWorkflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
74+
"priority": "normal",
75+
"alert_type": "error",
76+
"tags": [
77+
"service:cloud-api",
78+
"env:${{ matrix.env_name }}",
79+
"source:github-actions",
80+
"test:smoke"
81+
]
82+
}' || echo "WARNING: Failed to post Datadog event"

0 commit comments

Comments
 (0)