-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Makefile
145 lines (112 loc) · 4.19 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
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
# Copyright Dave Verwer, Sven A. Schmidt, and other contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SHELL=bash
DOCKER_IMAGE=registry.gitlab.com/finestructure/swiftpackageindex
ifndef VERSION
export VERSION=$(shell git rev-parse HEAD)
WARN_VERSION=true
endif
version:
ifeq ($(WARN_VERSION), true)
$(info No VERSION provided, defaulting to $(VERSION))
else
$(info VERSION: $(VERSION))
endif
build:
swift build --disable-automatic-resolution
run:
swift run
test: xcbeautify
set -o pipefail \
&& swift test --disable-automatic-resolution --sanitize=thread \
2>&1 | ./xcbeautify --renderer github-actions
test-query-performance: xcbeautify
set -o pipefail \
&& env RUN_QUERY_PERFORMANCE_TESTS=true \
swift test --disable-automatic-resolution \
--filter QueryPerformanceTests \
2>&1 | tee test.log
grep "ℹ️" test.log
grep -v "\] Compiling" test.log | ./xcbeautify --renderer github-actions
test-fast:
@echo Skipping image snapshot tests
@echo Running without --sanitize=thread
swift test --disable-automatic-resolution
xcbeautify:
rm -rf .build/checkouts/xcbeautify
git clone https://github.com/cpisciotta/xcbeautify.git .build/checkouts/xcbeautify
cd .build/checkouts/xcbeautify && git checkout 2.6.0 && make build
binpath=`cd .build/checkouts/xcbeautify && swift build -c release --show-bin-path` && ln -sf $$binpath/xcbeautify
docker-build: version
docker build -t $(DOCKER_IMAGE):$(VERSION) .
docker-push:
docker push $(DOCKER_IMAGE):$(VERSION)
test-docker:
@# run tests inside a docker container
docker run --rm -v "$(PWD)":/host -w /host \
--add-host=host.docker.internal:host-gateway \
registry.gitlab.com/finestructure/spi-base:1.1.0 \
make test
test-e2e: db-reset reconcile ingest analyze
@# run import sequence test
migrate:
echo y | swift run Run migrate
revert:
swift run Run migrate --revert
routes:
swift run Run routes
reconcile:
swift run Run reconcile
ingest:
swift run Run ingest --limit 1
analyze:
swift run Run analyze --limit 1
db-up: db-up-dev db-up-test
db-up-dev:
docker run --name spi_dev -e POSTGRES_DB=spi_dev -e POSTGRES_USER=spi_dev -e POSTGRES_PASSWORD=xxx -p 6432:5432 -d postgres:16-alpine
# Keep test db on postgres:13 for now, to make local testing faster. See
# https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/issues/3360#issuecomment-2331103211
# for details
db-up-test:
docker run --name spi_test \
-e POSTGRES_DB=spi_test \
-e POSTGRES_USER=spi_test \
-e POSTGRES_PASSWORD=xxx \
-e PGDATA=/pgdata \
--tmpfs /pgdata:rw,noexec,nosuid,size=1024m \
-p 5432:5432 \
-d \
postgres:13-alpine
db-down: db-down-dev db-down-test
db-down-dev:
docker rm -f spi_dev
db-down-test:
docker rm -f spi_test
db-reset: db-down db-up migrate
NPM_INSTALL=/usr/local/bin/npm --cache /tmp/.npm-cache install
NPM_RUN=/usr/local/bin/npm --cache /tmp/.npm-cache run
build-front-end:
docker run --rm -v $$PWD:/host -w /host --user $$(id -u):$$(id -g) --entrypoint sh node:21-alpine -c "$(NPM_INSTALL) && $(NPM_RUN) build"
serve-front-end:
docker run --rm -it -v $$PWD:/host -w /host --user $$(id -u):$$(id -g) --entrypoint sh node:21-alpine -c "$(NPM_INSTALL) && $(NPM_RUN) serve"
lint-front-end:
docker run --rm -v $$PWD:/host -w /host --user $$(id -u):$$(id -g) --entrypoint sh node:21-alpine -c "$(NPM_INSTALL) && $(NPM_RUN) lint"
copy-front-end-resources:
@# copy front-end resources from existing image (rather than build them)
docker run --rm -it -v $$PWD:/host -w /host --entrypoint sh registry.gitlab.com/finestructure/swiftpackageindex:$(VERSION) -c "cp -r /run/Public ."
periphery:
periphery scan --quiet
update-doc-test:
@echo ⚠️ Make sure to load a new db snapshot!
swift run Run create-restfile docs > restfiles/doc-test.restfile