Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
45 changes: 23 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,26 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1

- name: Run golangci-lint
run: golangci-lint run --timeout=5m
uses: golangci/golangci-lint-action@v8
with:
version: v2.3.1

# Schema and Example Validation
validate:
name: Validate Schemas and Examples
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check Go formatting
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files are not properly formatted:"
gofmt -s -l .
exit 1
fi
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Validate schemas and examples
run: make validate

# Build check
build:
Expand Down Expand Up @@ -65,8 +70,7 @@ jobs:
run: go mod download

- name: Build application
run: |
go build -v ./cmd/...
run: make build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

(in line with my 'prefer using make commands locally and in CI to keep them in sync')


- name: Check for vulnerabilities
run: |
Expand All @@ -77,7 +81,7 @@ jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
needs: [lint, build]
needs: [lint, validate, build]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -101,8 +105,7 @@ jobs:
run: go mod download

- name: Run unit tests
run: |
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand All @@ -116,7 +119,7 @@ jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: [lint, build]
needs: [lint, validate, build]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -140,9 +143,7 @@ jobs:
run: go mod download

- name: Run integration tests
run: |
chmod +x ./tests/integration/run.sh
./tests/integration/run.sh
run: make integration-test

# Overall status check
test-summary:
Expand Down
7 changes: 6 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ linters:
- return
nestif:
min-complexity: 8
revive:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncertain: Do we need this extra rule?

I'm not super familiar with golangci-lint, so apologies if this is a dumb question! Overall I think I'd like us to reduce custom config and use whatever the common/popular presets are: makes onboarding to the repo easier and AI tools more likely to get things right.

rules:
- name: use-any
severity: error
disabled: false
exclusions:
generated: lax
presets:
Expand Down Expand Up @@ -122,4 +127,4 @@ formatters:
paths:
- third_party$
- builtin$
- examples$
- examples$
70 changes: 70 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.PHONY: help build test lint lint-fix validate validate-schemas validate-examples integration-test check dev-local dev-compose clean docker publisher coverage

# Default target
help: ## Show this help message
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'

# Build targets
build: ## Build the registry application
go build ./cmd/registry

publisher: ## Build the publisher tool
cd tools/publisher && ./build.sh

docker: ## Build Docker image
docker build -t registry .

# Test targets
test: ## Run unit tests
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...

integration-test: ## Run integration tests
./tests/integration/run.sh

test-endpoints: ## Test API endpoints (requires running server)
./scripts/test_endpoints.sh

test-publish: ## Test publish endpoint (requires BEARER_TOKEN env var)
./scripts/test_publish.sh

# Validation targets
validate-schemas: ## Validate JSON schemas
./tools/validate-schemas.sh

validate-examples: ## Validate examples against schemas
./tools/validate-examples.sh

validate: validate-schemas validate-examples ## Run all validation checks

# Code quality targets
lint: ## Run linter (includes formatting)
golangci-lint run --timeout=5m

lint-fix: ## Run linter with auto-fix (includes formatting)
golangci-lint run --fix --timeout=5m

# Combined targets
check: lint validate test ## Run all checks (lint, validate, test)

pre-commit: check integration-test ## Run all pre-commit checks
@echo "All pre-commit checks passed!"

# Development targets
dev-compose: ## Start development environment with Docker Compose
docker compose up

dev-local: ## Run registry locally (requires MongoDB)
go run cmd/registry/main.go

# Cleanup
clean: ## Clean build artifacts and coverage files
rm -f registry
rm -f coverage.out
cd tools/publisher && rm -f publisher

# Coverage
coverage: ## Generate test coverage report
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...

.DEFAULT_GOAL := help
114 changes: 103 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ For development:
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.

```bash
# Build the Docker image
make docker

# 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.
Expand All @@ -51,27 +54,68 @@ 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.

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
make docker # Build Docker image

# Development
make dev-compose # Start development environment with Docker Compose
make dev-local # Run registry locally (requires MongoDB)

# Testing
make test # Run unit tests with coverage
make integration-test # Run integration tests
make test-endpoints # Test API endpoints (requires running server)
make test-publish # Test publish endpoint (requires BEARER_TOKEN)

# 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, test)
make pre-commit # Run all pre-commit checks (includes integration tests)

# Utilities
make coverage # Generate test coverage report
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

# Check formatting
gofmt -s -l .
make lint

# Fix formatting
gofmt -s -w .
# Run linter with auto-fix
make lint-fix
```

### Git Hooks (Optional)
Expand Down Expand Up @@ -333,19 +377,67 @@ 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

# Run all pre-commit checks (includes integration tests)
make pre-commit
```

## License

See the [LICENSE](LICENSE) file for details.
Expand Down
Loading