undocker/Makefile

57 lines
1.4 KiB
Makefile
Raw Normal View History

SCRIPTS := $(shell awk '/#!\/usr\/bin\/env (ba)?sh/&&FNR==1{print FILENAME}' $(shell git ls-files))
GODEPS := $(shell git ls-files '*.go' go.mod go.sum)
2021-08-24 03:47:38 +00:00
2021-08-24 10:57:30 +00:00
VSN ?= $(shell git describe --dirty)
VSNHASH ?= $(shell git rev-parse --verify HEAD)
LDFLAGS ?= -ldflags "-X main.Version=$(VSN) -X main.VersionHash=$(VSNHASH)"
2021-08-24 04:02:12 +00:00
2024-09-10 07:43:25 +00:00
undocker: $(GODEPS) ## builds binary for the current architecture
go build $(LDFLAGS) -o $@
2021-08-24 04:02:12 +00:00
.PHONY: test
test: coverage.out
2021-06-01 06:00:27 +00:00
.PHONY: lint
2021-08-24 14:23:31 +00:00
lint:
2021-06-01 06:00:27 +00:00
go vet ./...
2024-05-10 11:57:10 +00:00
staticcheck -f stylish ./...
2021-08-24 14:23:31 +00:00
shellcheck $(SCRIPTS)
2024-09-10 07:51:13 +00:00
shfmt -w -i 4 $(SCRIPTS)
2024-05-10 13:10:29 +00:00
git diff --exit-code
2021-06-01 05:42:23 +00:00
.INTERMEDIATE: coverage.out
2021-06-01 05:49:39 +00:00
coverage.out: $(GODEPS)
go test -race -cover -coverprofile $@ ./...
2021-06-01 05:42:23 +00:00
coverage.html: coverage.out
go tool cover -html=$< -o $@
2021-06-01 16:54:55 +00:00
.PHONY: clean
clean:
2022-08-29 15:02:17 +00:00
rm -f undocker coverage.html
2024-05-10 12:59:04 +00:00
TEST_IMAGES = \
busybox-glibc_65ad0d468eb1 \
docker_v27.1.2_save
2024-05-10 12:59:04 +00:00
.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)))