[MM-18193] Use vendor folder when compiling test plugins (#12188)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
7966397f1f
Коммит
b8f0546c19
@@ -416,4 +416,4 @@ pipeline {
|
|||||||
cleanWs notFailBuild: true
|
cleanWs notFailBuild: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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:
|
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: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: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`
|
- `mattermost/mattermost-build-server:sep-17-2019` which is based on Go 1.12.9 you can use for MM versions >= `5.16.0`
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -38,23 +38,13 @@ func CompileGo(t *testing.T, sourceCode, outputPath string) {
|
|||||||
err = ioutil.WriteFile(main, []byte(sourceCode), 0600)
|
err = ioutil.WriteFile(main, []byte(sourceCode), 0600)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
if os.Getenv("GO111MODULE") != "off" {
|
_, sourceFile, _, ok := runtime.Caller(0)
|
||||||
var mattermostServerPath string
|
require.True(t, ok)
|
||||||
|
serverPath := filepath.Dir(filepath.Dir(sourceFile))
|
||||||
// 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"))
|
|
||||||
}
|
|
||||||
|
|
||||||
out := &bytes.Buffer{}
|
out := &bytes.Buffer{}
|
||||||
cmd := exec.Command("go", "build", "-o", outputPath, "main.go")
|
cmd := exec.Command("go", "build", "-mod=vendor", "-o", outputPath, main)
|
||||||
cmd.Dir = dir
|
cmd.Dir = serverPath
|
||||||
cmd.Stdout = out
|
cmd.Stdout = out
|
||||||
cmd.Stderr = out
|
cmd.Stderr = out
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user