-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (68 loc) · 3.82 KB
/
Makefile
File metadata and controls
95 lines (68 loc) · 3.82 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
SHELL = /usr/bin/env bash -o pipefail
# We use ifeq instead of ?= so that we set variables
# also when they are defined, but empty.
ifeq ($(VERSION),)
VERSION = `git describe --tags --always --dirty=+`
endif
ifeq ($(BUILD_TIMESTAMP),)
BUILD_TIMESTAMP = `date -u +%FT%TZ`
endif
ifeq ($(REVISION),)
REVISION = `git rev-parse HEAD`
endif
.PHONY: build peerdb build-static lib test test-ci lint lint-ci fmt fmt-ci upgrade clean release lint-docs lint-docs-ci audit encrypt decrypt sops watch
build: peerdb
peerdb: dist
go build -trimpath -ldflags "-s -w -X gitlab.com/tozd/go/cli.Version=${VERSION} -X gitlab.com/tozd/go/cli.BuildTimestamp=${BUILD_TIMESTAMP} -X gitlab.com/tozd/go/cli.Revision=${REVISION}" -o $@ gitlab.com/peerdb/peerdb/cmd/$@
build-static: dist
go build $(PEERDB_BUILD_FLAGS) -trimpath -ldflags "-s -w -linkmode external -extldflags '-static' -X gitlab.com/tozd/go/cli.Version=${VERSION} -X gitlab.com/tozd/go/cli.BuildTimestamp=${BUILD_TIMESTAMP} -X gitlab.com/tozd/go/cli.Revision=${REVISION}" -o peerdb gitlab.com/peerdb/peerdb/cmd/peerdb
dist: dist/index.html dist/assets dist/LICENSE.txt dist/NOTICE.txt dist/robots.txt
dist/index.html dist/assets dist/LICENSE.txt dist/NOTICE.txt dist/robots.txt: node_modules src vite.config.ts tsconfig.json tsconfig.node.json LICENSE
find dist -mindepth 1 ! -path "dist/dist.go" -delete
npm run build
lib: node_modules src vite.config.lib.ts tsconfig.json tsconfig.node.json LICENSE
npm run build-lib
node_modules: package-lock.json
package-lock.json: package.json
npm install
# We use -p 1 to run only one package test and thus test process at a time. This allows us to control the number of
# connections made to a PostgreSQL service to not hit the limit of connections to it. If multiple test processes run
# in parallel, then our current logic where we track connections and pools inside one process is not enough.
test:
gotestsum --format pkgname --packages ./... -- -p 1 -race -timeout 10m -cover -covermode atomic
test-ci:
gotestsum --format pkgname --packages ./... --junitfile tests.xml -- -p 1 -race -timeout 10m -coverprofile=coverage.txt -covermode atomic
gocover-cobertura < coverage.txt > coverage.xml
go tool cover -html=coverage.txt -o coverage.html
lint:
golangci-lint run --output.text.colors --allow-parallel-runners --fix
lint-ci:
golangci-lint run --output.text.path=stdout --output.code-climate.path=codeclimate.json
fmt:
go mod tidy
git ls-files --cached --modified --other --exclude-standard -z | grep -z -Z '.go$$' | xargs -0 gofumpt -w
git ls-files --cached --modified --other --exclude-standard -z | grep -z -Z '.go$$' | xargs -0 goimports -w -local gitlab.com/peerdb/peerdb
fmt-ci: fmt
git diff --exit-code --color=always
upgrade:
go run github.com/icholy/gomajor@v0.13.2 get all
go mod tidy
clean:
find dist -mindepth 1 ! -path "dist/dist.go" -delete
rm -rf coverage.* codeclimate.json tests.xml coverage lib peerdb
release:
npx --yes --package 'release-it@19.0.5' --package '@release-it/keep-a-changelog@7.0.0' -- release-it
lint-docs:
npx --yes --package 'markdownlint-cli@~0.45.0' -- markdownlint --ignore-path .gitignore --ignore testdata/ --fix '**/*.md'
lint-docs-ci: lint-docs
git diff --exit-code --color=always
audit:
go list -json -deps ./... | nancy sleuth --skip-update-check
encrypt:
gitlab-config sops --encrypt --mac-only-encrypted --in-place --encrypted-comment-regex sops:enc .gitlab-conf.yml
decrypt:
SOPS_AGE_KEY_FILE=keys.txt gitlab-config sops --decrypt --in-place .gitlab-conf.yml
sops:
SOPS_AGE_KEY_FILE=keys.txt gitlab-config sops .gitlab-conf.yml
watch:
CompileDaemon -build="make --silent peerdb" -command="./peerdb -D -k localhost+2.pem -K localhost+2-key.pem" -include="*.tmpl" -include="*.json" -include="go.mod" -include="go.sum" -exclude-dir=.git -exclude-dir=.cache -exclude-dir=output -graceful-kill=true -log-prefix=false -color=true