Add helpful targets via Makefile (#211)

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
The following PR:
* Adds a Makefile with the most common project-related commands
* Updates the CI workflow to leverage that (people testing locally will
use the same commands as the CI)
* Switches to using the official Golangci-lint action instead of
downloading it via curl
* Bumps the golangci version (supersedes #144)
* Fixes any formatting/linting issues found
* Updates the README to reference the new make targets
* Runs the schema validation scripts as part of the CI

**Next:**
* If you are okay I can file a follow up PR afterwards where I can tidy
up the CI workflows a bit, it feels there's some overlap.

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
Locally by running the make targets

## Breaking Changes
<!-- Will users need to update their code or configurations? -->

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->

---------

Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
Co-authored-by: Adam Jones <adamj+git@anthropic.com>
This commit is contained in:
Radoslav Dimitrov 2025-08-06 16:51:15 +03:00 • committed by GitHub
commit f5bf542697
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

108
README.md
View file

@ -36,11 +36,11 @@ For development:
## Running
The easiest way to get the registry running is to use `docker compose`. This will setup the MCP Registry service, import the seed data and run MongoDB in a local Docker environment.
The easiest way to get the registry running is uses docker compose. This will setup the MCP Registry service, import the seed data and run MongoDB in a local Docker environment.
```bash
# Run the registry and MongoDB with docker compose
docker compose up --build
make dev-compose
```
This will start the MCP Registry service and MongoDB with Docker, exposing it on port 8080.
@ -51,7 +51,7 @@ If you prefer to run the service locally without Docker, you can build and run i
```bash
# Build a registry executable
go build ./cmd/registry
make build
```
This will create the `registry` binary in the current directory. You'll need to have MongoDB running locally or with Docker.
@ -59,19 +59,58 @@ By default, the service will run on `http://localhost:8080`.
## Development
### Available Make Targets
To see all available make targets:
```bash
make help
```
Key development commands:
```bash
# Build targets
make build # Build the registry application
make publisher # Build the publisher tool
# Development
make dev-compose # Start development environment with Docker Compose
make dev-local # Run registry locally (requires MongoDB)
# Testing
make test-unit # Run unit tests with coverage report
make test-integration # Run integration tests
make test-endpoints # Test API endpoints (requires running server)
make test-publish # Test publish endpoint (requires BEARER_TOKEN)
make test-all # Run all tests
# Code quality
make lint # Run linter (same as CI)
make lint-fix # Run linter with auto-fix
# Validation
make validate-schemas # Validate JSON schemas
make validate-examples # Validate examples against schemas
make validate # Run all validation checks
# Combined workflows
make check # Run all checks (lint, validate, unit tests)
# Utilities
make clean # Clean build artifacts and coverage files
```
### Linting
The project uses golangci-lint with extensive checks. Always run linting before pushing:
```bash
# Run all linters (same as CI)
golangci-lint run --timeout=5m
make lint
# Check formatting
gofmt -s -l .
# Fix formatting
gofmt -s -w .
# Run linter with auto-fix
make lint-fix
```
### Git Hooks (Optional)
@ -333,19 +372,64 @@ The service can be configured using environment variables:
## Testing
Run the test script to validate API endpoints:
### Unit Tests
```bash
./scripts/test_endpoints.sh
# Run unit tests with coverage
make test
# Generate coverage report
make coverage
```
You can specify specific endpoints to test:
### Integration Tests
```bash
# Run integration tests
make integration-test
```
### API Endpoint Testing
```bash
# Test API endpoints (requires running server)
make test-endpoints
```
You can also run the script directly with specific endpoints:
```bash
./scripts/test_endpoints.sh --endpoint health
./scripts/test_endpoints.sh --endpoint servers
```
### Publish Endpoint Testing
```bash
# Test publish endpoint (requires BEARER_TOKEN env var)
make test-publish
```
### Validation
```bash
# Validate JSON schemas
make validate-schemas
# Validate examples against schemas
make validate-examples
# Run all validation checks
make validate
```
### Comprehensive Testing
```bash
# Run all checks (lint, validate, test)
make check
```
## License
See the [LICENSE](LICENSE) file for details.