@@ -33,23 +33,35 @@ gopath := shell("go env GOPATH")
3333mockgen-exe := gopath / " bin" / " mockgen"
3434nancy-exe := gopath / " bin" / " nancy"
3535
36- # Show this help and exit.
37- default :
38- @ just --list --list-prefix $ ' {{ BOLD }}{{ BLUE }} → {{ NORMAL }} ' -- justfile {{ justfile () }} --list-heading $ ' {{ BOLD }}{{ CYAN }} ◉ {{ YELLOW }}{{ app-id }}{{ CYAN }} dev console {{ NORMAL }} \n'
36+
37+ [ private ]
38+ default : help
3939
4040# Compile an executable binary
41- bin :
41+ build- bin:
4242 @ mkdir -p {{ bin-dir}}
4343 go mod tidy
4444 CGO_ENABLED={{ cgo-enabled}} go build -ldflags ' {{ ld-flags}} ' -o {{ bin-path}}
4545
46+ # Build a docker image and load it into a running daemon
47+ build-img :
48+ nix build .#dockerArchiveStreamer && ./result | docker image load
49+
4650# Remove all build artifacts
4751clean :
4852 @ rm -f bin/ * coverage.html .coverage.out .junit.xml {{ dev-db-file}} result
4953 - @docker rmi ghcr.io/ bow/ {{ app-id}} 2 > / dev/ null
5054
51- # Install dependencies for local development
52- dev :
55+ # Apply gofmt
56+ fmt :
57+ go fmt ./ ...
58+
59+ # Show this help and exit.
60+ help :
61+ @ just --list --list-prefix $' {{ BOLD }}{{ BLUE }} →{{ NORMAL }} ' --justfile {{ justfile ()}} --list-heading $' {{ BOLD }}{{ CYAN }} ◉ {{ YELLOW }}{{ app-id}}{{ CYAN }} dev console{{ NORMAL }} \n'
62+
63+ # Install dependencies for local development not yet in Nix
64+ install-dev :
5365 #!/usr/bin/env bash
5466 if command -v nix-env > / dev/ null && command -v direnv > / dev/ null; then
5567 printf " Configuring a local dev environment...\n " >&2 \
6577 printf " Error: both direnv and nix seem to be unconfigured and/or missing" >&2 && exit 1
6678 fi
6779
68- # Apply gofmt
69- fmt :
70- go fmt ./ ...
71-
72- # Build a docker image and load it into a running daemon
73- img :
74- nix build .#dockerArchiveStreamer && ./result | docker image load
75-
7680# Lint the code
7781lint :
7882 golangci-lint run
7983
8084# Generate mocks from interfaces
81- mocks :
85+ gen- mocks:
8286 #!/ usr/ bin/ env -S parallel --shebang --ungroup --jobs {{ num_cpus () }}
8387 {{ mockgen-exe}} -source=internal/ datastore/ parser.go -package=datastore Parser > internal/ datastore/ parser_mock_test.go
8488 {{ mockgen-exe}} -source=internal/ datastore/ datastore.go -package=server Datastore > internal/ server/ datastore_mock_test.go
8892 {{ mockgen-exe}} -source=api/ neon_grpc.pb.go -package=backend NeonClient > internal/ reader/ backend/ client_mock_test.go
8993
9094# Generate code from protobuf
91- protos :
95+ gen- protos:
9296 protoc \
9397 - I={{ proto-dir}} \
9498 - -go_opt=Mneon.proto=" {{ repo-name}} /api;api" \
@@ -109,22 +113,29 @@ scan-sec-ast:
109113 gosec -exclude=G304 ./ ...
110114
111115# Compile the binary and run the server in development mode
112- serve db = (dev-db-file): bin
116+ serve db = (dev-db-file): build- bin
113117 {{ bin-path}} server --db-path {{ db}}
114118
115119# Run the test suite
116- test : mocks coverage-out
120+ test : gen- mocks test-cov
117121
118122[private ]
119- coverage-out :
123+ test-cov :
120124 gotestsum --format dots-v2 --junitfile .junit.xml -- ./ ... -coverprofile=.coverage.out.all -covermode=atomic -coverpkg ./ internal/ ...,./ cmd/ ...,./ api,./ .
121125 @ grep -v " _mock_test.go" .coverage.out.all | grep -v " /api/" > .coverage.out
122126 @ go tool cover -func=.coverage.out
123127
124128# Run the test suite and output coverage to XML
125- test-cov-xml : coverage-out
129+ test-cov-xml : test-cov
126130 gocover-cobertura < .coverage.out > .coverage.xml
127131
128132# Run the test suite and output coverage to HTML
129- test-cov-html : coverage-out
133+ test-cov-html : test-cov
130134 go tool cover -html=.coverage.out -o coverage.html
135+
136+ # Update dependencies and nix flake
137+ update :
138+ nix flake update
139+ go get -u ./ ...
140+ go mod tidy
141+ gomod2nix
0 commit comments