From 44b735c85d1f7b6a8e76d50928fd93e815a3f25a Mon Sep 17 00:00:00 2001 From: Tomas Rutkauskas Date: Tue, 20 Oct 2026 11:01:05 +0300 Subject: [PATCH] Retry tests and examples on staging API 503s stag-v2 answers about one request in ten with 503 "no healthy upstream" (gateway kaulas), which failed the first build of main. Each mocha test now gets two retries and the examples up to three attempts. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/build.yml | 22 +++++++++++++++------- .github/workflows/publish.yml | 5 ++++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5f557f..d306fcd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -59,23 +59,31 @@ jobs: echo "::error::The CONVERTAPI_STAGING_TOKEN secret is not available to this run (a pull request from a fork gets no secrets)" exit 1 fi - npm test + # The staging API now and then answers 503 (no healthy upstream), so each test gets two retries. + npm run lint + npm run cover -- --retries 2 - name: Build run: npm run build # The examples call the production API and catch and print their own errors, so the preload points - # them at CONVERT_API_BASE_URI and any printed error fails the step. + # them at CONVERT_API_BASE_URI and any printed error fails an attempt. Up to three attempts, because + # the staging API now and then answers 503. - name: Run the examples env: API_TOKEN: ${{ secrets.CONVERTAPI_STAGING_TOKEN }} run: | set -euo pipefail - node --require ./.github/examples-base-uri.js examples/ 2>&1 | tee examples.log - if grep -q '^Error' examples.log; then - echo "::error::An example failed, see the errors above" - exit 1 - fi + for attempt in 1 2 3; do + node --require ./.github/examples-base-uri.js examples/ 2>&1 | tee examples.log + if ! grep -q '^Error' examples.log; then + exit 0 + fi + echo "::warning::Attempt $attempt: an example failed, see the errors above" + sleep 10 + done + echo "::error::The examples failed three times" + exit 1 build: name: build diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 62e4bcb..a2ce580 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -144,7 +144,10 @@ jobs: - name: Lint and test env: CONVERT_API_SECRET: ${{ secrets.CONVERTAPI_STAGING_TOKEN }} - run: npm test + # The staging API now and then answers 503 (no healthy upstream), so each test gets two retries. + run: | + npm run lint + npm run cover -- --retries 2 - name: Set the version and build env: