This repository has been archived by the owner on Jan 9, 2024. It is now read-only.
forked from efixler/scrape
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (51 loc) · 2.19 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
MODULE_NAME := $(shell go list -m)
DOCKER_IMAGE_NAME := ${shell basename ${MODULE_NAME}}-bookworm-slim
CWD := $(shell pwd)
BUILD_DIR := build
SCRAPE_PORT ?= 8080
.DEFAULT_GOAL := build
.PHONY: fmt vet build clean
build: vet ## build the binaries, to the build/ folder (default target)
@echo "Building $(MODULE_NAME)..."
@go build -o $(BUILD_DIR)/ -tags "$(TAGS)" ./cmd/scrape/...
@go build -o $(BUILD_DIR)/ -tags "$(TAGS)" ./cmd/scrape-feed/...
@go build -o $(BUILD_DIR)/ -tags "$(TAGS)" ./cmd/scrape-server/...
clean: ## clean the build directory
@echo "Cleaning $(MODULE_NAME)..."
@rm -rf $(BUILD_DIR)/*
# Docker images pull code from the repo via `go install` so
# we skip the local checks here.
# So - changes to the source base won't show up these dockers
# until they hit the `latest` tag.
# TODO: Add a `docker-build-dev` target that builds a docker
# image with the local source code.
docker-build: ## build the docker image
@echo "Building $(DOCKER_IMAGE_NAME)..."
@docker build --no-cache -t $(DOCKER_IMAGE_NAME) .
docker-run: ## run the docker image, binding to port 8080, or the env value of SCRAPE_PORT
@echo "Running $(DOCKER_IMAGE_NAME)..."
@docker run -d -ti -p 127.0.0.1:$(SCRAPE_PORT):8080 --volume=$(CWD)/docker/data:/scrape_data --rm scrape-bookworm-slim:latest
fmt:
@echo "Running go fmt..."
@go fmt ./...
@go fmt ./cmd/scrape/...
@go fmt ./cmd/scrape-feed/...
@go fmt ./cmd/scrape-server/...
test: ## run the tests
@echo "Running tests..."
@go test -coverprofile=coverage.out ./...
vet: fmt ## fmt, vet, and staticcheck
@echo "Running go vet and staticcheck..."
@go vet ./...
@go vet ./cmd/scrape/...
@go vet ./cmd/scrape-feed/...
@go vet ./cmd/scrape-server/...
@staticcheck ./...
@staticcheck ./cmd/scrape/...
@staticcheck ./cmd/scrape-feed/...
@staticcheck ./cmd/scrape-server/...
cognitive: ## run the cognitive complexity checker
@echo "Running gocognit..."
@gocognit -ignore "_test|testdata" -top 5 .
help: ## show this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% 0-9a-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)