2024-05-10 14:57:10 +03:00
|
|
|
SCRIPTS = $(shell awk '/#!\/usr\/bin\/env (ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
|
2021-06-01 08:49:39 +03:00
|
|
|
GODEPS = $(shell git ls-files '*.go' go.mod go.sum)
|
2021-08-24 06:47:38 +03:00
|
|
|
|
2021-08-24 13:57:30 +03:00
|
|
|
VSN ?= $(shell git describe --dirty)
|
2021-08-24 07:02:12 +03:00
|
|
|
VSNHASH = $(shell git rev-parse --verify HEAD)
|
|
|
|
LDFLAGS = -ldflags "-X main.Version=$(VSN) -X main.VersionHash=$(VSNHASH)"
|
|
|
|
|
2021-08-25 08:53:03 +03:00
|
|
|
undocker: ## builds binary for the current architecture
|
2021-09-29 14:29:26 +03:00
|
|
|
go build $(LDFLAGS) -o $@
|
2021-08-25 08:53:03 +03:00
|
|
|
|
2021-08-24 07:02:12 +03:00
|
|
|
.PHONY: test
|
2021-09-29 14:29:26 +03:00
|
|
|
test: coverage.out
|
2021-09-01 09:38:13 +03:00
|
|
|
|
2021-06-01 09:00:27 +03:00
|
|
|
.PHONY: lint
|
2021-08-24 17:23:31 +03:00
|
|
|
lint:
|
2021-06-01 09:00:27 +03:00
|
|
|
go vet ./...
|
2024-05-10 14:57:10 +03:00
|
|
|
staticcheck -f stylish ./...
|
2021-08-24 17:23:31 +03:00
|
|
|
shellcheck $(SCRIPTS)
|
2021-06-01 08:42:23 +03:00
|
|
|
|
|
|
|
.INTERMEDIATE: coverage.out
|
2021-06-01 08:49:39 +03:00
|
|
|
coverage.out: $(GODEPS)
|
2021-09-29 14:29:26 +03:00
|
|
|
go test -race -cover -coverprofile $@ ./...
|
2021-06-01 08:42:23 +03:00
|
|
|
|
|
|
|
coverage.html: coverage.out
|
|
|
|
go tool cover -html=$< -o $@
|
2021-06-01 19:54:55 +03:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2022-08-29 18:02:17 +03:00
|
|
|
rm -f undocker coverage.html
|
2024-05-10 15:59:04 +03:00
|
|
|
|
|
|
|
TEST_IMAGES = busybox-glibc_65ad0d468eb1
|
|
|
|
|
|
|
|
.PHONY: test-integration
|
|
|
|
test-integration: $(foreach IMG,$(TEST_IMAGES),test-integration-$(IMG))
|
|
|
|
|
|
|
|
ifeq ($(shell uname -s),Darwin)
|
|
|
|
TAR := gtar
|
|
|
|
else
|
|
|
|
TAR := tar
|
|
|
|
endif
|
|
|
|
|
|
|
|
define TEST_RULES
|
|
|
|
.PHONY: test-integration-$(IMG)
|
|
|
|
test-integration-$(IMG): undocker t/$(IMG).tar t/$(IMG).txt
|
|
|
|
./undocker t/$(IMG).tar - | $$(TAR) -tv > t/$(IMG)-got.txt
|
|
|
|
diff -u t/$(IMG).txt t/$(IMG)-got.txt
|
|
|
|
@echo "$(IMG) success"
|
|
|
|
|
|
|
|
t/$(IMG).tar:
|
|
|
|
wget -O $$@ https://git.jakstys.lt/api/packages/motiejus/generic/undocker-tests/0/$(IMG).tar
|
|
|
|
endef
|
|
|
|
$(foreach IMG,$(TEST_IMAGES),$(eval $(TEST_RULES)))
|