Skip to content

Commit

Permalink
docs: update contributing rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Ja7ad committed Aug 21, 2024
1 parent 8e7be4a commit c51af72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 43 deletions.
54 changes: 14 additions & 40 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,58 +26,32 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume

## Development Workflow

### Setup <!-- omit in TOC -->
### Requirements <!-- omit in TOC -->

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 <!-- omit in TOC -->

### Tests and Linter <!-- omit in TOC -->
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 <!-- omit in TOC -->

[`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 <!-- omit in TOC -->

```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` <!-- omit in TOC -->

```bash
easyjson -all types.go
```shell
make easyjson
```

## Git Guidelines
Expand Down
6 changes: 3 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.PHONY: test easyjson install-tool
.PHONY: test easyjson requirements

easyjson:
easyjson -all types.go

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 ./...

0 comments on commit c51af72

Please sign in to comment.