Skip to content

Commit be1a47d

Browse files
00x-dxrootulp
andauthoredJan 30, 2024
chore(makefile): add lint, test, & benchmark commands. (celestiaorg#29)
Co-authored-by: Rootul Patel <[email protected]>
1 parent 1e9e439 commit be1a47d

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed
 

‎Makefile

+27-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,39 @@
11
DOCKER := $(shell which docker)
22
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.28.1
3+
PROJECTNAME=$(shell basename "$(PWD)")
34

4-
## proto-gen-docker: Generate protobuf files. Requires docker.
5+
## help: Get more info on make commands.
6+
help: Makefile
7+
@echo " Choose a command run in "$(PROJECTNAME)":"
8+
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
9+
.PHONY: help
10+
11+
## proto-gen: Generate protobuf files. Requires docker.
512
proto-gen:
613
@echo "--> Generating Protobuf files"
714
$(DOCKER_BUF) generate
815
.PHONY: proto-gen-docker
916

10-
## proto-lint-docker: Lint protobuf files. Requires docker.
17+
## proto-lint: Lint protobuf files. Requires docker.
1118
proto-lint:
1219
@echo "--> Linting Protobuf files"
1320
@$(DOCKER_BUF) lint
1421
.PHONY: proto-lint
22+
23+
## lint: Lint Go files. Requires golangci-lint.
24+
lint:
25+
@echo "--> Lint source code using golangci-lint"
26+
@golangci-lint run
27+
.PHONY: lint
28+
29+
## test: Run unit tests.
30+
test:
31+
@echo "--> Run unit tests"
32+
@go test -mod=readonly ./...
33+
.PHONY: test
34+
35+
## benchmark: Run tests in benchmark mode.
36+
benchmark:
37+
@echo "--> Perform benchmark"
38+
@go test -mod=readonly -bench=. ./...
39+
.PHONY: benchmark

‎README.md

+19
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,26 @@ Pull requests are welcome. For major changes, please open an issue first to disc
1616

1717
This repo attempts to conform to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) so PR titles should ideally start with `fix:`, `feat:`, `build:`, `chore:`, `ci:`, `docs:`, `style:`, `refactor:`, `perf:`, or `test:` because this helps with semantic versioning and changelog generation. It is especially important to include an `!` (e.g. `feat!:`) if the PR includes a breaking change.
1818

19+
### Tools
20+
1921
1. Install [Go](https://golang.org/doc/install) 1.21.5
22+
1. Install [golangci-lint](https://golangci-lint.run/usage/install/)
2023
1. Fork this repo
2124
1. Make your changes
2225
1. Submit a pull request
26+
27+
### Helpful Commands
28+
29+
```sh
30+
# Display all available make commands
31+
make help
32+
33+
# Run tests
34+
make test
35+
36+
# Run linter
37+
make lint
38+
39+
# Perform benchmarking
40+
make bench
41+
```

0 commit comments

Comments
 (0)
Please sign in to comment.