Build target for "make tidy" (#2378)

The make tidy target runs "go mod tidy" in the root directory and all plugins.
This commit is contained in:
mmetc 2023-07-26 10:24:37 +02:00 committed by GitHub
parent 5e7c0e0f49
commit 1a6f12c88e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 33 additions and 23 deletions

View file

@ -31,8 +31,8 @@ BUILD_REQUIRE_GO_MINOR ?= 20
#--------------------------------------
GOCMD = go
GOTEST = $(GOCMD) test
GO = go
GOTEST = $(GO) test
BUILD_CODENAME ?= alphaga
@ -209,12 +209,21 @@ PLUGIN_VENDOR = $(foreach plugin,$(PLUGINS),$(shell if [ -f $(PLUGINS_DIR)/$(plu
vendor:
$(foreach plugin_dir,$(PLUGIN_VENDOR), \
cd $(plugin_dir) >/dev/null && \
$(GOCMD) mod vendor && \
$(GO) mod vendor && \
cd - >/dev/null; \
)
$(GOCMD) mod vendor
$(GO) mod vendor
tar -czf vendor.tgz vendor $(foreach plugin_dir,$(PLUGIN_VENDOR),$(plugin_dir)/vendor)
.PHONY: tidy
tidy:
$(GO) mod tidy
$(foreach plugin_dir,$(PLUGIN_VENDOR), \
cd $(plugin_dir) >/dev/null && \
$(GO) mod tidy && \
cd - >/dev/null; \
)
# remove vendor directories and vendor.tgz
.PHONY: vendor-remove
vendor-remove:
@ -223,6 +232,7 @@ vendor-remove:
)
$(RM) vendor vendor.tgz
.PHONY: package
package:
@echo "Building Release to dir $(RELDIR)"

View file

@ -5,9 +5,9 @@ ifeq ($(OS), Windows_NT)
endif
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOTEST = $(GOCMD) test
GO = go
GOBUILD = $(GO) build
GOTEST = $(GO) test
BINARY_NAME = cscli$(EXT)
PREFIX ?= "/"

View file

@ -5,9 +5,9 @@ ifeq ($(OS), Windows_NT)
endif
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOTEST = $(GOCMD) test
GO = go
GOBUILD = $(GO) build
GOTEST = $(GO) test
CROWDSEC_BIN = crowdsec$(EXT)
# names longer than 15 chars break 'pgrep'

View file

@ -25,7 +25,7 @@ def test_capi_whitelists(crowdsec, tmp_path_factory, flavor,):
with crowdsec(flavor=flavor, environment=env, volumes=volumes) as cs:
cs.wait_for_log("*Starting processing data*")
cs.wait_for_http(8080, '/health', want_status=HTTPStatus.OK)
res = cs.cont.exec_run(f'cscli config show-yaml')
res = cs.cont.exec_run('cscli config show-yaml')
assert res.exit_code == 0
stdout = res.output.decode()
y = yaml.safe_load(stdout)

View file

@ -7,8 +7,8 @@ endif
PLUGIN = dummy
BINARY_NAME = notification-$(PLUGIN)$(EXT)
GOCMD = go
GOBUILD = $(GOCMD) build
GO = go
GOBUILD = $(GO) build
build: clean
$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

View file

@ -7,8 +7,8 @@ endif
PLUGIN = email
BINARY_NAME = notification-$(PLUGIN)$(EXT)
GOCMD = go
GOBUILD = $(GOCMD) build
GO = go
GOBUILD = $(GO) build
build: clean
$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

View file

@ -7,8 +7,8 @@ endif
PLUGIN=http
BINARY_NAME = notification-$(PLUGIN)$(EXT)
GOCMD = go
GOBUILD = $(GOCMD) build
GO = go
GOBUILD = $(GO) build
build: clean
$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

View file

@ -5,8 +5,8 @@ ifeq ($(OS), Windows_NT)
endif
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GO = go
GOBUILD = $(GO) build
BINARY_NAME = notification-sentinel$(EXT)

View file

@ -7,8 +7,8 @@ endif
PLUGIN=slack
BINARY_NAME = notification-$(PLUGIN)$(EXT)
GOCMD = go
GOBUILD = $(GOCMD) build
GO = go
GOBUILD = $(GO) build
build: clean
$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)

View file

@ -7,8 +7,8 @@ endif
PLUGIN=splunk
BINARY_NAME = notification-$(PLUGIN)$(EXT)
GOCMD = go
GOBUILD = $(GOCMD) build
GO = go
GOBUILD = $(GO) build
build: clean
$(GOBUILD) $(LD_OPTS) $(BUILD_VENDOR_FLAGS) -o $(BINARY_NAME)