undocker

extract docker archives
Log | Files | Refs | README | LICENSE

Makefile (1214B) - Raw


      1 GODEPS := $(shell git ls-files '*.go' go.mod go.sum)
      2 
      3 VSN ?= $(shell git describe --dirty)
      4 VSNHASH ?= $(shell git rev-parse --verify HEAD)
      5 LDFLAGS ?= -ldflags "-X main.Version=$(VSN) -X main.VersionHash=$(VSNHASH)"
      6 
      7 undocker: $(GODEPS) ## builds binary for the current architecture
      8 	go build $(LDFLAGS) -o $@
      9 
     10 .PHONY: test
     11 test: coverage.out
     12 
     13 .PHONY: lint
     14 lint:
     15 	go vet ./...
     16 	staticcheck -f stylish ./...
     17 	shellcheck $$(awk '/#!\/usr\/bin\/env (ba)?sh/&&FNR==1{print FILENAME}' $$(git ls-files))
     18 	shfmt -w -i 4 $$(awk '/#!\/usr\/bin\/env (ba)?sh/&&FNR==1{print FILENAME}' $$(git ls-files))
     19 	git diff --exit-code
     20 
     21 .INTERMEDIATE: coverage.out
     22 coverage.out: $(GODEPS)
     23 	go test -race -cover -coverprofile $@ ./...
     24 
     25 coverage.html: coverage.out
     26 	go tool cover -html=$< -o $@
     27 
     28 .PHONY: clean
     29 clean:
     30 	rm -f undocker coverage.html
     31 
     32 TAR ?= $(shell command -v gtar 2>/dev/null || echo tar)
     33 
     34 .PHONY: test-integration
     35 test-integration: undocker
     36 	@failed=0; \
     37 	for img in t/*.tar; do \
     38 		name=$$(basename "$$img" .tar); \
     39 		TZ=UTC ./undocker "$$img" - | $(TAR) -tv > "t/$$name-got.txt"; \
     40 		if diff -u "t/$$name.txt" "t/$$name-got.txt"; then \
     41 			echo "$$name success"; \
     42 		else \
     43 			failed=1; \
     44 		fi; \
     45 	done; \
     46 	exit $$failed