Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (132 loc) · 5.1 KB
/
Copy pathMakefile
File metadata and controls
151 lines (132 loc) · 5.1 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Programs
CMAKE ?= cmake
CTEST ?= ctest
HURL ?= hurl
DOCKER ?= docker
SHELLCHECK ?= shellcheck
MKDOCS ?= mkdocs
NPM ?= npm
NPX ?= npx
NODE ?= node
# Options
INDEX ?= ON
SERVER ?= ON
PRESET ?= Debug
OUTPUT ?= ./build
PREFIX ?= $(OUTPUT)/dist
PARALLEL ?= $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)
DOCKERFILE_TEST_REPEAT ?= 1
# The image build cannot consult git, so the revision is handed to it
REVISION ?= $(shell git rev-parse HEAD 2>/dev/null)
DOCKER_BUILD_FLAGS ?=
SANDBOX ?= test/e2e/html
SANDBOX_PORT ?= 8000
# Only for local development
# Enterprise is the default for local development. Production use of the
# Enterprise edition requires a commercial license.
# See https://one.sourcemeta.com/commercial
ENTERPRISE ?= ON
DOCKERFILE = $(if $(filter ON,$(ENTERPRISE)),enterprise/Dockerfile,Dockerfile)
EDITION = $(if $(filter ON,$(ENTERPRISE)),enterprise,community)
.PHONY: all
all: configure compile test
node_modules: package.json package-lock.json
$(NPM) ci
ui/node_modules: ui/package.json ui/package-lock.json
cd ui && $(NPM) ci
.PHONY: configure
configure: node_modules ui/node_modules
$(CMAKE) -S . -B $(OUTPUT) \
-DCMAKE_BUILD_TYPE:STRING=$(PRESET) \
-DCMAKE_COMPILE_WARNING_AS_ERROR:BOOL=ON \
-DONE_TESTS:BOOL=ON \
-DONE_INDEX:BOOL=$(INDEX) \
-DONE_SERVER:BOOL=$(SERVER) \
-DONE_ENTERPRISE:BOOL=$(ENTERPRISE) \
-DONE_PREFIX:STRING=$(or $(realpath $(PREFIX)),$(abspath $(PREFIX))) \
-DBUILD_SHARED_LIBS:BOOL=OFF
.PHONY: compile
compile:
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --target clang_format
$(CMAKE) --build $(OUTPUT) --config $(PRESET)
$(CMAKE) --install $(OUTPUT) --prefix $(PREFIX) --config $(PRESET) --verbose \
--component sourcemeta_one --component sourcemeta_one
$(CMAKE) --install $(OUTPUT) --prefix $(PREFIX) --config $(PRESET) --verbose \
--component sourcemeta_one --component sourcemeta_jsonschema
.PHONY: lint
lint:
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --target clang_format_test
$(CMAKE) --build $(OUTPUT) --config $(PRESET) --target shellcheck
.PHONY: check
check:
./contrib/check-enterprise-hurl-tests.sh
.PHONY: test
test: check
$(CTEST) --test-dir $(OUTPUT) --build-config $(PRESET) --output-on-failure --parallel
.PHONY: docker-build
docker-build: $(DOCKERFILE)
$(DOCKER) build $(DOCKER_BUILD_FLAGS) --tag one . --file $< --progress plain \
--build-arg SOURCEMETA_ONE_BUILD_TYPE=$(PRESET) \
--build-arg SOURCEMETA_ONE_PARALLEL=$(PARALLEL) \
--build-arg SOURCEMETA_ONE_TEST_REPEAT=$(DOCKERFILE_TEST_REPEAT) \
--build-arg SOURCEMETA_ONE_REVISION=$(REVISION)
# Useful to run the entire main suite in a single command
.PHONY: test-e2e
test-e2e: check
./contrib/e2e-native.sh test/e2e/empty $(EDITION) $(SANDBOX_PORT)
./contrib/e2e-native.sh test/e2e/headless $(EDITION) $(SANDBOX_PORT)
./contrib/e2e-native.sh test/e2e/html $(EDITION) $(SANDBOX_PORT)
./contrib/e2e-native.sh test/e2e/ui-experimental $(EDITION) $(SANDBOX_PORT)
./contrib/e2e-native.sh test/e2e/meta $(EDITION) $(SANDBOX_PORT)
./contrib/e2e-native.sh test/e2e/no-api $(EDITION) $(SANDBOX_PORT)
./contrib/e2e-native.sh test/e2e/chaos $(EDITION) $(SANDBOX_PORT)
ifeq ($(ENTERPRISE),ON)
./contrib/e2e-native.sh enterprise/e2e/empty $(EDITION) $(SANDBOX_PORT)
./contrib/e2e-native.sh enterprise/e2e/html $(EDITION) $(SANDBOX_PORT)
# Machine credentials need nobody to sign in, so this authentication
# sandbox is the one that runs without an identity provider beside it
./contrib/e2e-native.sh enterprise/e2e/auth-keys $(EDITION) $(SANDBOX_PORT)
# The rest stand up an identity provider alongside the registry, so they
# only run under Docker Compose, never the native path
endif
.PHONY: docker
docker: docker-build
$(MAKE) -C test/e2e/empty EDITION=$(EDITION)
$(MAKE) -C test/e2e/headless EDITION=$(EDITION)
$(MAKE) -C test/e2e/html EDITION=$(EDITION)
$(MAKE) -C test/e2e/meta EDITION=$(EDITION)
$(MAKE) -C test/e2e/no-api EDITION=$(EDITION)
$(MAKE) -C test/e2e/chaos EDITION=$(EDITION)
ifeq ($(ENTERPRISE),ON)
$(MAKE) -C enterprise/e2e/empty EDITION=$(EDITION)
$(MAKE) -C enterprise/e2e/html EDITION=$(EDITION)
$(MAKE) -C enterprise/e2e/auth-keys EDITION=$(EDITION)
# The rest each stand up an identity provider alongside the registry,
# exercising both JWT and apiKey policies
$(MAKE) -C enterprise/e2e/auth EDITION=$(EDITION)
$(MAKE) -C enterprise/e2e/auth-closed EDITION=$(EDITION)
$(MAKE) -C enterprise/e2e/auth-sso EDITION=$(EDITION)
endif
.PHONY: docker-benchmark
docker-benchmark: benchmark/Dockerfile
$(DOCKER) build --tag one-benchmark . --file $< --progress plain
.PHONY: benchmark
benchmark:
./benchmark/index.sh $(OUTPUT)/dist/bin/sourcemeta-one-index
.PHONY: sandbox-index
sandbox-index: compile
$(PREFIX)/bin/sourcemeta-one-index \
$(SANDBOX)/one.json $(OUTPUT)/sandbox --configuration
$(PREFIX)/bin/sourcemeta-one-index \
$(SANDBOX)/one.json $(OUTPUT)/sandbox --profile
.PHONY: sandbox
sandbox: sandbox-index
$(PREFIX)/bin/sourcemeta-one-server \
$(realpath $(OUTPUT)/sandbox) $(SANDBOX_PORT)
.PHONY: docs
docs: mkdocs.yml
$(MKDOCS) serve --config-file $< --strict --open
.PHONY: clean
clean:
$(CMAKE) -E rm -R -f build
$(DOCKER) system prune --force --all --volumes || true