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: