-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
45 lines (35 loc) · 1.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
PORT ?= 3000
IMAGE ?= opbeans/opbeans-node
VERSION ?= latest
LTS_ALPINE ?= 20-alpine
AGENT_VERSION=$(shell npm ls --package-lock-only elastic-apm-node --json | jq -r '.dependencies."elastic-apm-node".version')
.DEFAULT_GOAL := help
help: ## Display this help text
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
all: build test
build: ## Build docker image
@docker build --file Dockerfile --tag=${IMAGE}:${VERSION} .
bats: ## Install bats in the project itself
@git clone https://github.com/sstephenson/bats.git
prepare-test: bats ## Prepare the bats dependencies
@docker pull node:${LTS_ALPINE}
@mkdir -p target
@git submodule sync
@git submodule update --init --recursive
test: prepare-test ## Run the tests
@echo "Tests are in progress, please be patient"
@PORT=${PORT} bats/bin/bats --tap tests | tee target/results.tap
@docker run --rm -v "${PWD}":/usr/src/app -w /usr/src/app node:${LTS_ALPINE} \
sh -c "npm install tap-xunit -g && cat target/results.tap | tap-xunit --package='co.elastic.opbeans' > target/junit-results.xml"
publish: build ## Publish docker image
@docker push "${IMAGE}:${VERSION}"
clean: ## Clean autogenerated files/folders
@rm -rf bats
@rm -rf target
create-release: ## Create github release given the APM Agent version if no tag release
@if [ -z "$(shell git tag -l v$(AGENT_VERSION))" ]; then \
echo "creating tag v$(AGENT_VERSION)"; \
gh release create "v$(AGENT_VERSION)" --title="$(AGENT_VERSION)" --generate-notes; \
else \
echo "git tag $(AGENT_VERSION) already exists"; \
fi