From e57cbc36d944b6c4ebe99f397eb55976d786d5f8 Mon Sep 17 00:00:00 2001
From: Simon Zolin <s.zolin@adguard.com>
Date: Mon, 3 Aug 2020 19:13:51 +0300
Subject: [PATCH] * Makefile: support running with multiple parallel jobs (e.g.
 -j8)

---
 Makefile | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 5c546857..c3e8080b 100644
--- a/Makefile
+++ b/Makefile
@@ -98,7 +98,8 @@ all: build
 init:
 	git config core.hooksPath .githooks
 
-build: dependencies client
+build: client_with_deps
+	go mod download
 	PATH=$(GOPATH)/bin:$(PATH) go generate ./...
 	CGO_ENABLED=0 go build -ldflags="-s -w -X main.version=$(VERSION) -X main.channel=$(CHANNEL) -X main.goarm=$(GOARM)"
 	PATH=$(GOPATH)/bin:$(PATH) packr clean
@@ -106,6 +107,10 @@ build: dependencies client
 client:
 	npm --prefix client run build-prod
 
+client_with_deps:
+	npm --prefix client ci
+	npm --prefix client run build-prod
+
 client-watch:
 	npm --prefix client run watch
 
@@ -139,7 +144,9 @@ test:
 	@echo Running Go unit-tests
 	go test -race -v -bench=. -coverprofile=coverage.txt -covermode=atomic ./...
 
-ci: dependencies client test
+ci: client_with_deps
+	go mod download
+	$(MAKE) test
 
 dependencies:
 	npm --prefix client ci
@@ -176,7 +183,8 @@ docker-multi-arch:
 	@echo If the image was pushed to the registry, you can now run it:
 	@echo docker run --name "adguard-home" -p 53:53/tcp -p 53:53/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp $(DOCKER_IMAGE_NAME)
 
-release: dependencies client
+release: client_with_deps
+	go mod download
 	@echo Starting release build: version $(VERSION), channel $(CHANNEL)
 	CHANNEL=$(CHANNEL) $(GORELEASER_COMMAND)
 	$(call repack_dist)