Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
88cc7a86
Commit
88cc7a86
authored
Jul 31, 2018
by
Jacob Vosmaer (GitLab)
Committed by
Nick Thomas
Jul 31, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop calling 'make' from 'go test'
parent
25d866fa
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
58 deletions
+34
-58
Makefile
Makefile
+16
-8
internal/artifacts/artifacts_test.go
internal/artifacts/artifacts_test.go
+3
-8
internal/testhelper/testhelper.go
internal/testhelper/testhelper.go
+10
-23
main_test.go
main_test.go
+5
-19
No files found.
Makefile
View file @
88cc7a86
...
@@ -6,32 +6,34 @@ export PATH:=${GOPATH}/bin:${PATH}
...
@@ -6,32 +6,34 @@ export PATH:=${GOPATH}/bin:${PATH}
GOBUILD
=
go build
-ldflags
"-X main.Version=
${VERSION}
"
GOBUILD
=
go build
-ldflags
"-X main.Version=
${VERSION}
"
PKG
=
gitlab.com/gitlab-org/gitlab-workhorse
PKG
=
gitlab.com/gitlab-org/gitlab-workhorse
PKG_ALL
=
$(
shell
GOPATH
=
${GOPATH}
go list
${PKG}
/... |
grep
-v
/vendor/
)
PKG_ALL
=
$(
shell
GOPATH
=
${GOPATH}
go list
${PKG}
/... |
grep
-v
/vendor/
)
EXE_ALL
=
gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
all
:
clean-build
gitlab-zip-cat gitlab-zip-metadata gitlab-workhorse
all
:
clean-build
$(EXE_ALL)
gitlab-zip-cat
:
${BUILD_DIR}/_build $(shell find cmd/gitlab-zip-cat/ -name '*.go')
gitlab-zip-cat
:
${BUILD_DIR}/_build
/.sync
$(shell find cmd/gitlab-zip-cat/ -name '*.go')
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
/cmd/
$@
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
/cmd/
$@
gitlab-zip-metadata
:
${BUILD_DIR}/_build $(shell find cmd/gitlab-zip-metadata/ -name '*.go')
gitlab-zip-metadata
:
${BUILD_DIR}/_build
/.sync
$(shell find cmd/gitlab-zip-metadata/ -name '*.go')
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
/cmd/
$@
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
/cmd/
$@
gitlab-workhorse
:
${BUILD_DIR}/_build $(shell find . -name '*.go' | grep -v '^
\.
/_')
gitlab-workhorse
:
${BUILD_DIR}/_build
/.sync
$(shell find . -name '*.go' | grep -v '^
\.
/_')
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
${GOBUILD}
-o
${BUILD_DIR}
/
$@
${PKG}
install
:
gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
install
:
gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
mkdir
-p
$(DESTDIR)${PREFIX}
/bin/
mkdir
-p
$(DESTDIR)${PREFIX}
/bin/
cd
${BUILD_DIR}
&&
install
gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
${DESTDIR}${PREFIX}
/bin/
cd
${BUILD_DIR}
&&
install
gitlab-workhorse gitlab-zip-cat gitlab-zip-metadata
${DESTDIR}${PREFIX}
/bin/
${BUILD_DIR}/_build
:
${BUILD_DIR}/_build
/.sync
:
mkdir
-p
$
@
/src/
${PKG}
mkdir
-p
$
{BUILD_DIR}
/_build
/src/
${PKG}
tar
-cf
-
--exclude
_build
--exclude
.git
.
|
(
cd
$
@
/src/
${PKG}
&&
tar
-xf
-
)
tar
-cf
-
--exclude
_build
--exclude
.git
.
|
(
cd
$
{BUILD_DIR}
/_build
/src/
${PKG}
&&
tar
-xf
-
)
touch
$@
touch
$@
.PHONY
:
test
.PHONY
:
test
test
:
clean-build clean-workhorse
all govendor
test
:
clean-build clean-workhorse
govendor prepare-tests
go
fmt
${PKG_ALL}
|
awk
'{ print } END { if (NR > 0) { print "Please run go fmt"; exit 1 } }'
go
fmt
${PKG_ALL}
|
awk
'{ print } END { if (NR > 0) { print "Please run go fmt"; exit 1 } }'
_support/detect-context.sh
_support/detect-context.sh
cd
${GOPATH}
/src/
${PKG}
&&
govendor
sync
cd
${GOPATH}
/src/
${PKG}
&&
govendor
sync
cp
$(EXE_ALL)
${GOPATH}
/src/
${PKG}
go
test
${PKG_ALL}
go
test
${PKG_ALL}
@
echo
SUCCESS
@
echo
SUCCESS
...
@@ -61,3 +63,9 @@ release:
...
@@ -61,3 +63,9 @@ release:
.PHONY
:
clean-build
.PHONY
:
clean-build
clean-build
:
clean-build
:
rm
-rf
${BUILD_DIR}
/_build
rm
-rf
${BUILD_DIR}
/_build
.PHONY
:
prepare-tests
prepare-tests
:
testdata/data/group/test.git $(EXE_ALL)
testdata/data/group/test.git
:
git clone
--quiet
--bare
https://gitlab.com/gitlab-org/gitlab-test.git
$@
internal/artifacts/artifacts_test.go
View file @
88cc7a86
...
@@ -10,15 +10,10 @@ import (
...
@@ -10,15 +10,10 @@ import (
)
)
func
TestMain
(
m
*
testing
.
M
)
{
func
TestMain
(
m
*
testing
.
M
)
{
cleanup
,
err
:=
testhelper
.
BuildExecutables
()
if
err
:=
testhelper
.
BuildExecutables
();
err
!=
nil
{
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Fatal
()
log
.
WithError
(
err
)
.
Print
(
"Test setup: failed to build executables"
)
os
.
Exit
(
1
)
}
}
os
.
Exit
(
func
()
int
{
os
.
Exit
(
m
.
Run
())
defer
cleanup
()
return
m
.
Run
()
}())
}
}
internal/testhelper/testhelper.go
View file @
88cc7a86
...
@@ -5,11 +5,9 @@ import (
...
@@ -5,11 +5,9 @@ import (
"bytes"
"bytes"
"errors"
"errors"
"fmt"
"fmt"
"io/ioutil"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
"os"
"os"
"os/exec"
"path"
"path"
"regexp"
"regexp"
"runtime"
"runtime"
...
@@ -126,35 +124,24 @@ func TestServerWithHandler(url *regexp.Regexp, handler http.HandlerFunc) *httpte
...
@@ -126,35 +124,24 @@ func TestServerWithHandler(url *regexp.Regexp, handler http.HandlerFunc) *httpte
}))
}))
}
}
func
BuildExecutables
()
(
func
(),
error
)
{
var
workhorseExecutables
=
[]
string
{
"gitlab-workhorse"
,
"gitlab-zip-cat"
,
"gitlab-zip-metadata"
}
func
BuildExecutables
()
error
{
rootDir
:=
RootDir
()
rootDir
:=
RootDir
()
// This method will be invoked more than once due to Go test
for
_
,
exe
:=
range
workhorseExecutables
{
// parallelization. We must use a unique temp directory for each
if
_
,
err
:=
os
.
Stat
(
path
.
Join
(
rootDir
,
exe
));
os
.
IsNotExist
(
err
)
{
// invokation so that they do not trample each other's builds.
return
fmt
.
Errorf
(
"cannot find executable %s. Please run 'make prepare-tests'"
,
exe
)
testDir
,
err
:=
ioutil
.
TempDir
(
""
,
"gitlab-workhorse-test"
)
if
err
!=
nil
{
return
nil
,
errors
.
New
(
"could not create temp directory"
)
}
}
makeCmd
:=
exec
.
Command
(
"make"
,
"BUILD_DIR="
+
testDir
)
makeCmd
.
Dir
=
rootDir
makeCmd
.
Stderr
=
os
.
Stderr
makeCmd
.
Stdout
=
os
.
Stdout
if
err
:=
makeCmd
.
Run
();
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to run %v in %v"
,
makeCmd
,
rootDir
)
}
}
oldPath
:=
os
.
Getenv
(
"PATH"
)
oldPath
:=
os
.
Getenv
(
"PATH"
)
testPath
:=
fmt
.
Sprintf
(
"%s:%s"
,
tes
tDir
,
oldPath
)
testPath
:=
fmt
.
Sprintf
(
"%s:%s"
,
roo
tDir
,
oldPath
)
if
err
:=
os
.
Setenv
(
"PATH"
,
testPath
);
err
!=
nil
{
if
err
:=
os
.
Setenv
(
"PATH"
,
testPath
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"failed to set PATH to %v"
,
testPath
)
return
fmt
.
Errorf
(
"failed to set PATH to %v"
,
testPath
)
}
}
return
func
()
{
return
nil
os
.
Setenv
(
"PATH"
,
oldPath
)
os
.
RemoveAll
(
testDir
)
},
nil
}
}
func
RootDir
()
string
{
func
RootDir
()
string
{
...
...
main_test.go
View file @
88cc7a86
...
@@ -45,31 +45,17 @@ var cacheDir = path.Join(scratchDir, "cache")
...
@@ -45,31 +45,17 @@ var cacheDir = path.Join(scratchDir, "cache")
func
TestMain
(
m
*
testing
.
M
)
{
func
TestMain
(
m
*
testing
.
M
)
{
git
.
Testing
=
true
git
.
Testing
=
true
source
:=
"https://gitlab.com/gitlab-org/gitlab-test.git"
if
_
,
err
:=
os
.
Stat
(
path
.
Join
(
testRepoRoot
,
testRepo
));
os
.
IsNotExist
(
err
)
{
clonePath
:=
path
.
Join
(
testRepoRoot
,
testRepo
)
log
.
Fatal
(
"cannot find test repository. Please run 'make prepare-tests'"
)
if
_
,
err
:=
os
.
Stat
(
clonePath
);
err
!=
nil
{
testCmd
:=
exec
.
Command
(
"git"
,
"clone"
,
"--bare"
,
source
,
clonePath
)
testCmd
.
Stdout
=
os
.
Stdout
testCmd
.
Stderr
=
os
.
Stderr
if
err
:=
testCmd
.
Run
();
err
!=
nil
{
log
.
WithField
(
"testCmd"
,
testCmd
)
.
Print
(
"Test setup: failed to run"
)
os
.
Exit
(
-
1
)
}
}
}
cleanup
,
err
:=
testhelper
.
BuildExecutables
()
if
err
:=
testhelper
.
BuildExecutables
();
err
!=
nil
{
if
err
!=
nil
{
log
.
WithError
(
err
)
.
Fatal
()
log
.
WithError
(
err
)
.
Print
(
"Test setup: failed to build executables"
)
os
.
Exit
(
1
)
}
}
defer
gitaly
.
CloseConnections
()
defer
gitaly
.
CloseConnections
()
os
.
Exit
(
func
()
int
{
os
.
Exit
(
m
.
Run
())
defer
cleanup
()
return
m
.
Run
()
}())
}
}
func
TestAllowedClone
(
t
*
testing
.
T
)
{
func
TestAllowedClone
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment