Skip to content

Commit ea5466a

Browse files
authored
Merge pull request #10412 from Roasbeef/faster-linter
make: use Docker named volumes for ~21x faster local linting (Mac OS)
2 parents cb3991e + a21d436 commit ea5466a

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

Makefile

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,28 @@ ifneq ($(workers),)
6868
LINT_WORKERS = --concurrency=$(workers)
6969
endif
7070

71+
# Docker cache mounting strategy:
72+
# - CI (GitHub Actions): Use bind mounts to host paths that GA caches persist.
73+
# - Local: Use Docker named volumes (much faster on macOS/Windows due to
74+
# avoiding slow host-syncing overhead).
75+
# Paths inside container must match GOCACHE/GOMODCACHE in tools/Dockerfile.
76+
ifdef CI
77+
# CI mode: bind mount to host paths that GitHub Actions caches.
7178
DOCKER_TOOLS = docker run \
7279
--rm \
73-
-v $(shell bash -c "$(GOCC) env GOCACHE || (mkdir -p /tmp/go-cache; echo /tmp/go-cache)"):/tmp/build/.cache \
74-
-v $(shell bash -c "$(GOCC) env GOMODCACHE || (mkdir -p /tmp/go-modcache; echo /tmp/go-modcache)"):/tmp/build/.modcache \
75-
-v $(shell bash -c "mkdir -p /tmp/go-lint-cache; echo /tmp/go-lint-cache"):/root/.cache/golangci-lint \
80+
-v $${HOME}/.cache/go-build:/tmp/build/.cache \
81+
-v $${HOME}/go/pkg/mod:/tmp/build/.modcache \
82+
-v $${HOME}/.cache/golangci-lint:/root/.cache/golangci-lint \
7683
-v $$(pwd):/build lnd-tools
84+
else
85+
# Local mode: Docker named volumes for fast macOS/Windows performance.
86+
DOCKER_TOOLS = docker run \
87+
--rm \
88+
-v lnd-go-build-cache:/tmp/build/.cache \
89+
-v lnd-go-mod-cache:/tmp/build/.modcache \
90+
-v lnd-go-lint-cache:/root/.cache/golangci-lint \
91+
-v $$(pwd):/build lnd-tools
92+
endif
7793

7894
GREEN := "\\033[0;32m"
7995
NC := "\\033[0m"
@@ -472,6 +488,11 @@ clean-mobile:
472488
$(RM) -r mobile/build
473489
$(RM) mobile/*_generated.go
474490

491+
#? clean-docker-volumes: Remove Docker cache volumes used for local development
492+
clean-docker-volumes:
493+
@$(call print, "Removing Docker cache volumes.")
494+
docker volume rm lnd-go-build-cache lnd-go-mod-cache lnd-go-lint-cache 2>/dev/null || true
495+
475496
.PHONY: all \
476497
btcd \
477498
default \
@@ -500,4 +521,5 @@ clean-mobile:
500521
ios \
501522
android \
502523
mobile \
503-
clean
524+
clean \
525+
clean-docker-volumes

0 commit comments

Comments
 (0)