Skip to content
quarry Artifact [5682bc9eee]
Login

Artifact [5682bc9eee]

Artifact 5682bc9eee458549d0391b89bba10e96a08679388327dbabe40577da52415a16:


# Local gates — run before every commit. CI (dagnats, later) runs the same.
.PHONY: check test vet build fixtures fixtures-real spec-lint docs dev

check: vet test build

# Spec correctness gate (0003 §2): lint the generated OpenAPI document with
# an off-the-shelf validator. Dev/CI tool only — never a runtime dep.
spec-lint:
	go run ./cmd/quarry spec > /tmp/quarry-spec.json
	go run github.com/daveshanley/[email protected] lint --no-banner --no-style --fail-severity error /tmp/quarry-spec.json

# API reference, generated from the op registry (0003: docs are a phase
# exit criterion). TestDocsCurrent fails the build when this is stale.
docs:
	go run ./cmd/quarry docs > docs/api.md

# Synthetic disposability fixture (fast; the CI corpus).
fixtures:
	fixtures/build-synthetic.sh

# Real corpus (sqlite, tcl) — large clones, opt-in.
fixtures-real:
	fixtures/build-real.sh

test:
	go test ./...

vet:
	go vet ./...

build:
	go build ./...

# Third-party licence inventory served at /licenses.
licenses:
	go run ./cmd/licensegen > internal/legal/licenses.json

# Dev loop: rebuild and restart the server whenever a .go file changes
# (wgo: go install github.com/bokwoon95/wgo@latest).
#
# Per-machine settings come from .env.local, which is not committed; copy
# .env.example to start one. dev.local.mk is the previous name and is
# still read, so an existing checkout keeps working.
-include .env.local
-include dev.local.mk

# Each corpus repository is named once in QUARRY_CORPUS_REPOS and its path
# derived, rather than repeating --repo name=path twenty-odd times.
corpus_repo_flags = $(foreach r,$(QUARRY_CORPUS_REPOS),--repo $(r)=$(QUARRY_CORPUS)/$(r))
extra_repo_flags  = $(foreach r,$(QUARRY_EXTRA_REPOS),--repo $(r))

# Only the settings that were given become flags: an empty key is left out
# entirely rather than passed as an empty string, which the server would
# read as a deliberate value.
optional = $(if $(2),--$(1) $(2))

# ?= so a .env.local that still sets DEV_ARGS wholesale keeps winning.
DEV_ARGS ?= \
	$(call optional,addr,$(QUARRY_ADDR)) \
	$(call optional,data,$(QUARRY_DATA)) \
	$(call optional,oltp,$(QUARRY_OLTP)) \
	$(call optional,repos-root,$(QUARRY_REPOS_ROOT)) \
	$(call optional,tracker,$(QUARRY_TRACKER)) \
	$(call optional,dagnats,$(QUARRY_DAGNATS)) \
	$(call optional,notify,$(QUARRY_NOTIFY)) \
	$(call optional,notify-key,$(QUARRY_NOTIFY_KEY)) \
	$(call optional,errorlog,$(QUARRY_ERRORLOG)) \
	$(corpus_repo_flags) \
	$(extra_repo_flags)

dev:
	wgo run ./cmd/quarry serve $(DEV_ARGS)

# Print the composed flags without running anything — the fastest way to
# see what .env.local actually amounts to.
dev-args:
	@echo $(DEV_ARGS)