From b8f0546c1936fd13c7af8df74b70dcbb0af4765d Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Tue, 24 Sep 2019 23:02:59 +0200 Subject: [PATCH] [MM-18193] Use vendor folder when compiling test plugins (#12188) --- build/Jenkinsfile.pr | 2 +- build/README.md | 4 ++-- utils/test_files_compiler.go | 22 ++++++---------------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/build/Jenkinsfile.pr b/build/Jenkinsfile.pr index ad301819f8..41b41d6a36 100644 --- a/build/Jenkinsfile.pr +++ b/build/Jenkinsfile.pr @@ -416,4 +416,4 @@ pipeline { cleanWs notFailBuild: true } } -} \ No newline at end of file +} diff --git a/build/README.md b/build/README.md index 6fbd941e4e..635cd63907 100644 --- a/build/README.md +++ b/build/README.md @@ -14,6 +14,6 @@ We have a docker image to build `mattermost-server` and it is based on Go docker In our Docker Hub Repository we have the following images: -- `mattermost/mattermost-build-server:dec-7-2018` which is based on Go 1.11 you can use for MM versions <= `5.9.0` -- `mattermost/mattermost-build-server:feb-28-2019` which is based on Go 1.12 you can use for MM versions > `5.9.0` <= `5.15.0` +- `mattermost/mattermost-build-server:dec-7-2018` which is based on Go 1.11 you can use for MM versions <= `5.8.0` +- `mattermost/mattermost-build-server:feb-28-2019` which is based on Go 1.12 you can use for MM versions >= `5.9.0` <= `5.15.0` - `mattermost/mattermost-build-server:sep-17-2019` which is based on Go 1.12.9 you can use for MM versions >= `5.16.0` diff --git a/utils/test_files_compiler.go b/utils/test_files_compiler.go index 7e4bb4a4a7..b58ad98bd2 100644 --- a/utils/test_files_compiler.go +++ b/utils/test_files_compiler.go @@ -5,11 +5,11 @@ package utils import ( "bytes" - "fmt" "io/ioutil" "os" "os/exec" "path/filepath" + "runtime" "strings" "testing" @@ -38,23 +38,13 @@ func CompileGo(t *testing.T, sourceCode, outputPath string) { err = ioutil.WriteFile(main, []byte(sourceCode), 0600) require.NoError(t, err) - if os.Getenv("GO111MODULE") != "off" { - var mattermostServerPath string - - // Generate a go.mod file relying on the local copy of the mattermost-server. - // testlib linked mattermost-server into the general temporary directory for this test. - mattermostServerPath, err = filepath.Abs("mattermost-server") - require.NoError(t, err) - - goMod(t, dir, "init", "mattermost.com/test") - goMod(t, dir, "edit", "-require", "github.com/mattermost/mattermost-server@v0.0.0") - goMod(t, dir, "edit", "-replace", fmt.Sprintf("github.com/mattermost/mattermost-server@v0.0.0=%s", mattermostServerPath)) - goMod(t, dir, "edit", "-replace", fmt.Sprintf("git.apache.org/thrift.git=%s", "github.com/apache/thrift@v0.0.0-20180902110319-2566ecd5d999")) - } + _, sourceFile, _, ok := runtime.Caller(0) + require.True(t, ok) + serverPath := filepath.Dir(filepath.Dir(sourceFile)) out := &bytes.Buffer{} - cmd := exec.Command("go", "build", "-o", outputPath, "main.go") - cmd.Dir = dir + cmd := exec.Command("go", "build", "-mod=vendor", "-o", outputPath, main) + cmd.Dir = serverPath cmd.Stdout = out cmd.Stderr = out err = cmd.Run()