diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-01-06 14:41:38 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-01-06 14:41:38 +0300 |
commit | a9584ef657ddb546cb7bcc64361a0fbdb1672c83 (patch) | |
tree | 59f4e29dde286b39dc756ad57dbb49c910b4706c | |
parent | 58a976f3ecd108b5841a246e4b86712ca1b86dc5 (diff) | |
parent | 0d4fb3276ba5c7520529ae32837febe010353e30 (diff) |
Merge branch 'allow-gem-building' into 'master'
Makefile: Allow building the Gitaly gem without a tag
See merge request https://gitlab.com/gitlab-org/gitaly/-/merge_requests/5234
Merged-by: Patrick Steinhardt <psteinhardt@gitlab.com>
Approved-by: Quang-Minh Nguyen <qmnguyen@gitlab.com>
Approved-by: Patrick Steinhardt <psteinhardt@gitlab.com>
Reviewed-by: Patrick Steinhardt <psteinhardt@gitlab.com>
Reviewed-by: Quang-Minh Nguyen <qmnguyen@gitlab.com>
Reviewed-by: karthik nayak <knayak@gitlab.com>
Co-authored-by: Karthik Nayak <knayak@gitlab.com>
-rw-r--r-- | Makefile | 4 | ||||
-rwxr-xr-x | tools/protogem/build-proto-gem | 45 |
2 files changed, 37 insertions, 12 deletions
@@ -232,6 +232,8 @@ TEST_LOG_DIR ?= TEST_REPO_DIR := ${BUILD_DIR}/testrepos TEST_REPO := ${TEST_REPO_DIR}/gitlab-test.git BENCHMARK_REPO := ${TEST_REPO_DIR}/benchmark.git +## Options to pass to the script which builds the Gitaly gem +BUILD_GEM_OPTIONS ?= # All executables provided by Gitaly. GITALY_EXECUTABLES = $(addprefix ${BUILD_DIR}/bin/,$(notdir $(shell find ${SOURCE_DIR}/cmd -mindepth 1 -maxdepth 1 -type d -print))) @@ -492,7 +494,7 @@ lint-proto: ${PROTOC} ${PROTOLINT} ${PROTOC_GEN_GITALY_LINT} .PHONY: build-proto-gem ## Build the Ruby Gem that contains Gitaly's Protobuf definitons. build-proto-gem: - ${Q}"${SOURCE_DIR}"/tools/protogem/build-proto-gem "${BUILD_DIR}/gitaly.gem" + ${Q}"${SOURCE_DIR}"/tools/protogem/build-proto-gem -o "${BUILD_DIR}/gitaly.gem" ${BUILD_GEM_OPTIONS} .PHONY: publish-proto-gem ## Build and publish the Ruby Gem that contains Gitaly's Protobuf definitons. diff --git a/tools/protogem/build-proto-gem b/tools/protogem/build-proto-gem index ee5fc94df..9825719a7 100755 --- a/tools/protogem/build-proto-gem +++ b/tools/protogem/build-proto-gem @@ -3,21 +3,49 @@ require 'erb' require 'fileutils' require 'tmpdir' +require 'optparse' File.umask(0022) SOURCE_DIR = File.absolute_path(File.join(__dir__, '..', '..')) RUBY_VERSION_FILE = File.join('gitaly', 'version.rb') -def main(output_path) +def parse_options + options = {} + + option_parser = OptionParser.new do |opts| + opts.banner = "Usage: build-proto-gem [options]" + + opts.on_tail("--skip-verify-tag", "Skip verification that this is run for a tagged Gitaly commit") do + options[:skip_verify_tag] = true + end + + opts.on("-o", "--output PATH", "output path for the gem") do |path| + options[:output_path] = File.absolute_path(path) + end + end + + option_parser.parse! + + if options[:output_path].nil? + puts option_parser.help + exit 1 + end + + return options +end + +def main(options) version = File.read(File.join(SOURCE_DIR, 'VERSION')).strip unless version.match?(/\d+\.\d+\.\d+(-rc\d+)?/) abort "Version string #{version.inspect} does not look like a Gitaly Release tag (e.g. \"v1.0.2\"). Aborting." end - ref = capture!(%w[git describe --tag]).chomp - if ref != "v#{version}" - abort "Checkout tag v#{version} to publish.\n\t git checkout v#{version}" + if !options[:skip_verify_tag] + ref = capture!(%w[git describe --tag]).chomp + if ref != "v#{version}" + abort "Checkout tag v#{version} to publish.\n\t git checkout v#{version}" + end end puts 'Testing for changed files' @@ -28,7 +56,7 @@ def main(output_path) Dir.mktmpdir do |output_dir| generate_sources(output_dir, version) - build_gem(output_dir, output_path) + build_gem(output_dir, options[:output_path]) end end @@ -140,9 +168,4 @@ module GitalySupport end end -unless ARGV.count == 1 - warn "Usage: #{$0} OUTPUT_PATH" - abort -end - -main(File.absolute_path(ARGV[0])) +main(parse_options) |