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

Add makefile and badges for readme #561

Merged
merged 5 commits into from
Aug 21, 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
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<p align="center">
<a href="https://github.com/meilisearch/meilisearch-go/actions"><img src="https://github.com/meilisearch/meilisearch-go/workflows/Tests/badge.svg" alt="GitHub Workflow Status"></a>
<a href="https://goreportcard.com/report/github.com/meilisearch/meilisearch-go"><img src="https://goreportcard.com/badge/github.com/meilisearch/meilisearch-go" alt="Test"></a>
<a href="https://codecov.io/gh/meilisearch/meilisearch-go"><img src="https://codecov.io/gh/meilisearch/meilisearch-go/branch/main/graph/badge.svg?token=8N6N60D5UI" alt="CodeCov"></a>
<a href="https://pkg.go.dev/github.com/meilisearch/meilisearch-go"><img src="https://pkg.go.dev/badge/github.com/meilisearch/meilisearch-go.svg" alt="Go Reference"></a>
<a href="https://github.com/meilisearch/meilisearch-go/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a>
<a href="https://ms-bors.herokuapp.com/repositories/58"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
</p>
Expand Down
12 changes: 12 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.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"

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