Skip to content

Commit

Permalink
chore(makefile): add lint, test, & benchmark commands. (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Rootul Patel <[email protected]>
  • Loading branch information
00x-dx and rootulp authored Jan 30, 2024
1 parent 1e9e439 commit be1a47d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
29 changes: 27 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
DOCKER := $(shell which docker)
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.28.1
PROJECTNAME=$(shell basename "$(PWD)")

## proto-gen-docker: Generate protobuf files. Requires docker.
## help: Get more info on make commands.
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
.PHONY: help

## proto-gen: Generate protobuf files. Requires docker.
proto-gen:
@echo "--> Generating Protobuf files"
$(DOCKER_BUF) generate
.PHONY: proto-gen-docker

## proto-lint-docker: Lint protobuf files. Requires docker.
## proto-lint: Lint protobuf files. Requires docker.
proto-lint:
@echo "--> Linting Protobuf files"
@$(DOCKER_BUF) lint
.PHONY: proto-lint

## lint: Lint Go files. Requires golangci-lint.
lint:
@echo "--> Lint source code using golangci-lint"
@golangci-lint run
.PHONY: lint

## test: Run unit tests.
test:
@echo "--> Run unit tests"
@go test -mod=readonly ./...
.PHONY: test

## benchmark: Run tests in benchmark mode.
benchmark:
@echo "--> Perform benchmark"
@go test -mod=readonly -bench=. ./...
.PHONY: benchmark
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ Pull requests are welcome. For major changes, please open an issue first to disc

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.

### Tools

1. Install [Go](https://golang.org/doc/install) 1.21.5
1. Install [golangci-lint](https://golangci-lint.run/usage/install/)
1. Fork this repo
1. Make your changes
1. Submit a pull request

### Helpful Commands

```sh
# Display all available make commands
make help

# Run tests
make test

# Run linter
make lint

# Perform benchmarking
make bench
```

0 comments on commit be1a47d

Please sign in to comment.