adguardhome-sync/Makefile

114 lines
3.7 KiB
Makefile
Raw Normal View History

2022-08-12 15:31:24 +08:00
# Run go lint against code
2022-12-29 00:45:08 +08:00
lint: golangci-lint
$(GOLANGCI_LINT) run --fix
2021-03-28 06:40:59 +08:00
# Run go mod tidy
tidy:
go mod tidy
generate: deepcopy-gen
@mkdir -p ./tmp
@touch ./tmp/deepcopy-gen-boilerplate.go.txt
2022-12-29 00:45:08 +08:00
$(DEEPCOPY_GEN) -h ./tmp/deepcopy-gen-boilerplate.go.txt -i ./pkg/types
2021-03-28 06:40:59 +08:00
# Run tests
2022-08-12 15:31:24 +08:00
test: generate lint test-ci
2021-11-30 05:25:01 +08:00
# Run ci tests
2022-03-31 03:54:53 +08:00
test-ci: mocks tidy
2021-03-28 06:40:59 +08:00
go test ./... -coverprofile=coverage.out
go tool cover -func=coverage.out
2021-03-28 22:42:12 +08:00
2021-04-11 17:56:55 +08:00
mocks: mockgen
2022-12-29 00:45:08 +08:00
$(MOCKGEN) -package client -destination pkg/mocks/client/mock.go github.com/bakito/adguardhome-sync/pkg/client Client
2021-04-11 17:56:55 +08:00
2022-12-29 00:45:08 +08:00
release: semver goreleaser
@version=$$($(LOCALBIN)/semver);
2021-03-28 22:42:12 +08:00
git tag -s $$version -m"Release $$version"
2022-12-29 00:45:08 +08:00
$(GORELEASER) --rm-dist
2021-03-28 22:42:12 +08:00
2022-12-29 00:45:08 +08:00
test-release: goreleaser
$(GORELEASER) --skip-publish --snapshot --rm-dist
2021-03-29 01:31:11 +08:00
2022-12-29 00:45:08 +08:00
## toolbox - start
## Location to install dependencies to
LOCALBIN ?= $(shell test -s "cygpath -m $$(pwd)" || pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
2021-04-11 17:56:55 +08:00
2022-12-29 00:45:08 +08:00
## Tool Binaries
SEMVER ?= $(LOCALBIN)/semver
MOCKGEN ?= $(LOCALBIN)/mockgen
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GORELEASER ?= $(LOCALBIN)/goreleaser
DEEPCOPY_GEN ?= $(LOCALBIN)/deepcopy-gen
## Tool Versions
SEMVER_VERSION ?= v1.1.3
MOCKGEN_VERSION ?= v1.6.0
GOLANGCI_LINT_VERSION ?= v1.50.1
GORELEASER_VERSION ?= v1.14.0
DEEPCOPY_GEN_VERSION ?= v0.26.0
## Tool Installer
.PHONY: semver
semver: $(SEMVER) ## Download semver locally if necessary.
$(SEMVER): $(LOCALBIN)
test -s $(LOCALBIN)/semver || GOBIN=$(LOCALBIN) go install github.com/bakito/semver@$(SEMVER_VERSION)
.PHONY: mockgen
mockgen: $(MOCKGEN) ## Download mockgen locally if necessary.
$(MOCKGEN): $(LOCALBIN)
test -s $(LOCALBIN)/mockgen || GOBIN=$(LOCALBIN) go install github.com/golang/mock/mockgen@$(MOCKGEN_VERSION)
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
.PHONY: goreleaser
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary.
$(GORELEASER): $(LOCALBIN)
test -s $(LOCALBIN)/goreleaser || GOBIN=$(LOCALBIN) go install github.com/goreleaser/goreleaser@$(GORELEASER_VERSION)
.PHONY: deepcopy-gen
deepcopy-gen: $(DEEPCOPY_GEN) ## Download deepcopy-gen locally if necessary.
$(DEEPCOPY_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/deepcopy-gen || GOBIN=$(LOCALBIN) go install k8s.io/code-generator/cmd/deepcopy-gen@$(DEEPCOPY_GEN_VERSION)
## Update Tools
.PHONY: update-toolbox-tools
update-toolbox-tools:
@rm -f \
$(LOCALBIN)/semver \
$(LOCALBIN)/mockgen \
$(LOCALBIN)/golangci-lint \
$(LOCALBIN)/goreleaser \
$(LOCALBIN)/deepcopy-gen
toolbox makefile -f $$(pwd)/Makefile \
github.com/bakito/semver \
github.com/golang/mock/mockgen \
github.com/golangci/golangci-lint/cmd/golangci-lint \
github.com/goreleaser/goreleaser \
k8s.io/code-generator/cmd/deepcopy-gen@github.com/kubernetes/code-generator
## toolbox - end
2022-02-15 01:35:56 +08:00
2022-02-15 01:35:56 +08:00
start-replica:
2022-11-08 01:05:59 +08:00
docker run --pull always --name adguardhome-replica -p 9090:80 -p 9091:3000 --rm adguard/adguardhome
# docker run --pull always --name adguardhome-replica -p 9090:80 -p 9091:3000 --rm adguard/adguardhome:v0.107.13
2022-02-15 01:35:56 +08:00
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
build-image:
$(call check_defined, AGH_SYNC_VERSION)
2022-11-08 01:05:59 +08:00
docker build --build-arg VERSION=${AGH_SYNC_VERSION} --build-arg BUILD=$(shell date -u +'%Y-%m-%dT%H:%M:%S.%3NZ') --name adgardhome-replica -t ghcr.io/bakito/adguardhome-sync:${AGH_SYNC_VERSION} .
kind-create:
kind delete cluster
kind create cluster
kind-test:
2022-10-07 13:32:20 +08:00
@./testdata/e2e/bin/install-chart.sh