From faa77e7970c4c18370cc562dc7d13d15890b0e1d Mon Sep 17 00:00:00 2001 From: Laurent Le Houerou Date: Thu, 21 Mar 2024 06:33:44 +0000 Subject: [PATCH] create Makefile for build & test tasks --- Makefile | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..452e84c --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +BINARY_NAME=bin/sorarebuddy + +BIN_DIR=$(shell dirname $(BINARY_NAME)) +include .env +export $(shell sed 's/=.*//' .env) + +ensure-bin-dir: + @mkdir -p $(BIN_DIR) + +build: ensure-bin-dir + @echo "Building..." + go build -o $(BINARY_NAME) cmd/console/root.go + +run: build + @echo "Running..." + $(info JWTTOKEN is $(JWTTOKEN)) + $(info JWTAUDIENCE is $(JWTAUDIENCE)) + ./$(BINARY_NAME) --jwtaudience $(JWTAUDIENCE) --jwttoken $(JWTTOKEN) --dbhost $(DBHOST) --dbport $(DBPORT) --dbuser $(DBUSER) --dbpass $(DBPASS) --dbname $(DBNAME) --verbose + +clean: + @echo "Cleaning..." + go clean + rm -f $(BINARY_NAME) + +resetdb: + goose -dir ./db/migrations postgres "host=$(DBHOST) port=$(DBPORT) user=$(DBUSER) password=$(DBPASS) dbname=$(DBNAME) sslmode=disable" down + goose -dir ./db/migrations postgres "host=$(DBHOST) port=$(DBPORT) user=$(DBUSER) password=$(DBPASS) dbname=$(DBNAME) sslmode=disable" up + goose -dir ./db/migrations postgres "host=$(DBHOST) port=$(DBPORT) user=$(DBUSER) password=$(DBPASS) dbname=$(DBNAME) sslmode=disable" status + +.PHONY: build run clean ensure-bin-dir resetdb +.DEFAULT_GOAL := all +all: build run clean ensure-bin-dir +