-
Notifications
You must be signed in to change notification settings - Fork 576
Add helpful targets via Makefile #211
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
Changes from 3 commits
4552d64
416e80a
f0aa63d
062a0b4
3015b95
8c581a2
25ab60c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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: | ||
domdomegg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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: | ||
|
|
@@ -65,8 +70,7 @@ jobs: | |
| run: go mod download | ||
|
|
||
| - name: Build application | ||
| run: | | ||
| go build -v ./cmd/... | ||
| run: make build | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😍 (in line with my 'prefer using |
||
|
|
||
| - name: Check for vulnerabilities | ||
| run: | | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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 | ||
|
|
@@ -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: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,6 +83,11 @@ linters: | |
| - return | ||
| nestif: | ||
| min-complexity: 8 | ||
| revive: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
|
|
@@ -122,4 +127,4 @@ formatters: | |
| paths: | ||
| - third_party$ | ||
| - builtin$ | ||
| - examples$ | ||
| - examples$ | ||
| 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 |
Uh oh!
There was an error while loading. Please reload this page.