From 8317eabea00f987f0d202c29c5703df60dc2d60f Mon Sep 17 00:00:00 2001 From: Rick Newton-Rogers Date: Wed, 28 May 2025 15:14:10 +0100 Subject: [PATCH] Retry curl operations in CI scripts (#3256) ### Motivation: Some 429: Too many requests responses have been seen when attempting to curl remote CI scripts. ### Modifications: Adding `--retry 3` which means that curl will retry 3 times on transient error codes. ### Result: Transient errors will be retried 3 times, first for 1 second and then doubled each retry. From `man curl` ``` --retry If a transient error is returned when curl tries to perform a transfer, it retries this number of times before giving up. Setting the number to 0 makes curl do no retries (which is the default). Transient error means either: a timeout, an FTP 4xx response code or an HTTP 408, 429, 500, 502, 503 or 504 response code. When curl is about to retry a transfer, it first waits one second and then for all forthcoming retries it doubles the waiting time until it reaches 10 minutes which then remains delay between the rest of the retries. By using --retry-delay you disable this exponential backoff algorithm. See also --retry-max-time to limit the total time allowed for retries. curl complies with the Retry-After: response header if one was present to know when to issue the next retry (added in 7.66.0). If --retry is provided several times, the last set value is used. ``` --- .github/workflows/benchmarks.yml | 2 +- .github/workflows/cmake_tests.yml | 4 ++-- .github/workflows/cxx_interop.yml | 4 ++-- .github/workflows/main.yml | 2 +- .github/workflows/pull_request.yml | 2 +- .github/workflows/static_sdk.yml | 4 ++-- .github/workflows/swift_matrix.yml | 6 +++--- .github/workflows/unit_tests.yml | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index b922cd5a8..22319c310 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -72,7 +72,7 @@ jobs: with: persist-credentials: false - id: generate-matrix - run: echo "benchmarks-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" + run: echo "benchmarks-matrix=$(curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" env: MATRIX_LINUX_COMMAND: "swift package --package-path ${{ inputs.benchmark_package_path }} ${{ inputs.swift_package_arguments }} benchmark baseline check --check-absolute-path ${{ inputs.benchmark_package_path }}/Thresholds/${SWIFT_VERSION}/" MATRIX_LINUX_SETUP_COMMAND: "swift --version && apt-get update -y -q && apt-get install -y -q libjemalloc-dev" diff --git a/.github/workflows/cmake_tests.yml b/.github/workflows/cmake_tests.yml index 5046197b1..ec6100cf6 100644 --- a/.github/workflows/cmake_tests.yml +++ b/.github/workflows/cmake_tests.yml @@ -40,11 +40,11 @@ jobs: which curl jq || apt -q update which curl || apt -yq install curl which jq || apt -yq install jq - curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/update-cmake-lists.sh | CONFIG_JSON='${{ inputs.update_cmake_lists_config }}' FAIL_ON_CHANGES=true bash + curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/update-cmake-lists.sh | CONFIG_JSON='${{ inputs.update_cmake_lists_config }}' FAIL_ON_CHANGES=true bash - name: CMake build run: | which curl cmake ninja || apt -q update which curl || apt -yq install curl which cmake || apt -yq install cmake which ninja || apt -yq install ninja-build - curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/cmake-build.sh | TARGET_DIRECTORY="${{ inputs.cmake_build_target_directory }}" CMAKE_VERSION="${{ inputs.cmake_version }}" bash + curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/cmake-build.sh | TARGET_DIRECTORY="${{ inputs.cmake_build_target_directory }}" CMAKE_VERSION="${{ inputs.cmake_version }}" bash diff --git a/.github/workflows/cxx_interop.yml b/.github/workflows/cxx_interop.yml index 531f0aae9..86a1d907a 100644 --- a/.github/workflows/cxx_interop.yml +++ b/.github/workflows/cxx_interop.yml @@ -65,9 +65,9 @@ jobs: with: persist-credentials: false - id: generate-matrix - run: echo "cxx-interop-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" + run: echo "cxx-interop-matrix=$(curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" env: - MATRIX_LINUX_COMMAND: "curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash" + MATRIX_LINUX_COMMAND: "curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-cxx-interop-compatibility.sh | bash" MATRIX_LINUX_SETUP_COMMAND: "swift --version && apt-get update -y -q && apt-get install -y -q curl jq" MATRIX_LINUX_5_9_ENABLED: ${{ inputs.linux_5_9_enabled }} MATRIX_LINUX_5_10_ENABLED: ${{ inputs.linux_5_10_enabled }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab987aaa5..4ebec19db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,7 @@ jobs: with: persist-credentials: false - id: generate-matrix - run: echo "integration-test-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" + run: echo "integration-test-matrix=$(curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" env: MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq" MATRIX_LINUX_COMMAND: "./scripts/integration_tests.sh" diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9207df4bf..ae7827ba8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -45,7 +45,7 @@ jobs: with: persist-credentials: false - id: generate-matrix - run: echo "integration-test-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" + run: echo "integration-test-matrix=$(curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" env: MATRIX_LINUX_SETUP_COMMAND: "apt-get update -y -q && apt-get install -y -q lsof dnsutils netcat-openbsd net-tools curl jq" MATRIX_LINUX_COMMAND: "./scripts/integration_tests.sh" diff --git a/.github/workflows/static_sdk.yml b/.github/workflows/static_sdk.yml index b6de6ba2e..b00477abe 100644 --- a/.github/workflows/static_sdk.yml +++ b/.github/workflows/static_sdk.yml @@ -19,7 +19,7 @@ jobs: "platform":"Linux", "runner":"ubuntu-latest", "image":"ubuntu:jammy", - "setup_command":"apt update -q && apt install -y -q curl jq tar && curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_prerequisites.sh | bash && curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_static_sdk.sh | INSTALL_SWIFT_STATIC_SDK_VERSION=latest INSTALL_SWIFT_STATIC_SDK_ARCH=x86_64 bash && hash -r", + "setup_command":"apt update -q && apt install -y -q curl jq tar && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_prerequisites.sh | bash && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_static_sdk.sh | INSTALL_SWIFT_STATIC_SDK_VERSION=latest INSTALL_SWIFT_STATIC_SDK_ARCH=x86_64 bash && hash -r", "command":"swift build", "command_arguments":"--swift-sdk x86_64-swift-linux-musl" }, @@ -29,7 +29,7 @@ jobs: "platform":"Linux", "runner":"ubuntu-latest", "image":"ubuntu:jammy", - "setup_command":"apt update -q && apt install -y -q curl jq tar && curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_prerequisites.sh | bash && curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_static_sdk.sh | INSTALL_SWIFT_STATIC_SDK_BRANCH=main INSTALL_SWIFT_STATIC_SDK_ARCH=x86_64 bash && hash -r", + "setup_command":"apt update -q && apt install -y -q curl jq tar && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_swift_prerequisites.sh | bash && curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/install_static_sdk.sh | INSTALL_SWIFT_STATIC_SDK_BRANCH=main INSTALL_SWIFT_STATIC_SDK_ARCH=x86_64 bash && hash -r", "command":"swift build", "command_arguments":"--swift-sdk x86_64-swift-linux-musl" } diff --git a/.github/workflows/swift_matrix.yml b/.github/workflows/swift_matrix.yml index 20badb616..90cade761 100644 --- a/.github/workflows/swift_matrix.yml +++ b/.github/workflows/swift_matrix.yml @@ -165,7 +165,7 @@ jobs: COMMAND_OVERRIDE_NIGHTLY_MAIN: ${{ inputs.matrix_linux_nightly_main_command_override }} run: | apt-get -qq update && apt-get -qq -y install curl - curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash + curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.sh | bash windows: name: Windows (${{ matrix.swift.swift_version }}) @@ -189,7 +189,7 @@ jobs: persist-credentials: false - name: Donwload matrix script if: ${{ matrix.swift.enabled }} - run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1 + run: curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1 - name: Run matrix job if: ${{ matrix.swift.enabled }} run: | @@ -221,7 +221,7 @@ jobs: submodules: true - name: Donwload matrix script if: ${{ matrix.swift.enabled }} - run: curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1 + run: curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/check-matrix-job.ps1 -o __check-matrix-job.ps1 - name: Run matrix job if: ${{ matrix.swift.enabled }} run: | diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index c2fd2f9f0..b5b1882fa 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -129,7 +129,7 @@ jobs: with: persist-credentials: false - id: generate-matrix - run: echo "unit-test-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" + run: echo "unit-test-matrix=$(curl -s --retry 3 https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT" env: MATRIX_LINUX_SETUP_COMMAND: "swift --version" MATRIX_LINUX_COMMAND: "swift test"