diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 75a4ba7b..ea3bb323 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,58 +26,32 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume ## Development Workflow -### Setup +### Requirements -You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml). +- `docker`: for running integration tests and linting +- `easyjson`: for generating type marshalers and unmarshalers +- Retrieve SDK dependencies -Example of running all the checks with docker: -```bash -docker-compose run --rm package bash -c "go get && golangci-lint run -v && go test -v" -``` - -To install dependencies: +You can install these tools and dependencies by using the `make requirements` command. -```bash -go get -v -t -d ./... -``` +### Test -### Tests and Linter +You can run integration test and linter check by command: -Each PR should pass the tests and the linter to be accepted. - -```bash -# Tests -curl -L https://install.meilisearch.com | sh # download Meilisearch -./meilisearch --master-key=masterKey --no-analytics # run Meilisearch -go clean -cache ; go test -v ./... -# Use golangci-lint -docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.42.0 golangci-lint run -v -# Use gofmt -gofmt -w ./.. +```shell +make test ``` ### EasyJson -[`easyjson`](https://github.com/mailru/easyjson) is a package used for optimizing marshal/unmarshal Go structs to/from JSON. It takes the `types.go` file as an input, and auto-generates `types_easyjson.go` with optimized marshalling and unmarshalling methods for this SDK. +[`easyjson`](https://github.com/mailru/easyjson) is a package used for optimizing marshal/unmarshal Go structs to/from JSON. +It takes the `types.go` file as an input, and auto-generates `types_easyjson.go` with optimized +marshalling and unmarshalling methods for this SDK. If for any reason `types.go` is modified, this file should be regenerated by running easyjson again. -#### Install easyjson - -```bash -# for Go < 1.17 -go get -u github.com/mailru/easyjson/... -``` -#### or -```bash -# for Go >= 1.17 -go get github.com/mailru/easyjson && go install github.com/mailru/easyjson/...@latest -``` - -#### Regenerate `types_easyjson.go` - -```bash -easyjson -all types.go +```shell +make easyjson ``` ## Git Guidelines diff --git a/makefile b/makefile index 3a478105..35c0ff9d 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -.PHONY: test easyjson install-tool +.PHONY: test easyjson requirements easyjson: easyjson -all types.go @@ -6,7 +6,7 @@ easyjson: test: docker compose run --rm package bash -c "go get && golangci-lint run -v && go test -v" -install-tool: +requirements: go get github.com/mailru/easyjson && go install github.com/mailru/easyjson/...@latest curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh - + go get -v -t ./...