-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
71 lines (48 loc) · 2.03 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
#
# Prepare openapi files and run projects in containers.
#
YAML=$(shell find * -name \*yaml)
YAMLSRC=$(shell find openapi -name \*yaml.src)
YAMLGEN=$(patsubst %.yaml.src,%.yaml,$(YAMLSRC))
ECHO_GEN=generated/github.com/teamdigitale/api-starter-kit-go/api/api-types.gen.go generated/github.com/teamdigitale/api-starter-kit-go/api/api-server.gen.go
CHI_GEN=generated/github.com/teamdigitale/api-starter-kit-go/api/api-types.gen.go generated/github.com/teamdigitale/api-starter-kit-go/api/api-server-chi.gen.go
yaml: $(YAMLGEN)
.ONESHELL:
%.yaml: %.yaml.src
tox -e yamllint -- -d relaxed $<
tox -e yaml 2>/dev/null -- $< $@
yamllint: $(YAML)
tox -e yamllint -- $<
%-types.gen.go: openapi/simple.yaml
oapi-codegen -package api --generate types -o $@ $<
sed -i -e 's,*string,string,g' -e 's,*int32,int32,g' -e 's,*time.Time,time.Time,g' $@
%-server.gen.go: openapi/simple.yaml
oapi-codegen -package api --generate server,spec -o $@ $<
%-server-chi.gen.go: openapi/simple.yaml
oapi-codegen -package api --generate chi-server,spec -o $@ $<
prepare-echo:
mkdir -p generated/github.com/teamdigitale/api-starter-kit-go
cp -rp go-echo/* generated/github.com/teamdigitale/api-starter-kit-go
prepare-chi:
mkdir -p generated/github.com/teamdigitale/api-starter-kit-go
cp -rp go-chi/* generated/github.com/teamdigitale/api-starter-kit-go
echo-gen: prepare-echo $(ECHO_GEN)
chi-gen: prepare-chi $(CHI_GEN)
go-build:
cd generated/github.com/teamdigitale/api-starter-kit-go
go mod init github.com/teamdigitale/api-starter-kit-go
go build
build-chi: clean chi-gen go-build
build-echo: clean echo-gen go-build
run-echo: build-echo
cd generated/github.com/teamdigitale/api-starter-kit-go && go run main.go
run-chi: build-chi
cd generated/github.com/teamdigitale/api-starter-kit-go && go run main.go
test-echo: build-echo
cd generated/github.com/teamdigitale/api-starter-kit-go && go test
test-chi: build-chi
cd generated/github.com/teamdigitale/api-starter-kit-go && go test
clean:
rm -rf generated
reformat:
find . -name *.go -exec gofmt -w {} \;