From e9dc6f1f83fb360b0d498c935cb258ee98f91a20 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Thu, 1 Feb 2024 23:09:20 +0100 Subject: [PATCH] feat(buildtool): introduce script/go.bash wrapper (#1485) This wrapper invokes buildtool's gofixpath to ensure we end up executing the correct version of golang. Part of https://github.com/ooni/probe/issues/2664. --- .github/workflows/gofixpath.yml | 4 +++- internal/cmd/buildtool/gofixpath.go | 2 ++ script/go.bash | 7 +++++++ script/internal/go.bash | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100755 script/go.bash create mode 100755 script/internal/go.bash diff --git a/.github/workflows/gofixpath.yml b/.github/workflows/gofixpath.yml index ddf093acd..9041b7528 100644 --- a/.github/workflows/gofixpath.yml +++ b/.github/workflows/gofixpath.yml @@ -1,5 +1,7 @@ # Ensures that ./internal/cmd/buildtool gofixpath {command} [arguments] downloads the correct # version of go and executes {command} with [arguments] with "go" being the right version. +# +# See https://github.com/ooni/probe/issues/2664. name: gofixpath on: @@ -29,4 +31,4 @@ jobs: with: go-version: "${{ matrix.goversion }}" - - run: go run ./internal/cmd/buildtool gofixpath -- go run ./internal/cmd/buildtool generic miniooni + - run: ./script/go.bash run ./internal/cmd/buildtool generic miniooni diff --git a/internal/cmd/buildtool/gofixpath.go b/internal/cmd/buildtool/gofixpath.go index a5e1053b8..db1aeb109 100644 --- a/internal/cmd/buildtool/gofixpath.go +++ b/internal/cmd/buildtool/gofixpath.go @@ -27,6 +27,8 @@ func gofixpathSubcommand() *cobra.Command { // gofixpathMain ensures the correct version of Go is in path, otherwise // installs such a version, configure the PATH correctly, and then executes // whatever argument passed to the command with the correct PATH. +// +// See https://github.com/ooni/probe/issues/2664. func gofixpathMain(deps buildtoolmodel.Dependencies, args ...string) { // create empty environment envp := &shellx.Envp{} diff --git a/script/go.bash b/script/go.bash new file mode 100755 index 000000000..86fff4ec2 --- /dev/null +++ b/script/go.bash @@ -0,0 +1,7 @@ +#!/bin/bash +set -euxo pipefail +# We invoke ./script/internal/go.bash through the gofixpath subcommand such that +# the "go" binary in PATH is the correct version of go. +# +# See https://github.com/ooni/probe/issues/2664 +go run ./internal/cmd/buildtool gofixpath -- ./script/internal/go.bash "$@" diff --git a/script/internal/go.bash b/script/internal/go.bash new file mode 100755 index 000000000..88e8ef9b8 --- /dev/null +++ b/script/internal/go.bash @@ -0,0 +1,7 @@ +#!/bin/bash +set -euxo pipefail +# If this script is invoked by ./script/go.bash, then go is +# the correct version of go expected by the buildtool. +# +# See https://github.com/ooni/probe/issues/2664 +go "$@"