An open API service indexing awesome lists of open source software.

https://github.com/anisimov-anthony/assignment-service

Go microservice that automates the process of assigning reviewers to Pull Requests in development teams
https://github.com/anisimov-anthony/assignment-service

assignment go golang microservice mongodb pull-requests rest-api

Last synced: about 1 month ago
JSON representation

Go microservice that automates the process of assigning reviewers to Pull Requests in development teams

Awesome Lists containing this project

README

          

# Assignment Service

Microservice for automatically assigning reviewers to Pull Requests.

## Technology Stack

- **Language**: Go 1.22
- **Database**: MongoDB 7.0
- **HTTP Router**: Gorilla Mux
- **Logging**: Uber Zap
- **Testing**: Go testing + testify
- **Containerization**: Docker + Docker Compose

## Quick Start

### Running with Docker Compose

```bash
# Start all services
docker-compose up

## Convenient make commands (other commands can be found via make help)
# Stop and clean up
make docker-clean
# Start
make docker-up
```

The service will be available at `http://localhost:8080`

**Note:** If you already have a local MongoDB running on port 27017, Docker Compose will automatically use port 27018 for external access. Inside the Docker network, containers communicate via the standard port 27017.

### Local Development

```bash
# Install dependencies
make deps

# Build and run
make run

# Or simply:
go run ./cmd/server
```

## Makefile

Main commands (make help):

- `build` Build binary
- `run` Run application locally
- `test` Run tests with race detector
- `test-coverage` Show test coverage
- `lint` Check code with golangci-lint
- `fmt` Format code (go fmt + goimports)
- `verify` Full check: format + linter + tests
- `clean` Remove binaries and coverage
- `deps` Download and clean up dependencies
- `docker-build` Build Docker images
- `docker-up` Start services
- `docker-up-detached` Start services (in background)
- `docker-down` Stop and remove containers
- `docker-clean` Full cleanup: containers + volumes + images
- `docker-logs` Follow container logs
- `help` Show this help

## API Endpoints

### Main Endpoints (described in OpenAPI)

- `POST /team/add` - create team
- `GET /team/get` - get team information
- `POST /users/setIsActive` - set user activity status
- `GET /users/getReview` - get PRs assigned to user
- `POST /pullRequest/create` - create Pull Request
- `POST /pullRequest/merge` - set `MERGED` status for Pull Request
- `POST /pullRequest/reassign` - reassign reviewer

### Additionally Implemented Endpoints

- `GET /health` - check service health (not described in OpenAPI, only declared)
- `GET /stats/user` - user statistics

## Testing

Code coverage: **87.5%**

```bash
# Run all tests
make test

# View coverage
make test-coverage
```

Tests verify all main service scenarios including error handling and edge cases.

## Load Testing

More details are described in `scripts/k6/README.md`

**k6** is used for load testing. Tests are located in the `scripts/k6/` folder:

Test results are saved to:
- `scripts/k6/results/` - text reports directly from the terminal with k6 runs
- `scripts/k6/k6-results/YYYY-MM-DD/` - JSON results for analysis (local folder)
- `scripts/k6/parse_results.py` - script for parsing results

### Testing Hardware

Load testing was performed on the following hardware:

**Main specifications:**
- **CPU**: Intel i3-7020U (4 cores) @ 2.3GHz
- **RAM**: 8GB
- **OS**: Arch Linux x86_64

## CI/CD

The project is configured with GitHub Actions:

- **go-ci.yml** - building, testing and linting Go code
- **docker-ci.yml** - building Docker images

## License

This project is distributed under the [MIT License](LICENSE).