Repository navigation
CBG-5862: retry Go module downloads in CI #8792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
17b5691
CBG-5862: retry Go module downloads in CI
bbrks 90d861e
CBG-5862: validate retry.sh inputs and fix the e2e helper path
bbrks 0324434
Merge remote-tracking branch 'origin/main' into CBG-5862
bbrks 8bb8d25
CBG-5862: prefetch the ruleguard module deps too
bbrks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Copyright 2026-Present Couchbase, Inc. | ||
| # | ||
| # Use of this software is governed by the Business Source License included in | ||
| # the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that | ||
| # file, in accordance with the Business Source License, use of this software | ||
| # will be governed by the Apache License, Version 2.0, included in the file | ||
| # licenses/APL2.txt. | ||
|
|
||
| # Runs a command, retrying with exponential backoff. CI uses this for Go module downloads, which | ||
| # fail intermittently when the module proxy is unhealthy. | ||
| # | ||
| # Usage: .ci/retry.sh <command> [args...] | ||
| # Tunable with RETRY_ATTEMPTS (default 4) and RETRY_DELAY (initial backoff seconds, default 5). | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| attempts=${RETRY_ATTEMPTS:-4} | ||
| delay=${RETRY_DELAY:-5} | ||
|
|
||
| # without these guards, no args exits 0 without running anything and a bad attempt count skips the loop entirely | ||
| if (($# == 0)); then | ||
| echo "retry: usage: .ci/retry.sh <command> [args...]" >&2 | ||
| exit 2 | ||
| fi | ||
| if [[ ! "${attempts}" =~ ^[1-9][0-9]*$ ]]; then | ||
| echo "retry: RETRY_ATTEMPTS must be a positive integer, got '${attempts}'" >&2 | ||
| exit 2 | ||
| fi | ||
| if [[ ! "${delay}" =~ ^[0-9]+$ ]]; then | ||
| echo "retry: RETRY_DELAY must be a non-negative integer, got '${delay}'" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| for ((attempt = 1; attempt <= attempts; attempt++)); do | ||
| # capture the status here: $? after an if-block is the status of the if, not of the command | ||
| status=0 | ||
| "$@" || status=$? | ||
| if ((status == 0)); then | ||
| exit 0 | ||
| fi | ||
| if ((attempt < attempts)); then | ||
| # diagnostics go to stderr so callers capturing stdout get the command's output only | ||
| echo "retry: attempt ${attempt}/${attempts} of '$*' failed (exit ${status}), retrying in ${delay}s" >&2 | ||
| sleep "${delay}" | ||
| delay=$((delay * 2)) | ||
| fi | ||
| done | ||
|
|
||
| echo "retry: '$*' failed after ${attempts} attempts" >&2 | ||
| exit "${status}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.