Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(makefile): add lint, test, & benchmark commands. #29

Merged
merged 5 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
```
Loading