Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (136 loc) · 5.16 KB
/
Copy pathMakefile
File metadata and controls
183 lines (136 loc) · 5.16 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
default: base
SHELL := /usr/bin/env bash
NODE_CONFIG_ENV ?= test
export PGAPPNAME ?= odkcentral
node_modules: package.json
npm install
touch node_modules
.PHONY: node_version
node_version: node_modules
node lib/bin/enforce-node-version.js
################################################################################
# OIDC
.PHONY: test-oidc-integration
test-oidc-integration: node_version
TEST_AUTH=oidc NODE_CONFIG_ENV=oidc-integration-test make test-integration
.PHONY: dev-oidc
dev-oidc: base
NODE_CONFIG_ENV=oidc-development npx nodemon --watch lib --watch config lib/bin/run-server.js
.PHONY: fake-oidc-server
fake-oidc-server:
cd test/e2e/oidc/fake-oidc-server && \
FAKE_OIDC_ROOT_URL=http://localhost:9898 npx nodemon index.mjs
.PHONY: fake-oidc-server-ci
fake-oidc-server-ci:
cd test/e2e/oidc/fake-oidc-server && \
node index.mjs
################################################################################
# S3
.PHONY: fake-s3-accounts
fake-s3-accounts: node_version
NODE_CONFIG_ENV=s3-dev node lib/bin/s3-create-bucket.js
.PHONY: dev-s3
dev-s3: fake-s3-accounts base
NODE_CONFIG_ENV=s3-dev npx nodemon --watch lib --watch config lib/bin/run-server.js
# default admin credentials: minioadmin:minioadmin
# See: https://hub.docker.com/r/pgsty/silo/
# MINIO_KMS_SECRET_KEY, MINIO_KMS_AUTO_ENCRYPTION enable encryption - this changes how s3 ETags are generated.
# See: https://docs.aws.amazon.com/AmazonS3/latest/API/API_Object.html
# See: https://github.com/minio/minio/discussions/19012
S3_SERVER_ARGS := -p 127.0.0.1:9000:9000 -p 127.0.0.1:9001:9001 \
-e MINIO_ROOT_USER=odk-central-dev \
-e MINIO_ROOT_PASSWORD=topSecret123 \
-e MINIO_KMS_AUTO_ENCRYPTION=on \
-e MINIO_KMS_SECRET_KEY=odk-minio-test-key:QfdUCrn3UQ58W5pqCS5SX4SOlec9sT8yb4rZ4zK24w0= \
pgsty/silo:RELEASE.2026-09-03T13-18-01Z server /data --console-address ":9001"
.PHONY: fake-s3-server-ephemeral
fake-s3-server-ephemeral:
docker run --rm $(S3_SERVER_ARGS)
.PHONY: fake-s3-server-persistent
fake-s3-server-persistent:
docker run --detach $(S3_SERVER_ARGS)
################################################################################
# DATABASE MIGRATIONS
.PHONY: migrations
migrations: node_version
node lib/bin/run-migrations.js
################################################################################
# RUN SERVER
.PHONY: base
base: node_modules node_version migrations
.PHONY: dev
dev: base
npx nodemon --watch lib --watch config lib/bin/run-server.js
.PHONY: run
run: base
node lib/bin/run-server.js
.PHONY: debug
debug: base
node --debug --inspect lib/bin/run-server.js
################################################################################
# TEST & LINT
.PHONY: test
test: lint
$(MAKE) test-unit
$(MAKE) test-integration
.PHONY: test-db-migrations
test-db-migrations:
NODE_CONFIG_ENV=db-migration-test npx mocha --bail --sort --timeout=20000 \
--require test/db-migrations/mocha-setup.js \
./test/db-migrations/**/*.spec.js
.PHONY: test-db-ssl
test-db-ssl:
NODE_CONFIG_ENV=db-migration-test npx mocha --sort --timeout=20000 \
--require test/db-ssl/mocha-setup.js \
./test/db-ssl/**/*.spec.js
.PHONY: test-fast
test-fast: node_version
MOCHA_OPTIONS="--fgrep @slow --invert" $(MAKE) test-unit
MOCHA_OPTIONS="--fgrep @slow --invert" $(MAKE) test-integration
.PHONY: test-integration
test-integration: node_version
NODE_CONFIG_ENV=$(NODE_CONFIG_ENV) BCRYPT=insecure npx mocha --recursive test/integration
.PHONY: test-unit
test-unit: node_version
NODE_CONFIG_ENV=test BCRYPT=insecure npx mocha --recursive test/unit
.PHONY: test-coverage
test-coverage: node_version
NODE_CONFIG_ENV=test npx nyc -x "**/migrations/**" --reporter=lcov node_modules/.bin/_mocha --recursive test
.PHONY: lint
lint: node_version
ESLINT_USE_FLAT_CONFIG=false \
npx eslint --cache --max-warnings 0 . \
2> >(grep -Ev 'ESLintRCWarning|--trace-warnings' >&2) # filter eslintrc deprecation warning
################################################################################
# POSTGRES
.PHONY: run-docker-postgres
run-docker-postgres: stop-docker-postgres
test/bin/docker-postgres.sh start
.PHONY: run-docker-postgres-ssl
run-docker-postgres-ssl: stop-docker-postgres-ssl
test/bin/docker-postgres.sh --ssl start
.PHONY: stop-docker-postgres
stop-docker-postgres:
test/bin/docker-postgres.sh stop
.PHONY: stop-docker-postgres-ssl
stop-docker-postgres-ssl:
test/bin/docker-postgres.sh --ssl stop
.PHONY: rm-docker-postgres
rm-docker-postgres: stop-docker-postgres
test/bin/docker-postgres.sh remove
.PHONY: rm-docker-postgres-ssl
rm-docker-postgres-ssl: stop-docker-postgres-ssl
test/bin/docker-postgres.sh --ssl remove
################################################################################
# OTHER
.PHONY: check-for-large-files
check-for-large-files:
./test/check-for-large-files.sh
.PHONY: api-docs
api-docs:
(test "$(docker images -q odk-docs)" || docker build --file odk-docs.dockerfile -t odk-docs .) && \
docker run --rm -it -v ./docs:/docs/docs/_static/central-spec -p 127.0.0.1:8000:8000 odk-docs
.PHONY: api-docs-lint
api-docs-lint:
node lib/bin/openapi-docs-lint.js docs/api.yaml && \
npx --no @redocly/cli lint --config docs/redocly.conf.yaml docs/api.yaml