forked from opencontainers/distribution-spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
119 lines (100 loc) · 4.39 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
EPOCH_TEST_COMMIT := 91d6d8466e68f1efff7977b63ad6f48e72245e05
CURRENT_COMMIT := $(shell git log --format="%H" -n 1)
CONFORMANCE_VERSION ?= $(CURRENT_COMMIT)
DOCKER ?= $(shell command -v docker 2>/dev/null)
PANDOC ?= $(shell command -v pandoc 2>/dev/null)
GOLANGCILINT ?= $(shell command -v golangcli-lint 2>/dev/null)
OUTPUT_DIRNAME ?= output/
DOC_FILENAME ?= oci-distribution-spec
PANDOC_CONTAINER ?= ghcr.io/opencontainers/pandoc:2.9.2.1-9.fc34.x86_64@sha256:590c5c7aaa6e8e7a4debae7e9102c837daa0c8a76f8f5b5c9831ea5f755e3e95
ifeq "$(strip $(PANDOC))" ''
ifneq "$(strip $(DOCKER))" ''
PANDOC = $(DOCKER) run \
--rm \
-v $(shell pwd)/:/input/:ro \
-v $(shell pwd)/$(OUTPUT_DIRNAME)/:/$(OUTPUT_DIRNAME)/ \
-u $(shell id -u) \
--workdir /input \
$(PANDOC_CONTAINER)
PANDOC_SRC := /input/
PANDOC_DST := /
endif
endif
GOLANGCILINT_CONTAINER ?= ghcr.io/opencontainers/golangci-lint:v1.52.1@sha256:d3d3d56f9706ebe843c1b06686c385877ba65b33f39507cdbeb22f482adce65a
ifeq "$(strip $(GOLANGCILINT))" ''
ifneq "$(strip $(DOCKER))" ''
GOLANGCILINT = $(DOCKER) run \
--rm \
-v $(shell pwd)/:/input:ro \
-e GOCACHE=/tmp/.cache \
-e GO111MODULE=on \
-e GOLANGCI_LINT_CACHE=/tmp/.cache \
--entrypoint /bin/bash \
-u $(shell id -u) \
--workdir /input \
$(GOLANGCILINT_CONTAINER)
GOLANGCILINT_SRC := /input/
GOLANGCILINT_DST := /
endif
endif
DOC_FILES := spec.md
FIGURE_FILES :=
test: .gitvalidation
# When this is running in GitHub, it will only check the GitHub commit range
.gitvalidation:
@command -v git-validation >/dev/null 2>/dev/null || (echo "ERROR: git-validation not found. Consider 'make install.tools' target" && false)
ifdef GITHUB_SHA
git-validation -q -run DCO,short-subject,dangling-whitespace -range $(GITHUB_SHA)..HEAD
else
git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
endif
docs: $(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf $(OUTPUT_DIRNAME)/$(DOC_FILENAME).html
ifeq "$(strip $(PANDOC))" ''
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES) $(FIGURE_FILES)
$(error cannot build $@ without either pandoc or docker)
else
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).pdf: $(DOC_FILES) $(FIGURE_FILES)
mkdir -p $(OUTPUT_DIRNAME)/ && \
$(PANDOC) -f gfm -t latex --pdf-engine=xelatex -V geometry:margin=0.5in,bottom=0.8in -V block-headings -o $(PANDOC_DST)$@ $(patsubst %,$(PANDOC_SRC)%,$(DOC_FILES))
ls -sh $(realpath $@)
$(OUTPUT_DIRNAME)/$(DOC_FILENAME).html: header.html $(DOC_FILES) $(FIGURE_FILES)
mkdir -p $(OUTPUT_DIRNAME)/ && \
cp -ap img/ $(shell pwd)/$(OUTPUT_DIRNAME)/&& \
$(PANDOC) -f gfm -t html5 -H $(PANDOC_SRC)header.html --standalone -o $(PANDOC_DST)$@ $(patsubst %,$(PANDOC_SRC)%,$(DOC_FILES))
ls -sh $(realpath $@)
endif
header.html: .tool/genheader.go specs-go/version.go
rm -f go.mod go.sum && \
go mod init github.com/opencontainers/distribution-spec && \
go get github.com/opencontainers/distribution-spec/specs-go && \
go run .tool/genheader.go > $@
install.tools: .install.gitvalidation
.install.gitvalidation:
go install github.com/vbatts/git-validation@latest
conformance: conformance-test conformance-binary
conformance-test:
$(GOLANGCILINT) -c 'cd conformance && golangci-lint run -v'
conformance-binary: $(OUTPUT_DIRNAME)/conformance.test
TEST_REGISTRY_CONTAINER ?= ghcr.io/project-zot/zot-minimal-linux-amd64:v2.0.0-rc6@sha256:bf95a94849cd9c6f596fb10e5a2d03b74267e7886d1ba0b3dab33337d9e46e5c
registry-ci:
docker rm -f oci-conformance && \
mkdir -p $(OUTPUT_DIRNAME) && \
echo '{"distSpecVersion":"1.1.0-dev","storage":{"rootDirectory":"/tmp/zot","gc":false,"dedupe":false},"http":{"address":"0.0.0.0","port":"5000"},"log":{"level":"debug"}}' > $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json
docker run -d \
-v $(shell pwd)/$(OUTPUT_DIRNAME)/zot-config.json:/etc/zot/config.json \
--name=oci-conformance \
-p 5000:5000 \
$(TEST_REGISTRY_CONTAINER) && \
sleep 5
conformance-ci:
export OCI_ROOT_URL="http://localhost:5000" && \
export OCI_NAMESPACE="myorg/myrepo" && \
export OCI_TEST_PULL=1 && \
export OCI_TEST_PUSH=1 && \
export OCI_TEST_CONTENT_DISCOVERY=1 && \
export OCI_TEST_CONTENT_MANAGEMENT=1 && \
$(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test
$(OUTPUT_DIRNAME)/conformance.test:
cd conformance && \
CGO_ENABLED=0 go test -c -o $(shell pwd)/$(OUTPUT_DIRNAME)/conformance.test \
--ldflags="-X github.com/opencontainers/distribution-spec/conformance.Version=$(CONFORMANCE_VERSION)"