Skip to content

Commit

Permalink
feat(buildtool): introduce script/go.bash wrapper (#1485)
Browse files Browse the repository at this point in the history
This wrapper invokes buildtool's gofixpath to ensure we end up executing
the correct version of golang.

Part of ooni/probe#2664.
  • Loading branch information
bassosimone authored Feb 1, 2024
1 parent b1de281 commit e9dc6f1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/gofixpath.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions internal/cmd/buildtool/gofixpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
7 changes: 7 additions & 0 deletions script/go.bash
Original file line number Diff line number Diff line change
@@ -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 "$@"
7 changes: 7 additions & 0 deletions script/internal/go.bash
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit e9dc6f1

Please sign in to comment.