Skip to content

Commit 4552d64

Browse files
committed
Add a Makefile
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
1 parent 6ba6129 commit 4552d64

File tree

3 files changed

+98
-19
lines changed

3 files changed

+98
-19
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,24 @@ jobs:
2727
run: |
2828
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.3.1
2929
30-
- name: Run golangci-lint
31-
run: golangci-lint run --timeout=5m
30+
- name: Run lint (includes formatting)
31+
run: make lint
32+
33+
# Schema and Example Validation
34+
validate:
35+
name: Validate Schemas and Examples
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
3240

33-
- name: Check Go formatting
34-
run: |
35-
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
36-
echo "The following files are not properly formatted:"
37-
gofmt -s -l .
38-
exit 1
39-
fi
41+
- name: Set up Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: ${{ env.GO_VERSION }}
45+
46+
- name: Validate schemas and examples
47+
run: make validate
4048

4149
# Build check
4250
build:
@@ -65,8 +73,7 @@ jobs:
6573
run: go mod download
6674

6775
- name: Build application
68-
run: |
69-
go build -v ./cmd/...
76+
run: make build
7077

7178
- name: Check for vulnerabilities
7279
run: |
@@ -77,7 +84,7 @@ jobs:
7784
unit-tests:
7885
name: Unit Tests
7986
runs-on: ubuntu-latest
80-
needs: [lint, build]
87+
needs: [lint, validate, build]
8188
steps:
8289
- name: Checkout code
8390
uses: actions/checkout@v4
@@ -101,8 +108,7 @@ jobs:
101108
run: go mod download
102109

103110
- name: Run unit tests
104-
run: |
105-
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
111+
run: make test
106112

107113
- name: Upload coverage to Codecov
108114
uses: codecov/codecov-action@v4
@@ -116,7 +122,7 @@ jobs:
116122
integration-tests:
117123
name: Integration Tests
118124
runs-on: ubuntu-latest
119-
needs: [lint, build]
125+
needs: [lint, validate, build]
120126
steps:
121127
- name: Checkout code
122128
uses: actions/checkout@v4
@@ -140,9 +146,7 @@ jobs:
140146
run: go mod download
141147

142148
- name: Run integration tests
143-
run: |
144-
chmod +x ./tests/integration/run.sh
145-
./tests/integration/run.sh
149+
run: make integration-test
146150

147151
# Overall status check
148152
test-summary:

.golangci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ linters:
8383
- return
8484
nestif:
8585
min-complexity: 8
86+
revive:
87+
rules:
88+
- name: use-any
89+
severity: error
90+
disabled: false
8691
exclusions:
8792
generated: lax
8893
presets:
@@ -122,4 +127,4 @@ formatters:
122127
paths:
123128
- third_party$
124129
- builtin$
125-
- examples$
130+
- examples$

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.PHONY: help build test lint lint-fix validate validate-schemas validate-examples integration-test check dev clean docker publisher coverage
2+
3+
# Default target
4+
help: ## Show this help message
5+
@echo "Available targets:"
6+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
7+
8+
# Build targets
9+
build: ## Build the registry application
10+
go build ./cmd/registry
11+
12+
publisher: ## Build the publisher tool
13+
cd tools/publisher && ./build.sh
14+
15+
docker: ## Build Docker image
16+
docker build -t registry .
17+
18+
# Test targets
19+
test: ## Run unit tests
20+
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
21+
22+
integration-test: ## Run integration tests
23+
./tests/integration/run.sh
24+
25+
test-endpoints: ## Test API endpoints (requires running server)
26+
./scripts/test_endpoints.sh
27+
28+
test-publish: ## Test publish endpoint (requires BEARER_TOKEN env var)
29+
./scripts/test_publish.sh
30+
31+
# Validation targets
32+
validate-schemas: ## Validate JSON schemas
33+
./tools/validate-schemas.sh
34+
35+
validate-examples: ## Validate examples against schemas
36+
./tools/validate-examples.sh
37+
38+
validate: validate-schemas validate-examples ## Run all validation checks
39+
40+
# Code quality targets
41+
lint: ## Run linter (includes formatting)
42+
golangci-lint run --timeout=5m
43+
44+
lint-fix: ## Run linter with auto-fix (includes formatting)
45+
golangci-lint run --fix --timeout=5m
46+
47+
# Combined targets
48+
check: lint validate test ## Run all checks (lint, validate, test)
49+
50+
pre-commit: check integration-test ## Run all pre-commit checks
51+
@echo "✅ All pre-commit checks passed!"
52+
53+
# Development targets
54+
dev: ## Start development environment with Docker Compose
55+
docker compose up
56+
57+
dev-local: ## Run registry locally (requires MongoDB)
58+
go run cmd/registry/main.go
59+
60+
# Cleanup
61+
clean: ## Clean build artifacts and coverage files
62+
rm -f registry
63+
rm -f coverage.out
64+
cd tools/publisher && rm -f publisher
65+
66+
# Coverage
67+
coverage: ## Generate test coverage report
68+
go test -v -race -coverprofile=coverage.out -covermode=atomic ./internal/...
69+
70+
.DEFAULT_GOAL := help

0 commit comments

Comments
 (0)