Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (42 loc) · 1.77 KB
/
Copy pathMakefile
File metadata and controls
53 lines (42 loc) · 1.77 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
SHELL := /bin/bash
BIN := bin
.PHONY: build build-app build-db build-validate run create-db test schema-check validate clean
## build: compile all binaries into bin/
build: build-app build-db build-validate
## build-app: compile the HTTP API server
build-app:
go build -o $(BIN)/ignis cmd/ignis/main.go
## build-db: compile the database loader (destructive — drops and recreates tables)
build-db:
go build -o $(BIN)/build_db cmd/build_db/main.go
## build-validate: compile the accuracy validation tool
build-validate:
go build -o $(BIN)/validate cmd/validate/main.go
## run: build and start the HTTP API server
run: build-app
./$(BIN)/ignis
## create-db: create the database if absent (or drop only the tabula schema if it exists), then populate via build_db
create-db: build-db
@source <(sed 's/[[:space:]]*#.*//' .env | grep -v '^[[:space:]]*$$') && \
if PGPASSWORD=$$DB_PASSWORD psql -h $$DB_HOST -p $$DB_PORT -U $$DB_USER -d postgres \
-tc "SELECT 1 FROM pg_database WHERE datname='$$DB_NAME'" | grep -q 1; then \
echo "Database '$$DB_NAME' exists — dropping tabula schema only." && \
PGPASSWORD=$$DB_PASSWORD psql -h $$DB_HOST -p $$DB_PORT -U $$DB_USER -d $$DB_NAME \
-c "DROP SCHEMA IF EXISTS tabula CASCADE;"; \
else \
PGPASSWORD=$$DB_PASSWORD psql -h $$DB_HOST -p $$DB_PORT -U $$DB_USER -d postgres \
-c "CREATE DATABASE $$DB_NAME;" && echo "Created database '$$DB_NAME'."; \
fi && \
./$(BIN)/build_db
## test: run all unit tests
test:
go test ./...
## schema-check: validate schemas/*.json against their example payloads
schema-check:
python3 test/schema_check.py
## validate: build and run the accuracy validation against the database
validate: build-validate
./$(BIN)/validate
## clean: remove compiled binaries
clean:
rm -rf $(BIN)