Skip to content

Commit

Permalink
Improve speed of Golang-related Makefile targets when running on macOS (
Browse files Browse the repository at this point in the history
#3527)

* Improve speed of all Golang-related Makefile targets when running on macOS.

* Clean up remaining references to .cache and .pkg directories.

I've left references to both directories in DONT_FIND and
clean-white-noise so that the existing behaviour is maintained for
anyone who has the directories present in their working copy already.
  • Loading branch information
charleskorn authored Nov 29, 2022
1 parent 2ad7eb4 commit 82ff070
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,14 @@ GO_FLAGS := -ldflags "\

ifeq ($(BUILD_IN_CONTAINER),true)

GOVOLUMES= -v $(shell pwd)/.cache:/go/cache:$(CONTAINER_MOUNT_OPTIONS) \
-v $(shell pwd)/.pkg:/go/pkg:$(CONTAINER_MOUNT_OPTIONS) \
GOVOLUMES= -v mimir-go-cache:/go/cache \
-v mimir-go-pkg:/go/pkg \
-v $(shell pwd):/go/src/github.com/grafana/mimir:$(CONTAINER_MOUNT_OPTIONS)

# Mount local ssh credentials to be able to clone private repos when doing `mod-check`
SSHVOLUME= -v ~/.ssh/:/root/.ssh:$(CONTAINER_MOUNT_OPTIONS)

exes $(EXES) protos $(PROTO_GOS) lint lint-packaging-scripts test test-with-race cover shell mod-check check-protos doc format dist build-mixin format-mixin check-mixin-tests license check-license conftest-fmt check-conftest-fmt conftest-test conftest-verify check-helm-tests build-helm-tests: fetch-build-image
@mkdir -p $(shell pwd)/.pkg
@mkdir -p $(shell pwd)/.cache
@echo
@echo ">>>> Entering build container: $@"
$(SUDO) time docker run --rm $(TTY) -i $(SSHVOLUME) $(GOVOLUMES) $(BUILD_IMAGE) GOOS=$(GOOS) GOARCH=$(GOARCH) BINARY_SUFFIX=$(BINARY_SUFFIX) $@;

Expand Down Expand Up @@ -463,7 +460,8 @@ format-makefiles: $(MAKE_FILES)

clean: ## Cleanup the docker images, object files and executables.
$(SUDO) docker rmi $(IMAGE_NAMES) >/dev/null 2>&1 || true
rm -rf -- $(UPTODATE_FILES) $(EXES) .cache dist
$(SUDO) docker volume rm -f mimir-go-pkg mimir-go-cache
rm -rf -- $(UPTODATE_FILES) $(EXES) dist
# Remove executables built for multiarch images.
find . -type f -name '*_linux_arm64' -perm +u+x -exec rm {} \;
find . -type f -name '*_linux_amd64' -perm +u+x -exec rm {} \;
Expand Down Expand Up @@ -497,7 +495,7 @@ reference-help: cmd/mimir/mimir
@(go run ./tools/config-inspector || true) > cmd/mimir/config-descriptor.json

clean-white-noise: ## Clean the white noise in the markdown files.
@find . -path ./.pkg -prune -o -path "*/vendor/*" -prune -or -type f -name "*.md" -print | \
@find . -path ./.pkg -prune -o -path ./.cache -prune -o -path "*/vendor/*" -prune -or -type f -name "*.md" -print | \
SED_BIN="$(SED)" xargs ./tools/cleanup-white-noise.sh

check-white-noise: ## Check the white noise in the markdown files.
Expand Down Expand Up @@ -592,8 +590,6 @@ ifeq ($(PACKAGE_IN_CONTAINER), true)

.PHONY: packages
packages: dist packaging/fpm/$(UPTODATE)
@mkdir -p $(shell pwd)/.pkg
@mkdir -p $(shell pwd)/.cache
@echo ">>>> Entering build container: $@"
$(SUDO) time docker run --rm $(TTY) \
-v $(shell pwd):/go/src/github.com/grafana/mimir:$(CONTAINER_MOUNT_OPTIONS) \
Expand Down

0 comments on commit 82ff070

Please sign in to comment.