Skip to content
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

scripts: add go-directive-sync, run with generate, sync go directives #1077

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.22.7
go 1.23.0

use (
.
Expand Down
32 changes: 32 additions & 0 deletions packages/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@
protoc-gen-go
protoc-gen-go-grpc
nix-update
scripts.go-directive-sync
];
text = ''
echo "Syncing go directive versions in go.mod/go.work files" >&2
go-directive-sync

while IFS= read -r dir; do
echo "Running go mod tidy on $dir" >&2
go mod tidy
Expand Down Expand Up @@ -531,4 +535,32 @@
];
text = builtins.readFile ./test-peerpods.sh;
};

# Sync the go directive between go.mod/go.work files (that is, the 'go' statement of these files).
# We take the latest version we find and use that everywhere.
go-directive-sync = writeShellApplication {
name = "go-directive-sync";
runtimeInputs = with pkgs; [
go
findutils
coreutils
];
text = ''
set -euo pipefail

modFiles=$(find . -regex '.*/go[.]\(mod\|work\)$')

goVers=()
while IFS= read -r f; do
ver=$(grep -E '^go [0-9]+[.][0-9]+[.][0-9]+$' "$f")
goVers+=("$ver")
done <<< "$modFiles"

maxVer=$(printf "%s\n" "''${goVers[@]}" | sort -V | tail -n1)

while IFS= read -r f; do
sed -i "s/^go [0-9]\+\.[0-9]\+\.[0-9]\+$/''${maxVer}/" "$f"
done <<< "$modFiles"
'';
};
}
2 changes: 1 addition & 1 deletion service-mesh/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/edgelesssys/contrast/service-mesh

go 1.22.0
go 1.23.0

require (
github.com/coreos/go-iptables v0.8.0
Expand Down
2 changes: 1 addition & 1 deletion tools/tdx-measure/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/edgelesssys/contrast/tdx-measure

go 1.22.0
go 1.23.0

require (
github.com/foxboron/go-uefi v0.0.0-20241017190036-fab4fdf2f2f3
Expand Down