Skip to content

Commit c8c7e97

Browse files
committed
fixup: Fix failure on darwin runners
1 parent e81f8a7 commit c8c7e97

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

scripts/set_avalanchego_version.sh

+32-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,38 @@ if ! [[ "$0" =~ scripts/set_avalanchego_version.sh ]]; then
99
exit 255
1010
fi
1111

12-
# Load the avalanche version
13-
source ./scripts/versions.sh
12+
# TODO(marun) Reduce duplication between this script and versions.sh. The
13+
# call to curl to get the full module hash fails on darwin runners tasked
14+
# with running the unit test suite, so it's not an option to just include
15+
# this in version.sh without further work, and that call further depends on
16+
# the module hash, which depends on getting the module details from go mod.
17+
18+
# Get version from go.mod
19+
MODULE_DETAILS="$(go list -m "github.com/ava-labs/avalanchego" 2>/dev/null)"
20+
21+
# Extract just the version part
22+
AVALANCHE_VERSION="$(echo "${MODULE_DETAILS}" | awk '{print $2}')"
23+
24+
# Check if it matches pseudo-version pattern:
25+
# v*YYYYMMDDHHMMSS-abcdef123456
26+
#
27+
# If not, the value is assumed to represent a tag
28+
if [[ "${AVALANCHE_VERSION}" =~ ^v.*[0-9]{14}-[0-9a-f]{12}$ ]]; then
29+
# Extract module hash from version
30+
MODULE_HASH="$(echo "${AVALANCHE_VERSION}" | cut -d'-' -f3)"
31+
32+
# The first 8 chars of the hash is used as the tag of avalanchego images
33+
AVALANCHE_VERSION="${MODULE_HASH::8}"
34+
35+
FULL_AVALANCHEGO_VERSION="$(curl -s "https://api.github.com/repos/ava-labs/avalanchego/commits/${MODULE_HASH}" | grep '"sha":' | head -n1 | cut -d'"' -f4)"
36+
fi
37+
38+
# FULL_AVALANCHEGO_VERSION needs to either be a tag or the full SHA to
39+
# be usable for custom github action references.
40+
if [[ -z "${FULL_AVALANCHEGO_VERSION:-}" ]]; then
41+
# Assume AVALANCHEGO_VERSION is a tag.
42+
FULL_AVALANCHEGO_VERSION="${AVALANCHE_VERSION}"
43+
fi
1444

1545
# Ensure the monitoring version is the same as the avalanche version
1646
CUSTOM_ACTION="ava-labs/avalanchego/.github/actions/run-monitored-tmpnet-cmd"

scripts/versions.sh

-10
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,7 @@ if [[ -z ${AVALANCHE_VERSION:-} ]]; then
2222

2323
# The first 8 chars of the hash is used as the tag of avalanchego images
2424
AVALANCHE_VERSION="${MODULE_HASH::8}"
25-
26-
# Get full hash from GitHub API
27-
FULL_AVALANCHEGO_VERSION="$(curl -s "https://api.github.com/repos/ava-labs/avalanchego/commits/${MODULE_HASH}" | grep '"sha":' | head -n1 | cut -d'"' -f4)"
2825
fi
2926
fi
3027

31-
# FULL_AVALANCHEGO_VERSION needs to either be a tag or the full SHA to
32-
# be usable for custom github action references.
33-
if [[ -z "${FULL_AVALANCHEGO_VERSION:-}" ]]; then
34-
# Assume AVALANCHEGO_VERSION is a tag.
35-
FULL_AVALANCHEGO_VERSION="${AVALANCHE_VERSION}"
36-
fi
37-
3828
GINKGO_VERSION=${GINKGO_VERSION:-'v2.2.0'}

0 commit comments

Comments
 (0)