Skip to content

Commit

Permalink
docs: contribution guide & makefile (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
estahn committed Aug 16, 2021
1 parent 9558e6f commit 675de88
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Expand Up @@ -30,3 +30,4 @@ repos:
hooks:
- id: go-mod-tidy
- id: go-fmt
- id: go-imports
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -10,9 +10,12 @@ By participating to this project, you agree to abide our
Prerequisites:

- `make`
- [Go 1.15+](https://golang.org/doc/install)
- [Go 1.16+](https://golang.org/doc/install)
- [golangci-lint](https://golangci-lint.run/usage/install/#local-installation)
- [Docker](https://www.docker.com/) (or [Podman](https://podman.io/))
- [kind](https://kind.sigs.k8s.io/)
- [pre-commit](https://pre-commit.com/) (optional)
- [ngrok](https://ngrok.com/) (optional)

Clone `k8s-image-swapper` anywhere:

Expand All @@ -37,13 +40,13 @@ make test
You can create a branch for your changes and try to build from the source as you go:

```sh
make build
make test
```

When you are satisfied with the changes, we suggest you run:

```sh
make ci
make fmt lint test
```

Which runs all the linters and tests.
Expand Down
29 changes: 29 additions & 0 deletions Makefile
@@ -0,0 +1,29 @@
SOURCE_FILES?=./...
TEST_PATTERN?=.
TEST_OPTIONS?=

.PHONY: help $(MAKECMDGOALS)
.DEFAULT_GOAL := help

export GO111MODULE := on
export GOPROXY = https://proxy.golang.org,direct

help: ## List targets & descriptions
@cat Makefile* | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

setup: ## Install dependencies
go mod download
go mod tidy

test: ## Run tests
LC_ALL=C go test $(TEST_OPTIONS) -failfast -race -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt $(SOURCE_FILES) -run $(TEST_PATTERN) -timeout=5m

cover: test ## Run tests and open coverage report
go tool cover -html=coverage.txt

fmt: ## gofmt and goimports all go files
gofmt -l -w .
goimports -l -w .

lint: ## Run linters
golangci-lint run

0 comments on commit 675de88

Please sign in to comment.