diff --git a/.github/workflows/alltests.yml b/.github/workflows/alltests.yml index a4fcf52fe5..069c7910cc 100644 --- a/.github/workflows/alltests.yml +++ b/.github/workflows/alltests.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 5815946931..75aa02dc5e 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -22,7 +22,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 6572ee63e2..7ebcd0b376 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/go1.19.yml b/.github/workflows/go1.19.yml new file mode 100644 index 0000000000..0e6e6c8f41 --- /dev/null +++ b/.github/workflows/go1.19.yml @@ -0,0 +1,27 @@ +# Interim build script checking for go1.19 +# +# Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222) +# +name: go1.19 +on: + pull_request: + push: + branches: + - "master" + - "release/**" + +jobs: + build_and_test: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + + - run: go install golang.org/dl/go1.19@latest + + - run: $(go env GOPATH)/bin/go1.19 download + + - run: $(go env GOPATH)/bin/go1.19 build -v ./... + + - run: $(go env GOPATH)/bin/go1.19 test -short -race -tags shaping ./... + diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index 4b588dc285..1c442eae08 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -19,7 +19,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 55dccabd05..4da0a2f472 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -22,7 +22,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/jafar.yml b/.github/workflows/jafar.yml index c048b91709..66225ee05d 100644 --- a/.github/workflows/jafar.yml +++ b/.github/workflows/jafar.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 339dcca717..542d925daf 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -22,7 +22,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/miniooni.yml b/.github/workflows/miniooni.yml index d1a163842f..b6e4f1c6fc 100644 --- a/.github/workflows/miniooni.yml +++ b/.github/workflows/miniooni.yml @@ -27,7 +27,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/oohelperd.yml b/.github/workflows/oohelperd.yml index 0ea5d7b9a8..b6135b6b7d 100644 --- a/.github/workflows/oohelperd.yml +++ b/.github/workflows/oohelperd.yml @@ -19,7 +19,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/qafbmessenger.yml b/.github/workflows/qafbmessenger.yml index dbeda34f1b..0e8d499b01 100644 --- a/.github/workflows/qafbmessenger.yml +++ b/.github/workflows/qafbmessenger.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/qahhfm.yml b/.github/workflows/qahhfm.yml index 3f41cc8fd1..477fd61cb2 100644 --- a/.github/workflows/qahhfm.yml +++ b/.github/workflows/qahhfm.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/qahirl.yml b/.github/workflows/qahirl.yml index 8d1c90ba83..b3eb70fc8f 100644 --- a/.github/workflows/qahirl.yml +++ b/.github/workflows/qahirl.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/qatelegram.yml b/.github/workflows/qatelegram.yml index 951a5b5526..22a73c1991 100644 --- a/.github/workflows/qatelegram.yml +++ b/.github/workflows/qatelegram.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/qawebconnectivity.yml b/.github/workflows/qawebconnectivity.yml index 808884fcfc..57266abf3f 100644 --- a/.github/workflows/qawebconnectivity.yml +++ b/.github/workflows/qawebconnectivity.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/qawhatsapp.yml b/.github/workflows/qawhatsapp.yml index db88e3214c..fc17cda63d 100644 --- a/.github/workflows/qawhatsapp.yml +++ b/.github/workflows/qawhatsapp.yml @@ -15,7 +15,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/tarball.yml b/.github/workflows/tarball.yml index 48118eafc1..895fb27737 100644 --- a/.github/workflows/tarball.yml +++ b/.github/workflows/tarball.yml @@ -21,7 +21,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index a9b10240e7..c3f8b3bcf1 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -19,7 +19,7 @@ jobs: id: goversion run: echo ::set-output name=version::$(cat GOVERSION) - - uses: actions/setup-go@v1 + - uses: actions/setup-go@v3 with: go-version: "${{ steps.goversion.outputs.version }}" diff --git a/Readme.md b/Readme.md index e484a68700..3fb8305c0b 100644 --- a/Readme.md +++ b/Readme.md @@ -57,6 +57,11 @@ Be sure you have: 2. a C compiler (Mingw-w64 for Windows). +### Caveats + +As of 2022-08-22, building with go1.19 will not include [Psiphon](https://psiphon.ca/) as +a dependency. Fixing this issue is TODO(https://github.com/ooni/probe/issues/2222). + ### ooniprobe Ooniprobe is the official CLI client. Compile using: diff --git a/internal/engine/experiment/urlgetter/getter_integration_test.go b/internal/engine/experiment/urlgetter/getter_integration_test.go index 29986351fa..b58258c0d3 100644 --- a/internal/engine/experiment/urlgetter/getter_integration_test.go +++ b/internal/engine/experiment/urlgetter/getter_integration_test.go @@ -4,6 +4,7 @@ import ( "context" "errors" "net/http" + "runtime" "strings" "testing" @@ -275,6 +276,9 @@ func TestGetterWithCancelledContextNoFollowRedirects(t *testing.T) { } func TestGetterWithCancelledContextCannotStartTunnel(t *testing.T) { + if strings.HasPrefix(runtime.Version(), "go1.19") { + t.Skip("TODO(https://github.com/ooni/probe/issues/2222)") + } ctx, cancel := context.WithCancel(context.Background()) cancel() // fail immediately g := urlgetter.Getter{ diff --git a/internal/tunnel/config.go b/internal/tunnel/config.go index 75bfc65210..7b1cf11c0a 100644 --- a/internal/tunnel/config.go +++ b/internal/tunnel/config.go @@ -10,7 +10,6 @@ import ( "github.com/cretz/bine/control" "github.com/cretz/bine/tor" "github.com/ooni/probe-cli/v3/internal/model" - "github.com/ooni/psiphon/tunnel-core/ClientLibrary/clientlib" "golang.org/x/sys/execabs" ) @@ -60,10 +59,6 @@ type Config struct { // testSocks5New allows us to mock socks5.New in testing code. testSocks5New func(conf *socks5.Config) (*socks5.Server, error) - // testStartPsiphon allows us to mock psiphon's clientlib.StartTunnel. - testStartPsiphon func(ctx context.Context, config []byte, - workdir string) (*clientlib.PsiphonTunnel, error) - // testTorStart allows us to mock tor.Start. testTorStart func(ctx context.Context, conf *tor.StartConf) (*tor.Tor, error) @@ -119,16 +114,6 @@ func (c *Config) socks5New(conf *socks5.Config) (*socks5.Server, error) { return socks5.New(conf) } -// startPsiphon calls either testStartPsiphon or psiphon's clientlib.StartTunnel. -func (c *Config) startPsiphon(ctx context.Context, config []byte, - workdir string) (*clientlib.PsiphonTunnel, error) { - if c.testStartPsiphon != nil { - return c.testStartPsiphon(ctx, config, workdir) - } - return clientlib.StartTunnel(ctx, config, "", clientlib.Parameters{ - DataRootDirectory: &workdir}, nil, nil) -} - // ooniTorBinaryEnv is the name of the environment variable // we're using to get the path to the tor binary when we are // being run by the ooni/probe-desktop application. diff --git a/internal/tunnel/psiphon.go b/internal/tunnel/psiphon.go index 13b4ea93ba..2c37dc7715 100644 --- a/internal/tunnel/psiphon.go +++ b/internal/tunnel/psiphon.go @@ -1,5 +1,13 @@ +//go:build !go1.19 + package tunnel +// +// Psiphon not working with go1.19 +// +// TODO(https://github.com/ooni/probe/issues/2222) +// + import ( "context" "fmt" @@ -11,6 +19,13 @@ import ( "github.com/ooni/psiphon/tunnel-core/ClientLibrary/clientlib" ) +// mockableStartPsiphon allows us to test for psiphon startup failures. +var mockableStartPsiphon = func( + ctx context.Context, config []byte, workdir string) (*clientlib.PsiphonTunnel, error) { + return clientlib.StartTunnel(ctx, config, "", clientlib.Parameters{ + DataRootDirectory: &workdir}, nil, nil) +} + // psiphonTunnel is a psiphon tunnel type psiphonTunnel struct { // bootstrapTime is the bootstrapTime of the bootstrap @@ -53,7 +68,7 @@ func psiphonStart(ctx context.Context, config *Config) (Tunnel, DebugInfo, error return nil, debugInfo, err } start := time.Now() - tunnel, err := config.startPsiphon(ctx, configJSON, workdir) + tunnel, err := mockableStartPsiphon(ctx, configJSON, workdir) if err != nil { return nil, debugInfo, err } diff --git a/internal/tunnel/psiphon_go119.go b/internal/tunnel/psiphon_go119.go new file mode 100644 index 0000000000..c90d537d01 --- /dev/null +++ b/internal/tunnel/psiphon_go119.go @@ -0,0 +1,19 @@ +//go:build go1.19 + +package tunnel + +// +// Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222) +// + +import ( + "context" + "errors" +) + +// psiphonStart starts the psiphon tunnel. +func psiphonStart(ctx context.Context, config *Config) (Tunnel, DebugInfo, error) { + return nil, DebugInfo{}, errors.New( + "psiphon is disabled when building with go1.19: see https://github.com/ooni/probe/issues/2222 for more information", + ) +} diff --git a/internal/tunnel/psiphon_integration_test.go b/internal/tunnel/psiphon_integration_test.go index 40e680cd27..4c5843133e 100644 --- a/internal/tunnel/psiphon_integration_test.go +++ b/internal/tunnel/psiphon_integration_test.go @@ -1,5 +1,11 @@ +//go:build !go1.19 + package tunnel_test +// +// Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222) +// + import ( "context" "io/ioutil" diff --git a/internal/tunnel/psiphon_test.go b/internal/tunnel/psiphon_test.go index 63e1521fad..451356e5b1 100644 --- a/internal/tunnel/psiphon_test.go +++ b/internal/tunnel/psiphon_test.go @@ -1,5 +1,11 @@ +//go:build !go1.19 + package tunnel +// +// Psiphon not working with go1.19: TODO(https://github.com/ooni/probe/issues/2222) +// + import ( "context" "errors" @@ -82,13 +88,17 @@ func TestPsiphonStartFailure(t *testing.T) { sess := &MockableSession{ Result: []byte(`{}`), } + oldStartPsiphon := mockableStartPsiphon + defer func() { + mockableStartPsiphon = oldStartPsiphon + }() + mockableStartPsiphon = func(ctx context.Context, config []byte, + workdir string) (*clientlib.PsiphonTunnel, error) { + return nil, expected + } tunnel, _, err := psiphonStart(context.Background(), &Config{ Session: sess, TunnelDir: "testdata", - testStartPsiphon: func(ctx context.Context, config []byte, - workdir string) (*clientlib.PsiphonTunnel, error) { - return nil, expected - }, }) if !errors.Is(err, expected) { t.Fatal("not the error we expected") diff --git a/internal/tunnel/tunnel_test.go b/internal/tunnel/tunnel_test.go index 4122ca494a..1736cddb5c 100644 --- a/internal/tunnel/tunnel_test.go +++ b/internal/tunnel/tunnel_test.go @@ -3,6 +3,8 @@ package tunnel_test import ( "context" "errors" + "runtime" + "strings" "testing" "github.com/ooni/probe-cli/v3/internal/tunnel" @@ -23,6 +25,9 @@ func TestStartNoTunnel(t *testing.T) { } func TestStartPsiphonWithCancelledContext(t *testing.T) { + if strings.HasPrefix(runtime.Version(), "go1.19") { + t.Skip("TODO(https://github.com/ooni/probe/issues/2222)") + } ctx, cancel := context.WithCancel(context.Background()) cancel() // fail immediately tun, _, err := tunnel.Start(ctx, &tunnel.Config{