-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
167 lines (132 loc) · 4.7 KB
/
justfile
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
help:
just --list
# run github actions locally
act:
act
# Parameterized build command for different projects
build app:
@echo "Building binary for {{app}}"
cd {{app}} && CGO_ENABLED=0 GOOS=linux go build -o bin/app
lint: go-lint ts-lint buf-lint
test: go-test ts-test
buf-lint:
buf lint
go-checks: go-lint go-test
ts-checks: ts-lint ts-test
go-coverage-report:
go test -coverprofile=reports/go/coverage.out ./...
go tool cover -func reports/go/coverage.out -o reports/go/coverage.txt
go tool cover -html reports/go/coverage.out -o reports/go/cover.html
go-lint-changed: install-go-tools
@echo Linting recently changed go files
golangci-lint run --fix --new-from-rev=HEAD~1 --config .golangci.yaml
go-lint: install-go-tools
@echo Linting go files
golangci-lint run --fix --config .golangci.yaml --timeout 5m --concurrency 4
go-integration-test: install-go-tools
# these are only meant to be ran within tilt-ci. they require external services like mysql & minio
go test -tags integration ./...
go-test: install-go-tools
@echo Running go tests
go test -short -timeout 30s ./...
ts-lint: install-ts-tools
@echo Linting typescript
cd ui && npm run format
ts-test: install-ts-tools
@echo Running typescript tests
# cd ui && npm run test
ts-build: install-ts-tools
@echo Building typescript
cd ui && npm run build
install-tools: install-go-tools install-ts-tools
# Run CI pipeline. This should be preferred to tilt ci as it creates and destroys the test cluster.
ci: install-tools
ctlptl create cluster kind --registry=ctlptl-registry \
&& \
tilt ci \
&& \
ctlptl delete cluster kind
generate-openapi: install-go-tools
@echo Generating OpenAPI
go install github.com/swaggo/swag/cmd/swag@latest
swag init --parseDependency --parseInternal --dir api --output services/api/docs
generate-api-clients: generate-openapi generate-go-api-client generate-typescript-client generate-k6
@echo Generated API clients
generate-k6:
@echo Generating K6 tests
@echo You will have to modify the generated script.js to work with your API
docker run --rm \
-v "./services/api/docs/swagger.json:/local/swagger.json" \
-v "./k6/tests/openapi:/out" \
openapitools/openapi-generator-cli generate \
-i "/local/swagger.json" \
-g k6 \
-o "/out" \
--skip-validate-spec
# rest
generate-go-api-client:
# https://github.com/OpenAPITools/openapi-generator?tab=readme-ov-file#16---docker
@echo Generating Go API client
docker run \
-v "./services/api/docs/swagger.yaml:/local/swagger.yaml" \
-v "./pkg/clients/api:/out" \
openapitools/openapi-generator-cli \
generate \
-i "/local/swagger.yaml" \
-g go \
-o "/out/" \
-p packageName=client \
-p withGoMod=false
generate-typescript-client: install-ts-tools
@echo Deprecated: generating graphql instead
just generate-graph-ts-client
# mockery test mocks defined in .mockery.yaml
generate-go-mocks:
mockery
# struct to struct data mapping using goverter
generate-go-converters: install-go-tools
@echo Generating converters
go install github.com/jmattheis/goverter/cmd/[email protected]
goverter gen ./internal/goverter
generate-proto:
@echo Generating protobuf
buf generate
go-mod-download:
@echo Download go.mod dependencies
go mod download
install-go-tools: go-mod-download
install-ts-tools:
@echo Installing tools from package.json
cd ui && npm install
setup-asdf:
cut -d\ -f1 .tool-versions|grep -E '^[^#]'|xargs -L1 asdf plugin add
asdf install
setup:
pre-commit install --install-hook
pre-commit install --hook-type commit-msg
@echo Ensure you run "setup-asdf" or install .tool-versions manually
# regenerate the graph server using gqlgen
generate-graph-server:
@echo Generating graph server
go get github.com/99designs/[email protected]
go install github.com/99designs/gqlgen
cd services/graph && gqlgen generate
# download the graphql schema used to generate clients; requires the graph server to be running
generate-graph-schema:
@echo This requires the graph service running in tilt to generate the schema
go get github.com/alexflint/go-arg
go get github.com/suessflorian/gqlfetch
cd tools/graphql-schema && go run main.go
# generate graphql clients (from schema)
generate-graph-clients: generate-graph-golang-client generate-graph-ts-client
echo Generating graphql clients
echo This will fail if the graph service is not running in tilt
generate-graph-golang-client: generate-graph-schema
@echo Generating golang graphql client
go run github.com/Khan/genqlient tools/graphql-golang-client/genqlient.yaml
generate-graph-ts-client: generate-graph-schema
@echo Generating typescript graphql client
@echo This requires the graph service running in tilt to generate the schema
cd ui && npm run graphql-codegen
install-amalgam-cli:
go install ./amalgam-cli/cmd