Skip to content

Commit 86ab4ed

Browse files
committed
fixup: Add check for golang version consistency
1 parent 734c3c7 commit 86ab4ed

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

ffi/flake.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@
116116
program = "${go}/bin/go";
117117
};
118118

119+
apps.jq = {
120+
type = "app";
121+
program = "${pkgs.jq}/bin/jq";
122+
};
123+
119124
apps.just = {
120125
type = "app";
121126
program = "${pkgs.just}/bin/just";
@@ -127,6 +132,7 @@
127132
packages = with pkgs; [
128133
firewood-ffi
129134
go
135+
jq
130136
just
131137
rustToolchain
132138
];

ffi/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ go 1.24
77
// - ffi/flake.nix (update golang.url to a version of avalanchego's nix/go/flake.nix that uses the desired version and run `just update-ffi-flake`)
88
// - ffi/tests/eth/go.mod
99
// - ffi/tests/firewood/go.mod
10+
// `just check-golang-version` validates that these versions are in sync and will run in CI as part of the ffi-nix job.
1011
toolchain go1.24.9
1112

1213
require (

justfile

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
3172
check-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

Comments
 (0)