From ef39d24fd06a86b1bb5cd3ddf101d938a8e13763 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 21 Dec 2018 17:49:01 +0100 Subject: Add vendoring script --- _support/vendor-gitlab-shell | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 _support/vendor-gitlab-shell (limited to '_support') diff --git a/_support/vendor-gitlab-shell b/_support/vendor-gitlab-shell new file mode 100755 index 000000000..c5fdbc99f --- /dev/null +++ b/_support/vendor-gitlab-shell @@ -0,0 +1,41 @@ +#!/usr/bin/env ruby + +require 'tempfile' + +require_relative 'run' + +REMOTE = 'https://gitlab.com/gitlab-org/gitlab-shell.git' +REMOVE_PATHS = %w[go support spec/action .git spec/gitlab_shell_gitlab_shell_spec.rb].freeze + +def main + Dir.mktmpdir do |dir| + run!(%W[git clone --depth=1 --quiet #{REMOTE} gitlab-shell], dir) + tmp_shell_dir = File.join(dir, 'gitlab-shell') + + run!(%w[mv README.md README.orig.md], tmp_shell_dir) + + revision = capture!(%w[git rev-parse HEAD], tmp_shell_dir).chomp + remote_project = REMOTE.sub(/\.git$/, '') + + readme = <<-EOS +# gitlab-shell + +Vendored from #{remote_project} at [#{revision}](#{remote_project}/commit/#{revision}). + +Original README: [README.orig.md](README.orig.md). +EOS + File.write(File.join(tmp_shell_dir, 'README.md'), readme) + + run!(%w[rm -rf --] + REMOVE_PATHS, tmp_shell_dir) + + gitlab_init = File.join(tmp_shell_dir, 'lib/gitlab_init.rb') + gitlab_init_contents = File.read(gitlab_init) + File.write(gitlab_init, gitlab_init_contents.sub(/^GITALY_EMBEDDED =.*/, 'GITALY_EMBEDDED = true')) + + shell_vendor_dir = 'ruby/vendor/gitlab-shell' + run!(%W[mkdir -p #{shell_vendor_dir}]) + run!(%W[rsync -av --delete #{tmp_shell_dir}/ #{shell_vendor_dir}/]) + end +end + +main -- cgit v1.2.3 From 65f276088e155876c5cf067849f633884a2fce63 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 20 Dec 2018 14:59:55 +0100 Subject: Fix 'make assemble' for gitlab-shell --- _support/makegen.go | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to '_support') diff --git a/_support/makegen.go b/_support/makegen.go index 202357cc7..2a6a83380 100644 --- a/_support/makegen.go +++ b/_support/makegen.go @@ -69,13 +69,18 @@ func (gm *gitalyMake) BuildDir() string { return gm.cwd } -func (gm *gitalyMake) Pkg() string { return "gitlab.com/gitlab-org/gitaly" } -func (gm *gitalyMake) GoImports() string { return "bin/goimports" } -func (gm *gitalyMake) GoCovMerge() string { return "bin/gocovmerge" } -func (gm *gitalyMake) GoLint() string { return "bin/golint" } -func (gm *gitalyMake) GoVendor() string { return "bin/govendor" } -func (gm *gitalyMake) MegaCheck() string { return "bin/megacheck" } -func (gm *gitalyMake) CoverageDir() string { return filepath.Join(gm.BuildDir(), "cover") } +func (gm *gitalyMake) Pkg() string { return "gitlab.com/gitlab-org/gitaly" } +func (gm *gitalyMake) GoImports() string { return "bin/goimports" } +func (gm *gitalyMake) GoCovMerge() string { return "bin/gocovmerge" } +func (gm *gitalyMake) GoLint() string { return "bin/golint" } +func (gm *gitalyMake) GoVendor() string { return "bin/govendor" } +func (gm *gitalyMake) MegaCheck() string { return "bin/megacheck" } +func (gm *gitalyMake) CoverageDir() string { return filepath.Join(gm.BuildDir(), "cover") } +func (gm *gitalyMake) GitalyRubyDir() string { return filepath.Join(gm.SourceDir(), "ruby") } +func (gm *gitalyMake) GitlabShellRelDir() string { return "ruby/vendor/gitlab-shell" } +func (gm *gitalyMake) GitlabShellDir() string { + return filepath.Join(gm.SourceDir(), gm.GitlabShellRelDir()) +} // 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()) } @@ -243,10 +248,10 @@ build: ../.ruby-bundle # 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: {{ .SourceDir }}/ruby/Gemfile.lock {{ .SourceDir }}/ruby/Gemfile - cd {{ .SourceDir }}/ruby && bundle config # for debugging - cd {{ .SourceDir }}/ruby && bundle install $(BUNDLE_FLAGS) - cd {{ .SourceDir }}/ruby && bundle show gitaly-proto # sanity check +../.ruby-bundle: {{ .GitalyRubyDir }}/Gemfile.lock {{ .GitalyRubyDir }}/Gemfile + cd {{ .GitalyRubyDir }} && bundle config # for debugging + cd {{ .GitalyRubyDir }} && bundle install $(BUNDLE_FLAGS) + cd {{ .GitalyRubyDir }} && bundle show gitaly-proto # sanity check touch $@ .PHONY: install @@ -277,9 +282,9 @@ assemble-go: build assemble-ruby: rm -rf $(ASSEMBLY_ROOT)/ruby mkdir -p $(ASSEMBLY_ROOT) - rm -rf {{ .SourceDir }}/ruby/tmp - cp -r {{ .SourceDir }}/ruby $(ASSEMBLY_ROOT)/ruby - rm -rf $(ASSEMBLY_ROOT)/ruby/spec + rm -rf {{ .GitalyRubyDir }}/tmp {{ .GitlabShellDir }}/tmp + cp -r {{ .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 @@ -317,7 +322,7 @@ race-go: prepare-tests .PHONY: rspec rspec: assemble-go prepare-tests - cd {{ .SourceDir }}/ruby && bundle exec rspec + cd {{ .GitalyRubyDir }} && bundle exec rspec .PHONY: verify verify: lint check-formatting megacheck govendor-status notice-up-to-date govendor-tagged rubocop @@ -381,7 +386,7 @@ govendor-tagged: {{ .GoVendor }} .PHONY: rubocop rubocop: ../.ruby-bundle - cd {{ .SourceDir }}/ruby && bundle exec rubocop --parallel + cd {{ .GitalyRubyDir }} && bundle exec rubocop --parallel .PHONY: cover cover: prepare-tests {{ .GoCovMerge }} @@ -403,8 +408,8 @@ cover: prepare-tests {{ .GoCovMerge }} docker: rm -rf docker/ mkdir -p docker/bin/ - rm -rf {{ .SourceDir }}/ruby/tmp - cp -r {{ .SourceDir }}/ruby docker/ruby + rm -rf {{ .GitalyRubyDir }}/tmp + cp -r {{ .GitalyRubyDir }} docker/ruby rm -rf docker/ruby/vendor/bundle {{ $pkg := .Pkg }} {{ $goLdFlags := .GoLdFlags }} -- cgit v1.2.3