Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ dist

# TernJS port file
.tern-port

bin/
build/
80 changes: 80 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
SHELL := /bin/bash
.DEFAULT_GOAL := generate

BIN = $(CURDIR)/bin
BUILD_DIR = $(CURDIR)/build

GOPATH = $(HOME)/go
GOBIN = $(GOPATH)/bin
GO ?= GOGC=off $(shell which go)
NODE ?= $(shell which node)
PNPM ?= $(shell which pnpm)
PKGS = $(or $(PKG),$(shell env $(GO) list ./...))
VERSION ?= $(shell git describe --tags --always --match=v*)
SHORT_COMMIT ?= $(shell git rev-parse --short HEAD)

PATH := $(GOBIN):$(BIN):$(PATH)

EMBEDDED =
LDFLAGS = -w -s -X "github.com/lunogram/platform/pkg/build.version=$(VERSION)" -X "github.com/lunogram/platform/pkg/build.commit=$(SHORT_COMMIT)"

# Printing
V ?= 0
Q = $(if $(filter 1,$V),,@)
M = $(shell printf "\033[34;1m▶\033[0m")

$(BUILD_DIR):
@mkdir -p $@

# Tools
$(BIN):
@mkdir -p $@
$(BIN)/%: | $(BIN) ; $(info $(M) building $(@F)…)
$Q GOBIN=$(BIN) $(GO) install $(shell $(GO) list tool | grep $(@F))

$(EMBEDDED):
$Q mkdir -p $(shell dirname $@)
$Q touch $@

GOLANGCI_LINT = $(BIN)/golangci-lint
STRINGER = $(BIN)/stringer
MINIMOCK = $(BIN)/minimock
OAPI_CODEGEN = $(BIN)/oapi-codegen

TOOLCHAIN = $(STRINGER) $(MINIMOCK) $(OAPI_CODEGEN)

# Targets
.PHONY: lint
lint: | $(EMBEDDED) $(GOLANGCI_LINT) $(BUF) ; $(info $(M) running linters…) @ ## Run the project linters
$Q $(GOLANGCI_LINT) run --max-issues-per-linter 10 --timeout 5m

.PHONY: test
test: | $(EMBEDDED) ; $(info $(M) running tests) @ ## Run all tests
$Q $(GO) test $(PKGS) -timeout 300s -race -count 1

.PHONY: test-short
test-short: | $(EMBEDDED) ; $(info $(M) running short tests) @ ## Run all short tests
$Q $(GO) test $(PKGS) -timeout 120s -race -count 1 -short

.PHONY: fmt
fmt: | $(EMBEDDED) ; $(info $(M) running go fmt…) @ ## Run gofmt on all source files
$Q $(GO) fmt $(PKGS)

.PHONY: generate
generate: | $(EMBEDDED) $(TOOLCHAIN) ; $(info $(M) running go generate…) @ ## Run gogenerate on all source files
$Q $(GO) generate $(PKGS)
$Q $(MAKE) fmt

.PHONY: clean
clean: ; $(info $(M) cleaning…) @ ## Cleanup everything
@rm -rf $(BIN)
@rm -rf $(BUILD)
@find . -name '*_mock_test.go' -exec rm -r {} \;
@find . -name '*_string.go' -exec rm -r {} \;
@find . -name '*_gen.go' -exec rm -r {} \;
@find . -name '*.sql.go' -exec rm -r {} \;

.PHONY: help
help:
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
201 changes: 0 additions & 201 deletions docker-compose.yml

This file was deleted.

Loading