Turn API Tests Into Useful CI Receipts
Описание и применение
Получайте структурированные отчёты о тестах API, которые фиксируют идентификатор запуска, детали запроса, ответ и состояние очистки, упрощая поиск ошибок в CI.
Задача
API tests that only report status codes leave developers guessing what happened during a run, especially when retries or external state are involved.
Результат
Receipts transform noisy CI logs into compact, replayable debugging artifacts, reducing time to identify failures caused by retries, external state, or fixture mismatches.
Рабочий процесс
- Generate a unique run_id combining GitHub run number and attempt
- Pass run_id to test process via environment variable
- Include run_id in API request headers (e.g., X-Test-Run)
- Execute API test and capture receipt fields in a finally block
- Write receipt JSON to a predefined directory
- Upload receipt as a GitHub Actions artifact with if: always()
- Optionally validate receipt schema and redact sensitive data
- Print a concise summary in the job output
- Keep receipts short‑lived and compare across retries
Доказательства
A receipt records the request identity, the response evidence, the relevant fixture, and the cleanup result.
The workflow should always upload the receipt, including on failure.
- Дата записи: 2026-09-21T18:00:21.010Z