Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Feb 1, 2024
1 parent 11bf2c7 commit 9c1bf89
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 12 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/goversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ on:
branches:
- "release/**"
- "fullbuild"
- "master"
tags:
- "v*"
pull_request:
schedule:
- cron: "17 7 * * *"

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
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/buildtool/android_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/buildtool/darwin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/buildtool/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/buildtool/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
}

Expand Down
5 changes: 5 additions & 0 deletions internal/cmd/buildtool/golang_test.go
Original file line number Diff line number Diff line change
@@ -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))
}
2 changes: 1 addition & 1 deletion internal/cmd/buildtool/ios_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/buildtool/linuxstatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/buildtool/windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9c1bf89

Please sign in to comment.