SHELL := /usr/bin/env bash
GO ?= go
ZOLA ?= zola
BINARY ?= bin/clusterlog

.PHONY: all build test vet e2e theme sync sync-check validate validate-local site serve smoke ci clean

all: build

build:
	mkdir -p $(dir $(BINARY))
	$(GO) build -trimpath -o $(BINARY) ./cmd/clusterlog

test:
	$(GO) test ./...

vet:
	$(GO) vet ./...

e2e: build
	./scripts/e2e-local.sh

theme:
	./scripts/bootstrap-theme.sh

sync: build
	./$(BINARY) --root . sync

sync-check: build
	./$(BINARY) --root . sync --check

validate: build
	./$(BINARY) --root . validate --require-zola

validate-local: build
	./$(BINARY) --root . validate --skip-zola

site: theme sync validate
	$(ZOLA) build

serve: theme sync
	$(ZOLA) serve --interface 127.0.0.1

smoke: build
	./scripts/smoke.sh

ci: theme test vet e2e build sync sync-check validate
	$(ZOLA) build

clean:
	rm -rf bin public themes/zola.386
