From 96703bb31e4c27ca096cdb514f368572bd9caa87 Mon Sep 17 00:00:00 2001 From: Dan McArdle Date: Wed, 17 Apr 2024 09:05:55 -0400 Subject: [PATCH] build: Inject rclone version tag when testing This enables gitannex end-to-end tests to run on CI. Otherwise, the version would not match and tests that check the rclone version would fail like so: ``` === RUN TestEndToEnd e2e_test.go:199: Skipping due to rclone version: expected version "v1.67.0-DEV", but got "v1.67.0-beta.7905.220bbe24d.merge" --- SKIP: TestEndToEnd (0.07s) ``` Issue #7625 --- Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 2e5aceba2..027d29611 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,7 @@ ifdef GOTAGS BUILDTAGS=-tags "$(GOTAGS)" LINTTAGS=--build-tags "$(GOTAGS)" endif +LDFLAGS=--ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" .PHONY: rclone test_all vars version @@ -50,7 +51,7 @@ rclone: ifeq ($(GO_OS),windows) go run bin/resource_windows.go -version $(TAG) -syso resource_windows_`go env GOARCH`.syso endif - go build -v --ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" $(BUILDTAGS) $(BUILD_ARGS) + go build -v $(LDFLAGS) $(BUILDTAGS) $(BUILD_ARGS) ifeq ($(GO_OS),windows) rm resource_windows_`go env GOARCH`.syso endif @@ -59,7 +60,7 @@ endif mv -v `go env GOPATH`/bin/rclone`go env GOEXE`.new `go env GOPATH`/bin/rclone`go env GOEXE` test_all: - go install --ldflags "-s -X github.com/rclone/rclone/fs.Version=$(TAG)" $(BUILDTAGS) $(BUILD_ARGS) github.com/rclone/rclone/fstest/test_all + go install $(LDFLAGS) $(BUILDTAGS) $(BUILD_ARGS) github.com/rclone/rclone/fstest/test_all vars: @echo SHELL="'$(SHELL)'" @@ -87,13 +88,13 @@ test: rclone test_all # Quick test quicktest: - RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) ./... + RCLONE_CONFIG="/notfound" go test $(LDFLAGS) $(BUILDTAGS) ./... racequicktest: - RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -cpu=2 -race ./... + RCLONE_CONFIG="/notfound" go test $(LDFLAGS) $(BUILDTAGS) -cpu=2 -race ./... compiletest: - RCLONE_CONFIG="/notfound" go test $(BUILDTAGS) -run XXX ./... + RCLONE_CONFIG="/notfound" go test $(LDFLAGS) $(BUILDTAGS) -run XXX ./... # Do source code quality checks check: rclone