-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (93 loc) · 3.52 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
# Programs
CMAKE ?= cmake
HURL ?= hurl
JSONSCHEMA ?= jsonschema
DOCKER ?= docker
SHELLCHECK ?= shellcheck
NPX ?= npx
NPM ?= npm
# Options
INDEX ?= ON
SERVER ?= ON
EDITION ?= ee
PRESET ?= Debug
OUTPUT ?= ./build
PREFIX ?= $(OUTPUT)/dist
SANDBOX ?= ./test/sandbox
ifeq ($(EDITION), ee)
ENTERPRISE := ON
else
ENTERPRISE := OFF
endif
.PHONY: all
all: configure compile test-schemas test
.PHONY: configure
configure:
$(CMAKE) -S . -B $(OUTPUT) \
-DCMAKE_BUILD_TYPE:STRING=$(PRESET) \
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON \
-DREGISTRY_DEVELOPMENT:BOOL=ON \
-DREGISTRY_INDEX:BOOL=$(INDEX) \
-DREGISTRY_SERVER:BOOL=$(SERVER) \
-DREGISTRY_ENTERPRISE:BOOL=$(ENTERPRISE) \
-DREGISTRY_PREFIX:STRING=$(realpath $(PREFIX)) \
-DBUILD_SHARED_LIBS:BOOL=OFF
.PHONY: compile
compile:
$(JSONSCHEMA) fmt --verbose schemas/*.json
$(JSONSCHEMA) lint --verbose schemas/*.json
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --target clang_format
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --target shellcheck
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --parallel 4
$(CMAKE) --install $(OUTPUT) --prefix $(PREFIX) --config $(PRESET) --verbose \
--component sourcemeta_registry
.PHONY: lint
lint:
$(JSONSCHEMA) fmt --check --verbose schemas/*.json
$(JSONSCHEMA) lint --verbose schemas/*.json
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --target clang_format
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --target shellcheck
$(SHELLCHECK) test/cli/*/*/*.sh test/sandbox/*.sh
.PHONY: test
test:
./test/cli/common/index/invalid-configuration.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/common/index/invalid-schema.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/common/index/external-reference.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/common/index/url-base-trailing-slash.sh $(PREFIX)/bin/sourcemeta-registry-index
ifeq ($(ENTERPRISE), ON)
./test/cli/ee/index/no-options.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/ee/index/no-output.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/ee/index/directory-index.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/ee/index/search-index.sh $(PREFIX)/bin/sourcemeta-registry-index
else
./test/cli/ce/index/no-options.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/ce/index/no-output.sh $(PREFIX)/bin/sourcemeta-registry-index
./test/cli/ce/index/directory-index.sh $(PREFIX)/bin/sourcemeta-registry-index
endif
.PHONY: test-schemas
test-schemas:
$(JSONSCHEMA) test test/schemas --resolve schemas
.PHONY: test-e2e
test-e2e:
$(HURL) --test \
--variable base=$(shell jq --raw-output '.url' < $(SANDBOX)/configuration.json) \
test/e2e/common/*.hurl test/e2e/$(EDITION)/*.hurl
ifeq ($(ENTERPRISE), ON)
$(NPM) --prefix test/ui install
$(NPX) --prefix test/ui playwright install --with-deps
env BASE_URL=$(shell jq --raw-output '.url' < $(SANDBOX)/configuration.json) \
$(NPX) --prefix test/ui playwright test --config test/ui/playwright.config.js
endif
.PHONY: sandbox
sandbox: compile
$(PREFIX)/bin/sourcemeta-registry-index $(SANDBOX)/configuration.json $(OUTPUT)/sandbox
./test/sandbox/manifest-check.sh $(OUTPUT)/sandbox $(SANDBOX)/manifest-$(EDITION).txt
$(PREFIX)/bin/sourcemeta-registry-server $(OUTPUT)/sandbox
.PHONY: docker
docker:
$(DOCKER) build --tag registry-$(EDITION) . --file Dockerfile.$(EDITION) --progress plain
$(DOCKER) compose --file test/sandbox/compose-$(EDITION).yaml up --build
.PHONY: clean
clean:
$(CMAKE) -E rm -R -f build test/ui/node_modules test/ui/test-results
$(DOCKER) system prune --force --all --volumes || true