diff options
author | Will Chandler <wchandler@gitlab.com> | 2024-01-11 19:27:59 +0300 |
---|---|---|
committer | Will Chandler <wchandler@gitlab.com> | 2024-01-19 18:56:51 +0300 |
commit | 59af1f680333ab8240cfe0f51b0ac408818b2e95 (patch) | |
tree | 9f4de58e74f0882c48c47a64690d5b6ab6e0c7eb | |
parent | c15c9d250a7e80fe868fe037bfd58e1f7b5f7584 (diff) |
Makefile: Add git-filter-repo for testing
We will shortly begin using git-filter-repo(1) to rewrite repository
history. This is a Python script that requires Python 3.5+, but it has
no external dependencies and can be downloaded as a single file.
We have added Python3 and installed git-filter-repo in Omnibus and CNG
GitLab, but still need it to be present for local testing and CI.
Add a target to clone filter-repo as a dependency and copy the script
into ${BUILD_DIR}/bin which is added to PATH for our tests.
We add a '.version' file for filter-repo to be consistent with the other
dependencies, but this isn't really required as we're not running a
build process in its source directory.
-rw-r--r-- | Makefile | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -173,6 +173,12 @@ ifdef GIT_FIPS_BUILD_OPTIONS GIT_BUILD_OPTIONS += ${GIT_FIPS_BUILD_OPTIONS} endif +# git-filter-repo target +GIT_FILTER_REPO ?= ${BUILD_DIR}/bin/git-filter-repo +GIT_FILTER_REPO_VERSION ?= v2.38.0 +GIT_FILTER_REPO_REPO_URL ?= https://github.com/newren/git-filter-repo +GIT_FILTER_REPO_SOURCE_DIR ?= ${DEPENDENCY_DIR}/git-filter-repo + # These variables control test options and artifacts ## List of Go packages which shall be tested. ## Go packages to test when using the test-go target. @@ -333,7 +339,7 @@ run_go_tests += \ endif .PHONY: prepare-tests -prepare-tests: ${GOTESTSUM} ${GITALY_PACKED_EXECUTABLES} +prepare-tests: ${GOTESTSUM} ${GITALY_PACKED_EXECUTABLES} ${GIT_FILTER_REPO} ${Q}mkdir -p "$(dir ${TEST_JUNIT_REPORT})" .PHONY: prepare-debug @@ -588,7 +594,8 @@ ${DEPENDENCY_DIR}/git-%.version: dependency-version | ${DEPENDENCY_DIR} ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${GIT_VERSION} ${GIT_BUILD_OPTIONS}" ] || >$@ echo -n "${GIT_VERSION} ${GIT_BUILD_OPTIONS}" ${DEPENDENCY_DIR}/protoc.version: dependency-version | ${DEPENDENCY_DIR} ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${PROTOC_VERSION} ${PROTOC_BUILD_OPTIONS}" ] || >$@ echo -n "${PROTOC_VERSION} ${PROTOC_BUILD_OPTIONS}" - +${DEPENDENCY_DIR}/git-filter-repo.version: dependency-version | ${DEPENDENCY_DIR} + ${Q}[ x"$$(cat "$@" 2>/dev/null)" = x"${GIT_FILTER_REPO_VERSION}" ] || >$@ echo -n "${GIT_FILTER_REPO_VERSION}" # This target is responsible for checking out Git sources. In theory, we'd only # need to depend on the source directory. But given that the source directory # always changes when anything inside of it changes, like when we for example @@ -638,6 +645,15 @@ ${PROTOC_GEN_GITALY_LINT}: proto | ${TOOLS_DIR} ${PROTOC_GEN_GITALY_PROTOLIST}: | ${TOOLS_DIR} ${Q}go build -o $@ ${SOURCE_DIR}/tools/protoc-gen-gitaly-protolist +${GIT_FILTER_REPO}: ${DEPENDENCY_DIR}/git-filter-repo.version | ${BUILD_DIR}/bin + ${Q}${GIT} -c init.defaultBranch=master init ${GIT_QUIET} "${GIT_FILTER_REPO_SOURCE_DIR}" + ${Q}${GIT} -C "${GIT_FILTER_REPO_SOURCE_DIR}" config remote.origin.url ${GIT_FILTER_REPO_REPO_URL} + ${Q}${GIT} -C "${GIT_FILTER_REPO_SOURCE_DIR}" config remote.origin.tagOpt --no-tags + ${Q}${GIT} -C "${GIT_FILTER_REPO_SOURCE_DIR}" fetch --depth 1 ${GIT_QUIET} origin ${GIT_FILTER_REPO_VERSION} + ${Q}${GIT} -C "${GIT_FILTER_REPO_SOURCE_DIR}" reset --hard + ${Q}${GIT} -C "${GIT_FILTER_REPO_SOURCE_DIR}" checkout ${GIT_QUIET} --detach FETCH_HEAD + ${Q}cp "${GIT_FILTER_REPO_SOURCE_DIR}/git-filter-repo" ${GIT_FILTER_REPO} + # External tools ${TOOLS_DIR}/%: ${SOURCE_DIR}/tools/%/tool.go ${SOURCE_DIR}/tools/%/go.mod ${SOURCE_DIR}/tools/%/go.sum | ${TOOLS_DIR} ${Q}GOBIN=${TOOLS_DIR} go install -modfile ${SOURCE_DIR}/tools/$*/go.mod ${TOOL_PACKAGE} |