summaryrefslogtreecommitdiff
path: root/Makefile
blob: 643db686203c49804271a09c1bfabd000d0e55d1 (plain)
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
46
47
48
49
50
51
52
53
54
PROJECT_NAME := $(shell basename $(shell pwd))
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
IMAGE_TAG := $(PROJECT_NAME):$(GIT_BRANCH)

.PHONY: clean setup build test run

bin/sparkled:
	@go build -o ./bin/sparkled ./cmd/sparkled/main.go

clean:
	@rm -f ./bin/sparkled
	@go clean -testcache
	@docker image rm -f $(IMAGE_TAG)

setup:
	@mise install
	@go install tool
	@command -v godotenv
	@command -v playwright
	@command -v yamlfmt

build: bin/sparkled

test-unit:
	@go test -shuffle=on ./...

test-integration: build-image
	@IMAGE_TAG=$(IMAGE_TAG) go test -v -tags=integration ./test/integration/...

test: clean test-unit test-integration

build-image:
	@docker build --no-cache --tag $(IMAGE_TAG) .

build-builder-image:
	@docker build --target build --tag $(IMAGE_TAG) .

run: clean build
	@godotenv -f .env.local,.env ./bin/init.sh

run-image: clean build-image
	@docker run --rm --network host --env-file .env.local -p 10000:10000 -p 9901:9901 -p 8080:8080 -it $(IMAGE_TAG)

sh-image: build-builder-image
	@docker run --rm -it $(IMAGE_TAG) /bin/sh

lint:
	@yamlfmt --lint -exclude vendor .

tidy:
	@go get -u ./...
	@go mod tidy
	@go mod vendor
	@yamlfmt -exclude vendor .