-
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (100 loc) · 3.7 KB
/
Makefile
File metadata and controls
129 lines (100 loc) · 3.7 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
NAME=process-compose
RM=rm
#VERSION = v0.51.0
VERSION = $(shell git describe --abbrev=0)
GIT_REV ?= $(shell git rev-parse --short HEAD)
DATE ?= $(shell TZ=UTC0 git show --quiet --date='format-local:%Y-%m-%dT%H:%M:%SZ' --format="%cd")
NUMVER = $(shell echo ${VERSION} | cut -d"v" -f 2)
NIX_VERSION = $(shell sed -n '7p' default.nix | grep -oP '[0-9]+\.[0-9]+\.[0-9]+')
PKG = github.com/f1bonacc1/${NAME}
SHELL := /usr/bin/env bash
PROJ_NAME := Process Compose
DOCS_DIR := www/docs/cli
LD_FLAGS := -ldflags="-X ${PKG}/src/config.Version=${VERSION} \
-X ${PKG}/src/config.CheckForUpdates=true \
-X ${PKG}/src/config.Commit=${GIT_REV} \
-X ${PKG}/src/config.Date=${DATE} \
-X '${PKG}/src/config.ProjectName=${PROJ_NAME} 🔥' \
-X '${PKG}/src/config.RemoteProjectName=${PROJ_NAME} ⚡' \
-s -w"
ifeq ($(OS),Windows_NT)
EXT=.exe
RM = cmd /C del /Q /F
endif
.PHONY: test run testrace docs schema check-nix-version
buildrun: build run
setup:
go mod download
ci: setup build testrace lint build-nix
swag: swag2op ## Generate docs from swagger attributes in the code
./bin/swag2op init --dir src --output src/docs -g api/pc_api.go --openapiOutputDir src/docs --parseDependency --parseInternal
build:
CGO_ENABLED=0 go build -o bin/${NAME}${EXT} ${LD_FLAGS} ./
build-nix:
nix build .
nixver:
sed -i 's/version = ".*"/version = "${NUMVER}"/' default.nix
nix-update-hash:
./scripts/update-vendor-hash.sh
build-pi:
GOOS=linux GOARCH=arm go build ${LD_FLAGS} -o bin/${NAME}-linux-arm ./
compile:
for arch in amd64 386 arm64 arm; do \
GOOS=linux GOARCH=$$arch go build ${LD_FLAGS} -o bin/${NAME}-linux-$$arch ./ ; \
done;
for arch in amd64 arm64; do \
GOOS=darwin GOARCH=$$arch go build ${LD_FLAGS} -o bin/${NAME}-darwin-$$arch ./ ; \
done;
for arch in amd64 arm64; do \
GOOS=windows GOARCH=$$arch go build ${LD_FLAGS} -o bin/${NAME}-windows-$$arch.exe ./ ; \
done;
test:
go test -cover ./...
testrace:
go test -race ./...
testrace-clean:
go clean -testcache && go test -race ./...
coverhtml:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
run:
PC_DEBUG_MODE=1 ./bin/${NAME}${EXT} -e .env
clean:
$(RM) bin/${NAME}*
check-nix-version:
@if [ "$(NUMVER)" != "$(NIX_VERSION)" ]; then \
echo "ERROR: git tag version ($(NUMVER)) does not match default.nix version ($(NIX_VERSION))"; \
exit 1; \
fi
release: check-nix-version
source exports
goreleaser release --clean --skip validate --auto-snapshot
snapshot:
goreleaser release --snapshot --clean
github-workflows:
act -W ./.github/workflows/go.yml -j build --matrix os:ubuntu-latest
act -W ./.github/workflows/nix.yml -j build
docs: build
./bin/process-compose docs ${DOCS_DIR}
for f in ${DOCS_DIR}/*.md ; do sed -i 's/${USER}/<user>/g; s|${TMPDIR}|/tmp/|g; s/process-compose-[0-9]\+.sock/process-compose-<pid>.sock/g' $$f ; done
schema:
./bin/process-compose schema ./schemas/process-compose-schema.json
lint: golangci-lint
./bin/golangci-lint run --show-stats -c .golangci.yaml
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
## Tool Binaries
SWAG2OP_GEN ?= $(LOCALBIN)/swag2op
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
.PHONY: swag2op
swag2op: $(SWAG2OP_GEN) ## Download swag2op locally if necessary.
$(SWAG2OP_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/swag2op || \
GOBIN=$(LOCALBIN) go install github.com/zxmfke/swagger2openapi3/cmd/swag2op@latest
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || \
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.3