Strings
Some checks failed
Build / build (push) Failing after 1m35s
Test / build (push) Failing after 1m31s

This commit is contained in:
Chuck Smith
2024-02-21 16:29:53 -05:00
parent 8caeaca559
commit e4bca02235
5 changed files with 189 additions and 5 deletions

93
Makefile Normal file
View File

@@ -0,0 +1,93 @@
.PHONY: dev build cli server install image release profile compare bench test clean
CGO_ENABLED=0
VERSION ?= $(shell git describe 2>/dev/null || echo "")
DESTDIR ?= $(GOBIN)
ifeq ($(LOCAL), 1)
IMAGE := r.mills.io/prologic/monkey
TAG := dev
else
ifeq ($(BRANCH), master)
IMAGE := prologic/monkey
TAG := latest
else
IMAGE := prologic/monkey
TAG := dev
endif
endif
all: help
help: ## Show this help message
@echo "monkey - Monkey Lang"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
dev: cli ## Build monkey and run the REPL
@./monkey
build: clean cli server ## Build monkey
cli: ## Build monkey CLI
@go build \
-tags "netgo static_build" -installsuffix netgo \
-ldflags "-w -X go.mills.io/monkey/v2.MonkeyVersion=$(VERSION)" \
./cmd/monkey/...
server: ## Build Monkey server
@go build \
-tags "netgo static_build" -installsuffix netgo \
-ldflags "-w -X go.mills.io/monkey/v2.MonkeyVersion=$(VERSION)" \
./cmd/monkey-server/...
install: cli server ## Install monkey to $DESTDIR
@install -D -m 755 monkey $(DESTDIR)/monkey
@install -D -m 755 monkey-server $(DESTDIR)monkey-server
ifeq ($(PUBLISH), 1)
image: ## Build and Publish the Docker image
@docker buildx build \
--build-arg VERSION="$(VERSION)" \
--build-arg COMMIT="$(COMMIT)" \
--build-arg BUILD="$(BUILD)" \
--platform linux/amd64,linux/arm64 --push -t $(IMAGE):$(TAG) .
else
image: ## Build the Docker image
@docker build \
--build-arg VERSION="$(VERSION)" -t $(IMAGE):$(TAG) .
endif
release: ## Release monkey
@./tools/release.sh
profile: ## Run tests with profiling enabled
@go test -cpuprofile cpu.prof -memprofile mem.prof -v -bench ./...
compare: ## Run benchmarks comparing Monkey with other languages
@hyperfine -w 5 -p 'make build; gcc -o examples/fib examples/fib.c' \
-n c -n go -n tengo -n python -n tauc -n taugo -n monkey \
--sort mean-time --export-markdown Benchmark.md \
'./examples/fib' \
'go run examples/fib.go' \
'tengo examples/fib.tengo' \
'python3 examples/fib.py' \
'tauc examples/fib.tau' \
'taugo examples/fib.tau' \
'./monkey examples/fib.m'
bench: # Run test benchmarks
@go test -v -benchmem -bench=. ./...
test: ## Run unit tests
@go test -v \
-cover \
-coverprofile coverage.out \
-covermode atomic \
-coverpkg ./... \
-race \
./...
clean: ## Cleanup untrakced files
@git clean -f -d -X 2> /dev/null || true