MM-43753: Module workspaces (#20113)
* MM-43753: Module workspaces Move to module workspaces We make the following changes: - Remove the vendor directory. - Dynamically create the go.work file if it doesn't exist. - Set the MM_SERVER_PATH for enterprise tests. https://mattermost.atlassian.net/browse/MM-43753 ```release-note NONE ``` * Fix missing reference to MM_SERVER_PATH ```release-note NONE ``` * Update test to add another nested dir ```release-note NONE ``` * Have separate script to create go.work file ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
cd487c812c
Коммит
38d0c2bcf3
@@ -8,14 +8,22 @@ import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
var (
|
||||
commonBaseSearchPaths = []string{
|
||||
func CommonBaseSearchPaths() []string {
|
||||
paths := []string{
|
||||
".",
|
||||
"..",
|
||||
"../..",
|
||||
"../../..",
|
||||
"../../../..",
|
||||
}
|
||||
)
|
||||
|
||||
// this enables the server to be used in tests from a different repository
|
||||
if mmPath := os.Getenv("MM_SERVER_PATH"); mmPath != "" {
|
||||
paths = append(paths, mmPath)
|
||||
}
|
||||
|
||||
return paths
|
||||
}
|
||||
|
||||
func findPath(path string, baseSearchPaths []string, workingDirFirst bool, filter func(os.FileInfo) bool) string {
|
||||
if filepath.IsAbs(path) {
|
||||
@@ -79,7 +87,7 @@ func FindPath(path string, baseSearchPaths []string, filter func(os.FileInfo) bo
|
||||
// FindFile looks for the given file in nearby ancestors relative to the current working
|
||||
// directory as well as the directory of the executable.
|
||||
func FindFile(path string) string {
|
||||
return FindPath(path, commonBaseSearchPaths, func(fileInfo os.FileInfo) bool {
|
||||
return FindPath(path, CommonBaseSearchPaths(), func(fileInfo os.FileInfo) bool {
|
||||
return !fileInfo.IsDir()
|
||||
})
|
||||
}
|
||||
@@ -87,7 +95,7 @@ func FindFile(path string) string {
|
||||
// fileutils.FindDir looks for the given directory in nearby ancestors relative to the current working
|
||||
// directory as well as the directory of the executable, falling back to `./` if not found.
|
||||
func FindDir(dir string) (string, bool) {
|
||||
found := FindPath(dir, commonBaseSearchPaths, func(fileInfo os.FileInfo) bool {
|
||||
found := FindPath(dir, CommonBaseSearchPaths(), func(fileInfo os.FileInfo) bool {
|
||||
return fileInfo.IsDir()
|
||||
})
|
||||
if found == "" {
|
||||
@@ -100,7 +108,7 @@ func FindDir(dir string) (string, bool) {
|
||||
// FindDirRelBinary looks for the given directory in nearby ancestors relative to the
|
||||
// directory of the executable, then relative to the working directory, falling back to `./` if not found.
|
||||
func FindDirRelBinary(dir string) (string, bool) {
|
||||
found := findPath(dir, commonBaseSearchPaths, false, func(fileInfo os.FileInfo) bool {
|
||||
found := findPath(dir, CommonBaseSearchPaths(), false, func(fileInfo os.FileInfo) bool {
|
||||
return fileInfo.IsDir()
|
||||
})
|
||||
if found == "" {
|
||||
|
||||
Ссылка в новой задаче
Block a user