-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
75 lines (58 loc) · 2.55 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
EXTENSION = postgrest_openapi
EXTVERSION = 0.0.1
DATA = $(wildcard sql/*--*.sql)
all: sql/$(EXTENSION)--$(EXTVERSION).sql $(EXTENSION).control
sql/$(EXTENSION).sql:
cat sql/*.sql > $@
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).sql
cp $< $@
$(EXTENSION).control:
sed "s/@EXTVERSION@/$(EXTVERSION)/g" $(EXTENSION).control.in > $(EXTENSION).control
.PHONY: fixtures
fixtures:
createdb contrib_regression
psql -v ON_ERROR_STOP=1 -f test/fixtures.sql -d contrib_regression
.PHONY: clean_fixtures
clean_fixtures:
dropdb --if-exists contrib_regression
# extra dep for PostgreSQL targets in pgxs.mk
clean: clean_fixtures
##### Docker stuff
PWD := $(shell pwd)
BASE_VAR := $(shell basename $(PWD))
CONTAINER_NAME := $(BASE_VAR)_postgrest-openapi-build_1
DOCKER_COMPOSE_COMMAND_BASE=docker-compose --project-directory . --env-file hosting/environment.env
DOCKER_COMPOSE_COMMAND_TESTS=$(DOCKER_COMPOSE_COMMAND_BASE) --file hosting/tests/docker-compose.yml
docker-build-test:
$(DOCKER_COMPOSE_COMMAND_TESTS) build --force
$(DOCKER_COMPOSE_COMMAND_TESTS) down --remove-orphans
$(DOCKER_COMPOSE_COMMAND_TESTS) up -d
sleep 4
docker logs $(CONTAINER_NAME)
DOCKER_COMPOSE_COMMAND_FINAL=$(DOCKER_COMPOSE_COMMAND_BASE) --file hosting/final/docker-compose.yml
docker-build: docker-build-test
$(DOCKER_COMPOSE_COMMAND_FINAL) build
$(DOCKER_COMPOSE_COMMAND_FINAL) down --remove-orphans
$(DOCKER_COMPOSE_COMMAND_FINAL) up -d
DOCKER_COMPOSE_COMMAND_BAR=$(DOCKER_COMPOSE_COMMAND_BASE) --file hosting/build-and-run/docker-compose.yml
docker-build-and-run: docker-build
$(DOCKER_COMPOSE_COMMAND_BAR) build
$(DOCKER_COMPOSE_COMMAND_BAR) down --remove-orphans
$(DOCKER_COMPOSE_COMMAND_BAR) up -d
# make docker-output-save EXPORT=main
docker-output-save: docker-build-test
ifeq ("$(EXPORT)","")
echo "Please use: make docker-output-save EXPORT=<test-set>\nWhere <test-set> is any of the files in test/sql (but without the sql on the end"
else
$(eval CONTAINER_ID := $(shell docker inspect --type container --format '{{.Id}}' $(CONTAINER_NAME)) )
docker commit $(CONTAINER_ID) debug/$(CONTAINER_NAME)
docker run -it --rm --entrypoint sh debug/$(CONTAINER_NAME) -c "cat /buildroot/output/results/$(EXPORT).out" | dos2unix > test/expected/$(EXPORT).out
endif
##### Postgres stuff
TESTS = $(wildcard test/sql/*.sql)
REGRESS = $(patsubst test/sql/%.sql,%,$(TESTS))
REGRESS_OPTS = --use-existing --inputdir=test --outputdir=output
EXTRA_CLEAN = sql/$(EXTENSION).sql sql/$(EXTENSION)--$(EXTVERSION).sql $(EXTENSION).control
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)