@@ -27,6 +27,47 @@ check-ffi-flake: check-nix
2727 ./ scripts/ run-just.sh update-ffi-flake
2828 ./ scripts/ run-just.sh check-clean -branch
2929
30+ # Check if the golang version is set consistently for all (requires clean git tree)
31+ check-golang-version : check-nix
32+ #!/usr/bin/env bash
33+ set -euo pipefail
34+
35+ FAILED=
36+
37+ cd ffi
38+
39+ TOOLCHAIN_VERSION=$(nix develop --command bash -c " go mod edit -json | jq -r '.Toolchain'" )
40+ echo " toolchain version in ffi/go.mod is ${TOOLCHAIN_VERSION}"
41+
42+ ETH_TESTS_VERSION=$(nix develop --command bash -c " cd tests/eth && go mod edit -json | jq -r '.Toolchain'" )
43+ echo " toolchain version in ffi/tests/eth/go.mod is ${ETH_TESTS_VERSION}"
44+
45+ if [[ " ${TOOLCHAIN_VERSION}" != " ${ETH_TESTS_VERSION}" ]]; then
46+ echo " ❌ toolchain version in ffi/tests/eth/go.mod should be ${TOOLCHAIN_VERSION}"
47+ FAILED=1
48+ fi
49+
50+ FIREWOOD_TESTS_VERSION=$(nix develop --command bash -c " cd tests/firewood && go mod edit -json | jq -r '.Toolchain'" )
51+ echo " toolchain version in ffi/tests/firewood/go.mod is ${FIREWOOD_TESTS_VERSION}"
52+
53+ if [[ " ${TOOLCHAIN_VERSION}" != " ${FIREWOOD_TESTS_VERSION}" ]]; then
54+ echo " ❌ toolchain version in ffi/tests/firewood/go.mod should be ${TOOLCHAIN_VERSION}"
55+ FAILED=1
56+ fi
57+
58+ NIX_VERSION=$(nix run .#go -- version | awk ' {print $3}' )
59+ echo " golang provided by ffi/flake.nix is ${NIX_VERSION}"
60+
61+ if [[ " ${TOOLCHAIN_VERSION}" != " ${NIX_VERSION}" ]]; then
62+ echo " ❌ golang provided by ffi/flake/nix should be ${TOOLCHAIN_VERSION}"
63+ echo " It will be necessary to update the golang.url in ffi/flake.nix to point to a SHA of" \
64+ " AvalancheGo whose nix/go/flake.nix provides ${TOOLCHAIN_VERSION}."
65+ fi
66+
67+ if [[ -n " ${FAILED}" ]]; then
68+ exit 1
69+ fi
70+
3071# Check if nix is installed
3172check-nix :
3273 #!/usr/bin/env bash
@@ -57,7 +98,7 @@ test-ffi-nix-go-bindings: build-ffi-nix
5798 #!/usr/bin/env bash
5899 set -euo pipefail
59100
60- echo " Running ffi tests against bindings built by nix..."
101+ echo " running ffi tests against bindings built by nix..."
61102
62103 cd ffi
63104
@@ -81,4 +122,9 @@ update-ffi-flake: check-nix
81122 #!/usr/bin/env bash
82123 set -euo pipefail
83124 cd ffi
125+
126+ echo " ensuring flake lock file is current for golang"
84127 nix flake update golang
128+
129+ echo " checking for a consistent golang verion"
130+ ../ scripts/ run-just.sh check-golang-version
0 commit comments