forked from stateful/runme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (71 loc) · 2.27 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
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
SHELL := /bin/bash
GO_ROOT := $(shell go env GOROOT)
GIT_SHA := $(shell git rev-parse HEAD)
GIT_SHA_SHORT := $(shell git rev-parse --short HEAD)
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
VERSION := $(shell git describe --tags)-$(GIT_SHA_SHORT)
LDFLAGS := -s -w \
-X 'github.com/stateful/runme/internal/version.BuildDate=$(DATE)' \
-X 'github.com/stateful/runme/internal/version.BuildVersion=$(subst v,,$(VERSION))' \
-X 'github.com/stateful/runme/internal/version.Commit=$(GIT_SHA)'
.PHONY: build
build:
go build -o runme -ldflags="$(LDFLAGS)" main.go
.PHONY: wasm
wasm: WASM_OUTPUT ?= examples/web
wasm:
cp $(GO_ROOT)/misc/wasm/wasm_exec.js $(WASM_OUTPUT)
GOOS=js GOARCH=wasm go build -o $(WASM_OUTPUT)/runme.wasm -ldflags="$(LDFLAGS)" ./web
.PHONY: test
test: build
@TZ=UTC go test ./...
.PHONY: test/update-snapshots
test/update-snapshots:
@TZ=UTC UPDATE_SNAPSHOTS=true go test ./...
.PHONY: test/robustness
test/robustness:
@cd integration/subject && npm install --include=dev
find . -name "README.md" | grep -v "\/\." | xargs dirname | uniq | xargs -n1 -I {} ./runme fmt --chdir {} > /dev/null
.PHONY: fmt
fmt:
@gofumpt -w .
.PHONY: lint
lint:
@revive -config revive.toml -formatter stylish ./...
.PHONY: install/dev
install/dev:
go install github.com/mgechev/[email protected]
go install github.com/securego/gosec/v2/cmd/[email protected]
go install honnef.co/go/tools/cmd/[email protected]
go install mvdan.cc/[email protected]
go install github.com/icholy/[email protected]
.PHONY: install/goreleaser
install/goreleaser:
go install github.com/goreleaser/[email protected]
.PHONY: proto/generate
proto/generate:
buf lint
buf format -w
buf generate
.PHONY: proto/clean
proto/clean:
rm -rf internal/gen/proto
# Remember to set up buf registry beforehand.
# More: https://docs.buf.build/bsr/authentication
.PHONY: proto/publish
proto/publish:
@cd ./internal/api && buf push
.PHONY: release
release: install/goreleaser
@goreleaser check
@goreleaser release --snapshot --clean
.PHONY: release/publish
release/publish: install/goreleaser
@goreleaser release
.PHONY: update-gql-schema
update-gql-schema:
@go run ./cmd/gqltool/main.go > ./client/graphql/schema/introspection_query_result.json
@cd ./client/graphql/schema && npm run convert
.PHONY: generate
generate:
go generate ./...