add a retry-command script (#27754)

* add a retry-command script

* add license header to retry script
This commit is contained in:
Josh Black
2024-07-12 13:18:41 -07:00
committed by GitHub
parent 979cf9011c
commit 56b32081f0
2 changed files with 24 additions and 6 deletions

View File

@@ -21,15 +21,15 @@ runs:
- uses: ./.github/actions/set-up-staticcheck
# We assume that the Go toolchain will be managed by the caller workflow so we don't set one
# up here.
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- run: ./.github/scripts/retry-command.sh go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
shell: bash
- run: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
- run: ./.github/scripts/retry-command.sh go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
shell: bash
- run: go install github.com/favadi/protoc-go-inject-tag@latest
- run: ./.github/scripts/retry-command.sh go install github.com/favadi/protoc-go-inject-tag@latest
shell: bash
- run: go install golang.org/x/tools/cmd/goimports@latest
- run: ./.github/scripts/retry-command.sh go install golang.org/x/tools/cmd/goimports@latest
shell: bash
- run: go install github.com/golangci/revgrep/cmd/revgrep@latest
- run: ./.github/scripts/retry-command.sh go install github.com/golangci/revgrep/cmd/revgrep@latest
shell: bash
- run: go install github.com/loggerhead/enumer@latest
- run: ./.github/scripts/retry-command.sh go install github.com/loggerhead/enumer@latest
shell: bash

18
.github/scripts/retry-command.sh vendored Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1
set -euo pipefail
tries=5
count=0
until "$@"
do
if [ $count -eq $tries ]; then
echo "tried $count times, exiting"
exit 1
fi
((count++))
echo "trying again, attempt $count"
sleep 2
done