Skip to content

Commit

Permalink
Merge #561
Browse files Browse the repository at this point in the history
561: Add makefile and badges for readme r=curquiza a=Ja7ad

## What does this PR do?
- This PR add codecov and go reference badge in readme and add makefile for easyjson and test.

## PR checklist
Please check if your PR fulfills the following requirements:
- [ ] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: Javad <[email protected]>
Co-authored-by: Javad Rajabzadeh <[email protected]>
  • Loading branch information
meili-bors[bot] and Ja7ad authored Aug 21, 2024
2 parents 7bd9c23 + 11b1bd5 commit a5a58fb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 40 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
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 ./...

0 comments on commit a5a58fb

Please sign in to comment.