# _build/Makefile # # This is an auto-generated Makefile. Do not edit. Do not invoke # directly, use ../Makefile instead. This file is generated using # makegen.go. # # These variables may be overridden at runtime by top-level make PREFIX ?= /usr/local INSTALL_DEST_DIR := $(DESTDIR)$(PREFIX)/bin/ BUNDLE_FLAGS ?= {{ .BundleFlags }} ASSEMBLY_ROOT ?= {{ .BuildDir }}/assembly BUILD_TAGS := tracer_static tracer_static_jaeger unexport GOROOT export GOBIN = {{ .BuildDir }}/bin export GO111MODULE=on export GOPROXY ?= https://proxy.golang.org export PATH := {{ .BuildDir }}/bin:$(PATH) .NOTPARALLEL: .PHONY: all all: build .PHONY: build build: ../.ruby-bundle # go install @cd {{ .SourceDir }} && go install {{ .GoLdFlags }} -tags "$(BUILD_TAGS)" {{ 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 # _build. Hence the '../' in front. ../.ruby-bundle: {{ .GitalyRubyDir }}/Gemfile.lock {{ .GitalyRubyDir }}/Gemfile cd {{ .GitalyRubyDir }} && bundle config # for debugging cd {{ .GitalyRubyDir }} && bundle install $(BUNDLE_FLAGS) touch $@ .PHONY: install install: build mkdir -p $(INSTALL_DEST_DIR) cd bin && install {{ join .Commands " " }} $(INSTALL_DEST_DIR) .PHONY: force-ruby-bundle force-ruby-bundle: rm -f ../.ruby-bundle # Assembles all runtime components into a directory # Used by the GDK: run 'make assemble ASSEMBLY_ROOT=.../gitaly' .PHONY: assemble assemble: force-ruby-bundle build assemble-internal # assemble-internal does not force 'bundle install' to run again .PHONY: assemble-internal assemble-internal: assemble-ruby assemble-go .PHONY: assemble-go assemble-go: build rm -rf $(ASSEMBLY_ROOT)/bin mkdir -p $(ASSEMBLY_ROOT)/bin cd bin && install {{ join .Commands " " }} $(ASSEMBLY_ROOT)/bin .PHONY: assemble-ruby assemble-ruby: mkdir -p $(ASSEMBLY_ROOT) rm -rf {{ .GitalyRubyDir }}/tmp {{ .GitlabShellDir }}/tmp mkdir -p $(ASSEMBLY_ROOT)/ruby/ rsync -a --delete {{ .GitalyRubyDir }}/ $(ASSEMBLY_ROOT)/ruby/ rm -rf $(ASSEMBLY_ROOT)/ruby/spec $(ASSEMBLY_ROOT)/{{ .GitlabShellRelDir }}/spec $(ASSEMBLY_ROOT)/{{ .GitlabShellRelDir }}/gitlab-shell.log binaries: assemble @if [ $$(uname -m) != 'x86_64' ]; then echo Incorrect architecture for build: $(uname -m); exit 1; fi @cd $(ASSEMBLY_ROOT) && shasum -a 256 bin/* | tee checksums.sha256.txt {{ .TestRepo }}: git clone --bare --quiet https://gitlab.com/gitlab-org/gitlab-test.git $@ # Git notes aren't fetched by default with git clone git -C $@ fetch origin refs/notes/*:refs/notes/* rm -rf $@/refs mkdir -p $@/refs/heads $@/refs/tags cp {{ .SourceDir }}/_support/gitlab-test.git-packed-refs $@/packed-refs git -C $@ fsck --no-progress {{ .GitTestRepo }}: git clone --bare --quiet https://gitlab.com/gitlab-org/gitlab-git-test.git $@ rm -rf $@/refs mkdir -p $@/refs/heads $@/refs/tags cp {{ .SourceDir }}/_support/gitlab-git-test.git-packed-refs $@/packed-refs git -C $@ fsck --no-progress .PHONY: prepare-tests prepare-tests: {{ .GitlabShellDir }}/config.yml {{ .TestRepo }} {{ .GitTestRepo }} ../.ruby-bundle {{ .GitlabShellDir }}/config.yml: {{ .GitlabShellDir }}/config.yml.example cp $< $@ .PHONY: test test: test-go rspec rspec-gitlab-shell .PHONY: test-go test-go: prepare-tests {{ .GoJunitReport }} @cd {{ .SourceDir }} && go test -v -tags "$(BUILD_TAGS)" -count=1 {{ join .AllPackages " " }} 2>&1 | {{ .GoJunitReport }} > report-${CI_JOB_NAME}.xml .PHONY: test-with-proxies test-with-proxies: prepare-tests @cd {{ .SourceDir }} &&\ go test -tags "$(BUILD_TAGS)" -count=1 -exec {{ .SourceDir }}/_support/bad-proxies {{ .Pkg }}/internal/rubyserver/ .PHONY: test-with-praefect test-with-praefect: build prepare-tests @cd {{ .SourceDir }} &&\ GITALY_TEST_PRAEFECT_BIN={{ .BuildDir }}/bin/praefect go test -tags "$(BUILD_TAGS)" -count=1 {{ join .AllPackages " " }} # count=1 bypasses go 1.10 test caching .PHONY: race-go race-go: prepare-tests {{ .GoJunitReport }} @cd {{ .SourceDir }} && go test -v -tags "$(BUILD_TAGS)" -race {{ join .AllPackages " " }} 2>&1 | {{ .GoJunitReport }} > report-${CI_JOB_NAME}.xml .PHONY: rspec rspec: assemble-go prepare-tests cd {{ .GitalyRubyDir }} && bundle exec rspec .PHONY: rspec-gitlab-shell rspec-gitlab-shell: {{ .GitlabShellDir }}/config.yml assemble-go prepare-tests # rspec in {{ .GitlabShellRelDir }} @cd {{ .GitalyRubyDir }} && bundle exec bin/ruby-cd {{ .GitlabShellDir }} rspec .PHONY: test-postgres test-postgres: prepare-tests @cd {{ .SourceDir }} && go test -tags postgres -count=1 gitlab.com/gitlab-org/gitaly/internal/praefect/datastore/... .PHONY: verify verify: check-mod-tidy check-formatting notice-up-to-date check-proto rubocop .PHONY: check-mod-tidy check-mod-tidy: # check-mod-tidy @cd {{ .SourceDir }} && _support/check-mod-tidy .PHONY: lint lint: {{ .GoLint }} @cd {{ .SourceDir }} && \ {{ .GoLint }} run --out-format tab --config .golangci.yml; \ EXIT_CODE=$$?;\ exit $$EXIT_CODE .PHONY: check-formatting check-formatting: {{ .GitalyFmt }} # gitalyfmt @cd {{ .SourceDir }} && {{ .GitalyFmt }} {{ join .GoFiles " " }} | {{ .MakeFormatCheck }} {{ .GoImports }}: {{ .MakegenDep }} go get golang.org/x/tools/cmd/goimports@2538eef75904eff384a2551359968e40c207d9d2 {{ .GoJunitReport }}: {{ .MakegenDep }} go get github.com/jstemmer/go-junit-report@984a47ca6b0a7d704c4b589852051b4d7865aa17 .PHONY: {{ .GitalyFmt }} {{ .GitalyFmt }}: @cd {{ .SourceDir }} && go build -o $@ ./internal/cmd/gitalyfmt .PHONY: format format: {{ .GoImports }} {{ .GitalyFmt }} # goimports pass 1 @cd {{ .SourceDir }} && goimports -w -l {{ join .GoFiles " " }} # gitalyfmt @cd {{ .SourceDir }} && {{ .GitalyFmt }} -w {{ join .GoFiles " " }} # goimports pass 2 @cd {{ .SourceDir }} && goimports -w -l {{ join .GoFiles " " }} .PHONY: staticcheck-deprecations staticcheck-deprecations: {{ .GoLint }} # Only returns deprecated code usage @cd {{ .SourceDir }} && \ {{ .GoLint }} run --out-format tab --config _support/golangci.warnings.yml; \ EXIT_CODE=$$?;\ exit $$EXIT_CODE .PHONY: lint-warnings lint-warnings: staticcheck-deprecations # Runs verification analysis that is okay to fail (but not ignore completely) {{ .GoLicenses }}: {{ .MakegenDep }} go get github.com/google/go-licenses@0fa8c766a59182ce9fd94169ddb52abe568b7f4e .PHONY: notice-up-to-date notice-up-to-date: notice-tmp # notice-up-to-date @(cmp {{ .BuildDir }}/NOTICE {{ .SourceDir }}/NOTICE) || (echo >&2 "NOTICE requires update: 'make notice'" && false) .PHONY: notice notice: notice-tmp mv {{ .BuildDir }}/NOTICE {{ .SourceDir }}/NOTICE .PHONY: notice-tmp notice-tmp: {{ .GoLicenses }} clean-ruby-vendor-go rm -rf {{ .BuildDir}}/licenses cd {{ .SourceDir }} && {{ .BuildDir }}/{{ .GoLicenses }} save ./... --save_path={{ .BuildDir }}/licenses go run {{ .SourceDir }}/_support/noticegen/noticegen.go -source {{ .BuildDir }}/licenses -template {{ .SourceDir }}/_support/noticegen/notice.template > {{ .BuildDir }}/NOTICE .PHONY: clean-ruby-vendor-go clean-ruby-vendor-go: cd {{ .SourceDir }} && mkdir -p ruby/vendor && find ruby/vendor -type f -name '*.go' -delete .PHONY: check-proto check-proto: proto no-changes .PHONY: rubocop rubocop: ../.ruby-bundle cd {{ .GitalyRubyDir }} && bundle exec rubocop --parallel .PHONY: cover cover: prepare-tests @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 }}/all.merged" "{{ .CoverageDir }}/all.html" @cd {{ .SourceDir }} && go test -coverprofile "{{ .CoverageDir }}/all.merged" {{ join .AllPackages " " }} @cd {{ .SourceDir }} && go tool cover -html "{{ .CoverageDir }}/all.merged" -o "{{ .CoverageDir }}/all.html" @echo "" @echo "=====> Total test coverage: <=====" @echo "" @@cd {{ .SourceDir }} && go tool cover -func "{{ .CoverageDir }}/all.merged" .PHONY: docker docker: rm -rf docker/ mkdir -p docker/bin/ rm -rf {{ .GitalyRubyDir }}/tmp cp -r {{ .GitalyRubyDir }} docker/ruby rm -rf docker/ruby/vendor/bundle {{ $pkg := .Pkg }} {{ $goLdFlags := .GoLdFlags }} {{ range $cmd := .Commands }} GOOS=linux GOARCH=amd64 go build -tags "$(BUILD_TAGS)" {{ $goLdFlags }} -o "docker/bin/{{ $cmd }}" {{ $pkg }}/cmd/{{ $cmd }} {{ end }} cp {{ .SourceDir }}/Dockerfile docker/ docker build -t gitlab/gitaly:{{ .VersionPrefixed }} -t gitlab/gitaly:latest docker/ .PHONY: proto proto: {{ .ProtoCGenGitaly }} {{ .GrpcToolsRuby }} cd {{ .SourceDir }} && {{ .ProtoC }} --gitaly_out=proto_dir=./proto,gitalypb_dir=./proto/go/gitalypb:. --go_out=paths=source_relative,plugins=grpc:./proto/go/gitalypb -I./proto ./proto/*.proto cd {{ .SourceDir }} && _support/generate-proto-ruby # this part is related to the generation of sources from testing proto files cd {{ .SourceDir }} && {{ .ProtoC }} --plugin={{ .ProtoCGenGo }} --go_out=plugins=grpc:. internal/praefect/grpc-proxy/testdata/test.proto .PHONY: proto-lint proto-lint: {{ .ProtoC }} {{ .ProtoCGenGo }} mkdir -p {{ .SourceDir }}/proto/go/gitalypb rm -rf {{ .SourceDir }}/proto/go/gitalypb/*.pb.go cd {{ .SourceDir }} && {{ .ProtoC }} --go_out=paths=source_relative:./proto/go/gitalypb -I./proto ./proto/lint.proto {{ .ProtoC }}: {{ .BuildDir }}/protoc.zip rm -rf {{ .BuildDir }}/protoc mkdir -p {{ .BuildDir }}/protoc cd {{ .BuildDir }}/protoc && unzip {{ .BuildDir }}/protoc.zip touch $@ {{ .BuildDir }}/protoc.zip: {{ .MakegenDep }} curl -o $@.tmp --silent -L {{ .ProtoCURL }} printf '{{ .ProtoCSHA256 }} $@.tmp' | shasum -a256 -c - mv $@.tmp $@ {{ .ProtoCGenGo }}: {{ .MakegenDep }} go get github.com/golang/protobuf/protoc-gen-go@v1.3.2 .PHONY: {{ .ProtoCGenGitaly }} {{ .ProtoCGenGitaly }}: proto-lint cd {{ .SourceDir }}/proto/go/internal && go build -o $@ gitlab.com/gitlab-org/gitaly/proto/go/internal/cmd/protoc-gen-gitaly {{ .GrpcToolsRuby }}: {{ .MakegenDep }} gem install --bindir {{ .BuildDir }}/bin -v 1.0.1 grpc-tools {{ .GoLint }}: {{ .BuildDir }}/golangci-lint.tar.gz mkdir -p {{ .BuildDir }}/bin cd {{ .BuildDir }} && tar -x -z --strip-components 1 -C {{ .BuildDir }}/bin -f golangci-lint.tar.gz {{ .GolangCILint }}/golangci-lint {{ .BuildDir }}/golangci-lint.tar.gz: {{ .MakegenDep }} curl -o $@.tmp --silent -L {{ .GolangCILintURL }} printf '{{ .GolangCILintSHA256 }} $@.tmp' | shasum -a256 -c - mv $@.tmp $@ no-changes: # looking for changed files @cd {{ .SourceDir }} && git status --porcelain | awk '{ print } END { if (NR > 0) { exit 1 } }' smoke-test: all rspec @cd {{ .SourceDir }} && go test ./internal/rubyserver