diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-11-01 14:10:05 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-11-03 13:53:00 +0300 |
commit | 75ed635121d372df108fe5543b2081e5c6b60f4d (patch) | |
tree | cd26edf7eedea2f03fbb99a1ca2fbc3c1945fd3a | |
parent | ea8cb42485b404c8d46bf51b2764e058bff7982b (diff) |
Makefile: Allow moving the `.ruby-bundle` file
The `.ruby-bundle` file is used to control when we need to run `bundle
install`: when older than either `Gemfile` or `Gemfile.lock` then we
know we need to re-run the command. This mechanism is also used by CNG
and Omnibus to control execution of this command. They both touch(1) the
file so that it is newer than its dependencies as a workaround so that
`make build` won't re-install any Ruby Gems that have already been
installed anyway.
This is definitely an awful workaround and should ideally be changed so
that we instead provide a variable that lets callers disable installing
Ruby Gems instead of having to reach into some internal details of our
build system. But fixing this now would be quite pointless as we are in
the process of retiring the Ruby sidecar.
The current way this works is about to cause problems though: we need to
adapt the way our unprivileged CI testing works to both build and run
tests as the unprivileged user, who cannot modify the source directory
at all. But as the `.ruby-bundle` file is located directly in the source
directory this refactor would break installing the Ruby Gem.
Let's work around this issue by making the location of `.ruby-bundle`
configurable via a Makefile variable. While ugly, we'll get rid of this
in a few releases anyway.
-rw-r--r-- | Makefile | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -29,6 +29,13 @@ BUILD_DIR := ${SOURCE_DIR}/_build DEPENDENCY_DIR := ${BUILD_DIR}/deps TOOLS_DIR := ${BUILD_DIR}/tools GITALY_RUBY_DIR := ${SOURCE_DIR}/ruby +# This file is used as a dependency for running `bundle install`: when its +# mtime is older than that of either `Gemfile` or `Gemfile.lock` we will +# execute the command. There is not typically any need to change the location, +# but we need this for our unprivileged CI so that it can be moved into the +# `_build` directory. Just moving the file completely doesn't work, as both CNG +# and Omnibus depend on it to inhibit re-bundling Ruby Gems. +RUBY_BUNDLE_FILE ?= ${SOURCE_DIR}/.ruby-bundle # These variables may be overridden at runtime by top-level make ## The prefix where Gitaly binaries will be installed to. Binaries will end up @@ -312,7 +319,7 @@ help: .PHONY: build ## Build Go binaries and install required Ruby Gems. -build: ${SOURCE_DIR}/.ruby-bundle ${GITALY_INSTALLED_EXECUTABLES} +build: ${RUBY_BUNDLE_FILE} ${GITALY_INSTALLED_EXECUTABLES} .PHONY: install ## Install Gitaly binaries. The target directory can be modified by setting PREFIX and DESTDIR. @@ -347,7 +354,7 @@ export GITALY_TESTING_GIT_BINARY ?= ${DEPENDENCY_DIR}/git-distribution/bin-wrapp endif .PHONY: prepare-tests -prepare-tests: libgit2 prepare-test-repos ${SOURCE_DIR}/.ruby-bundle ${GOTESTSUM} +prepare-tests: libgit2 prepare-test-repos ${RUBY_BUNDLE_FILE} ${GOTESTSUM} ifndef UNPRIVILEGED_CI_SKIP prepare-tests: ${GITALY_PACKED_EXECUTABLES} endif @@ -465,7 +472,7 @@ clean-ruby-vendor-go: .PHONY: rubocop ## Run Rubocop. -rubocop: ${SOURCE_DIR}/.ruby-bundle +rubocop: ${RUBY_BUNDLE_FILE} ${Q}cd ${GITALY_RUBY_DIR} && bundle exec rubocop --parallel --config ${GITALY_RUBY_DIR}/.rubocop.yml ${GITALY_RUBY_DIR} ${SOURCE_DIR}/_support/test-boot .PHONY: cover @@ -554,7 +561,7 @@ libgit2: ${LIBGIT2_INSTALL_DIR}/lib/libgit2.a # 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. -${SOURCE_DIR}/.ruby-bundle: ${GITALY_RUBY_DIR}/Gemfile.lock ${GITALY_RUBY_DIR}/Gemfile +${RUBY_BUNDLE_FILE}: ${GITALY_RUBY_DIR}/Gemfile.lock ${GITALY_RUBY_DIR}/Gemfile ${Q}cd ${GITALY_RUBY_DIR} && bundle install ${Q}touch $@ |