From 9c1bf89a64495b91966b9c6d719b1a662d918be9 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Thu, 1 Feb 2024 21:37:26 +0100 Subject: [PATCH] x --- .github/workflows/goversion.yml | 6 ++++-- internal/cmd/buildtool/android_test.go | 4 ++-- internal/cmd/buildtool/darwin_test.go | 2 +- internal/cmd/buildtool/generic.go | 4 ++-- internal/cmd/buildtool/golang.go | 5 +++-- internal/cmd/buildtool/golang_test.go | 5 +++++ internal/cmd/buildtool/ios_test.go | 2 +- internal/cmd/buildtool/linuxstatic_test.go | 2 +- internal/cmd/buildtool/windows_test.go | 2 +- 9 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/goversion.yml b/.github/workflows/goversion.yml index f4b127b44..5786cab94 100644 --- a/.github/workflows/goversion.yml +++ b/.github/workflows/goversion.yml @@ -6,8 +6,10 @@ on: branches: - "release/**" - "fullbuild" + - "master" tags: - "v*" + pull_request: schedule: - cron: "17 7 * * *" @@ -15,8 +17,8 @@ jobs: build_with_unexpected_go_version: strategy: matrix: - goversion: ["1.19", "1.21"] - system: [ubuntu-latest, windows-latest, macos-latest] + goversion: ["1.18", "1.19", "1.20", "1.21"] + system: [ubuntu-latest, macos-latest] runs-on: "${{ matrix.system }}" steps: - uses: actions/checkout@v3 diff --git a/internal/cmd/buildtool/android_test.go b/internal/cmd/buildtool/android_test.go index 69ce3cbb1..330573fd0 100644 --- a/internal/cmd/buildtool/android_test.go +++ b/internal/cmd/buildtool/android_test.go @@ -121,7 +121,7 @@ func TestAndroidBuildGomobile(t *testing.T) { buildtooltest.TagGOPATH: 2, buildtooltest.TagAndroidNDKCheck: 1, buildtooltest.TagAndroidSDKCheck: 1, - buildtooltest.TagGolangBinary: 1, + buildtooltest.TagGolangBinary: 3, buildtooltest.TagPsiphonMaybeCopyConfigFiles: 1, buildtooltest.TagPsiphonFilesExist: 1, } @@ -406,7 +406,7 @@ func TestAndroidBuildCLIAll(t *testing.T) { expectCalls := map[string]int{ buildtooltest.TagAndroidNDKCheck: 1, buildtooltest.TagAndroidSDKCheck: 1, - buildtooltest.TagGolangBinary: 1, + buildtooltest.TagGolangBinary: 8, buildtooltest.TagPsiphonMaybeCopyConfigFiles: 1, buildtooltest.TagPsiphonFilesExist: 8, } diff --git a/internal/cmd/buildtool/darwin_test.go b/internal/cmd/buildtool/darwin_test.go index b618067be..d6f88349a 100644 --- a/internal/cmd/buildtool/darwin_test.go +++ b/internal/cmd/buildtool/darwin_test.go @@ -130,7 +130,7 @@ func TestDarwinBuildAll(t *testing.T) { }) expectCalls := map[string]int{ - buildtooltest.TagGolangBinary: 1, + buildtooltest.TagGolangBinary: 4, buildtooltest.TagPsiphonMaybeCopyConfigFiles: 1, buildtooltest.TagPsiphonFilesExist: 4, } diff --git a/internal/cmd/buildtool/generic.go b/internal/cmd/buildtool/generic.go index b69b25b2d..6c8fa08ac 100644 --- a/internal/cmd/buildtool/generic.go +++ b/internal/cmd/buildtool/generic.go @@ -54,7 +54,7 @@ func genericBuildPackage(deps buildtoolmodel.Dependencies, product *product) { log.Infof("building %s for %s/%s", product.Pkg, runtime.GOOS, runtime.GOARCH) - argv := runtimex.Try1(shellx.NewArgv(golangBinary(), "build")) + argv := runtimex.Try1(shellx.NewArgv(deps.GolangBinary(), "build")) if deps.PsiphonFilesExist() { argv.Append("-tags", "ooni_psiphon_config") } @@ -74,7 +74,7 @@ func genericBuildLibrary(deps buildtoolmodel.Dependencies, product *product) { // packages paths are separated by forward slashes! library := runtimex.Try1(generateLibrary(path.Base(product.Pkg), os)) - argv := runtimex.Try1(shellx.NewArgv(golangBinary(), "build")) + argv := runtimex.Try1(shellx.NewArgv(deps.GolangBinary(), "build")) argv.Append("-buildmode", "c-shared") argv.Append("-o", library) argv.Append(product.Pkg) diff --git a/internal/cmd/buildtool/golang.go b/internal/cmd/buildtool/golang.go index 1e8c1cfd1..fab9b5083 100644 --- a/internal/cmd/buildtool/golang.go +++ b/internal/cmd/buildtool/golang.go @@ -34,11 +34,11 @@ func golangInstall(filename string) string { // read the version of Go we would like to use expected := string(must.FirstLineBytes(must.ReadFile(filename))) - // install the downloaded script + // install the wrapper command packageName := fmt.Sprintf("golang.org/dl/go%s@latest", expected) must.Run(log.Log, "go", "install", "-v", packageName) - // run the downloader script + // run the wrapper to download the distribution gobinary := filepath.Join( string(must.FirstLineBytes(must.RunOutput(log.Log, "go", "env", "GOPATH"))), "bin", @@ -47,6 +47,7 @@ func golangInstall(filename string) string { must.Run(log.Log, gobinary, "download") // if all is good, then we have the right gobinary + // along with the distribution return gobinary } diff --git a/internal/cmd/buildtool/golang_test.go b/internal/cmd/buildtool/golang_test.go index 566358b7a..17ecb9ba9 100644 --- a/internal/cmd/buildtool/golang_test.go +++ b/internal/cmd/buildtool/golang_test.go @@ -1,13 +1,18 @@ package main import ( + "os" "testing" "github.com/ooni/probe-cli/v3/internal/must" + "github.com/ooni/probe-cli/v3/internal/runtimex" ) func TestGolangBinary(t *testing.T) { // make sure the code does not panic when it runs and returns a valid binary + oldDirectory := runtimex.Try1(os.Getwd()) + runtimex.Try0(os.Chdir("../../..")) value := golangBinary() must.RunQuiet(value, "version") + runtimex.Try0(os.Chdir(oldDirectory)) } diff --git a/internal/cmd/buildtool/ios_test.go b/internal/cmd/buildtool/ios_test.go index 931f44c40..7c2dcb3ab 100644 --- a/internal/cmd/buildtool/ios_test.go +++ b/internal/cmd/buildtool/ios_test.go @@ -107,7 +107,7 @@ func TestIOSBuildGomobile(t *testing.T) { expectCalls := map[string]int{ buildtooltest.TagGOPATH: 1, - buildtooltest.TagGolangBinary: 1, + buildtooltest.TagGolangBinary: 3, buildtooltest.TagPsiphonMaybeCopyConfigFiles: 1, buildtooltest.TagPsiphonFilesExist: 1, } diff --git a/internal/cmd/buildtool/linuxstatic_test.go b/internal/cmd/buildtool/linuxstatic_test.go index 0b18194ff..baf876087 100644 --- a/internal/cmd/buildtool/linuxstatic_test.go +++ b/internal/cmd/buildtool/linuxstatic_test.go @@ -198,7 +198,7 @@ func TestLinuxStaticBuildAll(t *testing.T) { }) expectCalls := map[string]int{ - buildtooltest.TagGolangBinary: 1, + buildtooltest.TagGolangBinary: 2, buildtooltest.TagPsiphonMaybeCopyConfigFiles: 1, buildtooltest.TagPsiphonFilesExist: 2, } diff --git a/internal/cmd/buildtool/windows_test.go b/internal/cmd/buildtool/windows_test.go index fb40ac3be..43e23878e 100644 --- a/internal/cmd/buildtool/windows_test.go +++ b/internal/cmd/buildtool/windows_test.go @@ -138,7 +138,7 @@ func TestWindowsBuildAll(t *testing.T) { }) expectCalls := map[string]int{ - buildtooltest.TagGolangBinary: 1, + buildtooltest.TagGolangBinary: 4, buildtooltest.TagPsiphonMaybeCopyConfigFiles: 1, buildtooltest.TagPsiphonFilesExist: 4, buildtooltest.TagWindowsMingwCheck: 1,