Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Nowotyński <maxmati4@gmail.com>2019-01-30 23:19:23 +0300
committerMateusz Nowotyński <maxmati4@gmail.com>2019-04-13 17:01:58 +0300
commit95af9165f4538ec4f25cda5fbaa0992bddcb6d15 (patch)
tree6dcd477947691aefbd2fdfa3bd1508dbdf244a91 /_support
parentfb06aa871d117443f3012f3e7548e374972e68fd (diff)
Add git2go
Signed-off-by: Mateusz Nowotyński <maxmati4@gmail.com>
Diffstat (limited to '_support')
-rw-r--r--_support/makegen.go52
-rw-r--r--_support/test-cover-parallel.go6
2 files changed, 44 insertions, 14 deletions
diff --git a/_support/makegen.go b/_support/makegen.go
index 146197857..ba90ef7fd 100644
--- a/_support/makegen.go
+++ b/_support/makegen.go
@@ -82,6 +82,18 @@ func (gm *gitalyMake) GitlabShellDir() string {
return filepath.Join(gm.SourceDir(), gm.GitlabShellRelDir())
}
+func (gm *gitalyMake) Git2GoVendorDir() string {
+ return filepath.Join(gm.BuildDir(), "../vendor/github.com/libgit2/git2go/vendor")
+}
+
+func (gm *gitalyMake) LibGit2Version() string {
+ return filepath.Join("0.27.8")
+}
+
+func (gm *gitalyMake) LibGit2SHA() string {
+ return filepath.Join("8313873d49dc01e8b880ec334d7430ae67496a89aaa8c6e7bbd3affb47a00c76")
+}
+
// SourceDir is the location of gitaly's files, inside the _build GOPATH.
func (gm *gitalyMake) SourceDir() string { return filepath.Join(gm.BuildDir(), "src", gm.Pkg()) }
@@ -265,10 +277,26 @@ unexport GOBIN
.PHONY: all
all: build
+{{ .Git2GoVendorDir }}/.ok:
+ rm -rf {{ .Git2GoVendorDir }}
+ mkdir -p {{ .Git2GoVendorDir }}
+
+ cd {{ .Git2GoVendorDir }} && curl -L -o libgit2.tar.gz https://github.com/libgit2/libgit2/archive/v{{ .LibGit2Version }}.tar.gz
+ cd {{ .Git2GoVendorDir }} && echo '{{ .LibGit2SHA }} libgit2.tar.gz' | shasum -a256 -c -
+ cd {{ .Git2GoVendorDir }} && tar -xvf libgit2.tar.gz
+ cd {{ .Git2GoVendorDir }} && mv libgit2-{{ .LibGit2Version }} libgit2
+
+ mkdir -p {{ .Git2GoVendorDir }}/libgit2/build
+ mkdir -p {{ .Git2GoVendorDir }}/libgit2/install/lib
+ cd {{ .Git2GoVendorDir }}/libgit2/build && cmake -DTHREADSAFE=ON -DBUILD_CLAR=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX=../install ..
+ cd {{ .Git2GoVendorDir }}/libgit2/build && cmake --build .
+
+ touch $@
+
.PHONY: build
-build: ../.ruby-bundle
+build: ../.ruby-bundle {{ .Git2GoVendorDir }}/.ok
# go install
- @cd {{ .SourceDir }} && go install {{ .GoLdFlags }} -tags "$(BUILD_TAGS)" {{ join .CommandPackages " " }}
+ @cd {{ .SourceDir }} && go install {{ .GoLdFlags }} -tags "$(BUILD_TAGS) static" {{ join .CommandPackages " " }}
# This file is used by Omnibus and CNG to skip the "bundle install"
# step. Both Omnibus and CNG assume it is in the Gitaly root, not in
@@ -337,17 +365,17 @@ prepare-tests: {{ .TestRepo }} {{ .GitTestRepo }} ../.ruby-bundle
.PHONY: test
test: test-go rspec rspec-gitlab-shell
-.PHONY: test-go
-test-go: prepare-tests
- @go test -tags "$(BUILD_TAGS)" -count=1 {{ join .AllPackages " " }} # count=1 bypasses go 1.10 test caching
+.PHONY: test-go
+test-go: prepare-tests {{ .Git2GoVendorDir }}/.ok
+ @go test -tags "$(BUILD_TAGS) static" -count=1 {{ join .AllPackages " " }} # count=1 bypasses go 1.10 test caching
.PHONY: test-with-proxies
test-with-proxies: prepare-tests
@http_proxy=http://invalid https_proxy=https://invalid go test -tags "$(BUILD_TAGS)" -count=1 {{ .Pkg }}/internal/rubyserver/
.PHONY: race-go
-race-go: prepare-tests
- @go test -tags "$(BUILD_TAGS)" -race {{ join .AllPackages " " }}
+race-go: prepare-tests {{ .Git2GoVendorDir }}/.ok
+ @go test -tags "$(BUILD_TAGS) static" -race {{ join .AllPackages " " }}
.PHONY: rspec
rspec: assemble-go prepare-tests
@@ -387,9 +415,9 @@ format: {{ .GoImports }}
@cd {{ .SourceDir }} && goimports -w -l {{ join .GoFiles " " }}
.PHONY: staticcheck
-staticcheck: {{ .StaticCheck }}
+staticcheck: {{ .StaticCheck }} {{ .Git2GoVendorDir }}/.ok
# staticcheck
- @cd {{ .SourceDir }} && {{ .StaticCheck }} {{ join .AllPackages " " }}
+ @cd {{ .SourceDir }} && {{ .StaticCheck }} -tags "$(BUILD_TAGS) static" {{ join .AllPackages " " }}
# Install staticcheck
{{ .StaticCheck }}:
@@ -426,7 +454,7 @@ rubocop: ../.ruby-bundle
cd {{ .GitalyRubyDir }} && bundle exec rubocop --parallel
.PHONY: cover
-cover: prepare-tests {{ .GoCovMerge }}
+cover: prepare-tests {{ .GoCovMerge }} {{ .Git2GoVendorDir }}/.ok
@echo "NOTE: make cover does not exit 1 on failure, don't use it to check for tests success!"
mkdir -p "{{ .CoverageDir }}"
rm -f {{ .CoverageDir }}/*.out "{{ .CoverageDir }}/all.merged" "{{ .CoverageDir }}/all.html"
@@ -442,7 +470,7 @@ cover: prepare-tests {{ .GoCovMerge }}
go install {{ .SourceDir }}/vendor/github.com/wadey/gocovmerge
.PHONY: docker
-docker:
+docker: {{ .Git2GoVendorDir }}/.ok
rm -rf docker/
mkdir -p docker/bin/
rm -rf {{ .GitalyRubyDir }}/tmp
@@ -451,7 +479,7 @@ docker:
{{ $pkg := .Pkg }}
{{ $goLdFlags := .GoLdFlags }}
{{ range $cmd := .Commands }}
- GOOS=linux GOARCH=amd64 go build {{ $goLdFlags }} -o "docker/bin/{{ $cmd }}" {{ $pkg }}/cmd/{{ $cmd }}
+ GOOS=linux GOARCH=amd64 go build -tags "$(BUILD_TAGS) static" {{ $goLdFlags }} -o "docker/bin/{{ $cmd }}" {{ $pkg }}/cmd/{{ $cmd }}
{{ end }}
cp {{ .SourceDir }}/Dockerfile docker/
docker build -t gitlab/gitaly:{{ .VersionPrefixed }} -t gitlab/gitaly:latest docker/
diff --git a/_support/test-cover-parallel.go b/_support/test-cover-parallel.go
index 2719f6d3c..f8cd4c1e4 100644
--- a/_support/test-cover-parallel.go
+++ b/_support/test-cover-parallel.go
@@ -53,6 +53,8 @@ func main() {
args := []string{
"go",
"test",
+ "-tags",
+ "static",
fmt.Sprintf("-coverpkg=%s", strings.Join(deps, ",")),
fmt.Sprintf("-coverprofile=%s/unit-%s.out", outDir, strings.Replace(pkg, "/", "_", -1)),
pkg,
@@ -82,7 +84,7 @@ func depsForPackage(pkg string, packageMap map[string]bool) ([]string, error) {
}
func buildDependentPackages(packages []string) error {
- buildDeps := exec.Command("go", append([]string{"test", "-i"}, packages...)...)
+ buildDeps := exec.Command("go", append([]string{"test", "-tags", "static", "-i"}, packages...)...)
buildDeps.Stdout = os.Stdout
buildDeps.Stderr = os.Stderr
start := time.Now()
@@ -90,7 +92,7 @@ func buildDependentPackages(packages []string) error {
log.Printf("command failed: %s", strings.Join(buildDeps.Args, " "))
return err
}
- log.Printf("go test -i\t%.3fs", time.Since(start).Seconds())
+ log.Printf("go test -tags static -i\t%.3fs", time.Since(start).Seconds())
return nil
}