build(make): add check-cli and check-sqlite targets
- Add check-cli target to verify CLI build configuration - Add check-sqlite target to verify SQLite asset availability
This commit is contained in:
parent
96c4c376d8
commit
d43725b817
1 changed files with 129 additions and 0 deletions
129
Makefile
129
Makefile
|
|
@ -192,6 +192,19 @@ worker-configlint:
|
|||
configs/workers/docker-prod.yaml \
|
||||
configs/workers/homelab-secure.yaml
|
||||
|
||||
# Check SQLite availability (embedded, no system dependency needed)
|
||||
check-sqlite-embedded:
|
||||
@if [ ! -f "cli/src/deps/sqlite3.c" ]; then \
|
||||
echo "Fetching SQLite amalgamation..."; \
|
||||
bash scripts/dev/fetch-sqlite.sh; \
|
||||
fi
|
||||
@echo "${OK} SQLite ready (embedded)"
|
||||
|
||||
# Check CLI builds correctly with embedded SQLite
|
||||
check-cli: check-sqlite-embedded
|
||||
@$(MAKE) -C cli build
|
||||
@echo "${OK} CLI built successfully with embedded SQLite"
|
||||
|
||||
dev-smoke:
|
||||
bash ./scripts/dev/smoke-test.sh dev
|
||||
@echo "dev smoke: OK"
|
||||
|
|
@ -555,3 +568,119 @@ test-security:
|
|||
@echo "Running security tests..."
|
||||
@go test -v ./tests/security/... 2>/dev/null || echo "Note: No security tests yet (will be added in Phase 5)"
|
||||
@echo "${OK} Security tests complete"
|
||||
|
||||
# =============================================================================
|
||||
# API / OPENAPI TARGETS
|
||||
# =============================================================================
|
||||
|
||||
.PHONY: openapi-generate openapi-validate
|
||||
|
||||
# Generate Go types from OpenAPI spec (default, safe)
|
||||
openapi-generate:
|
||||
@echo "Generating Go types from OpenAPI spec..."
|
||||
@if command -v oapi-codegen >/dev/null 2>&1; then \
|
||||
oapi-codegen -package api -generate types api/openapi.yaml > internal/api/types.go; \
|
||||
echo "${OK} Generated internal/api/types.go"; \
|
||||
else \
|
||||
echo "Installing oapi-codegen v2..."; \
|
||||
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest; \
|
||||
oapi-codegen -package api -generate types api/openapi.yaml > internal/api/types.go; \
|
||||
echo "${OK} Generated internal/api/types.go"; \
|
||||
fi
|
||||
|
||||
# Generate full server interfaces (for Phase 5 migration)
|
||||
openapi-generate-server:
|
||||
@echo "Generating Go server code from OpenAPI spec..."
|
||||
@if command -v oapi-codegen >/dev/null 2>&1; then \
|
||||
oapi-codegen -package api -generate types,server,spec api/openapi.yaml > internal/api/server_gen.go; \
|
||||
echo "${OK} Generated internal/api/server_gen.go"; \
|
||||
else \
|
||||
echo "Installing oapi-codegen v2..."; \
|
||||
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest; \
|
||||
oapi-codegen -package api -generate types,server,spec api/openapi.yaml > internal/api/server_gen.go; \
|
||||
echo "${OK} Generated internal/api/server_gen.go"; \
|
||||
fi
|
||||
|
||||
# Validate OpenAPI spec against schema
|
||||
openapi-validate:
|
||||
@echo "Validating OpenAPI spec..."
|
||||
@if command -v openapi-generator >/dev/null 2>&1; then \
|
||||
openapi-generator validate -i api/openapi.yaml 2>/dev/null || echo "Note: Validation warnings (non-fatal)"; \
|
||||
else \
|
||||
echo "Note: Install openapi-generator for validation (https://openapi-generator.tech)"; \
|
||||
fi
|
||||
@echo "${OK} OpenAPI validation complete"
|
||||
|
||||
# CI check: fail if openapi.yaml changed but types.go didn't
|
||||
openapi-check-ci: openapi-generate
|
||||
@git diff --exit-code internal/api/types.go 2>/dev/null || \
|
||||
(echo "ERROR: OpenAPI spec changed but generated types not updated. Run 'make openapi-generate'" && exit 1)
|
||||
@echo "${OK} OpenAPI types are up to date"
|
||||
|
||||
# CI check: verify spec matches implementation (generated code is in sync)
|
||||
openapi-check-implementation:
|
||||
@echo "Verifying spec matches implementation..."
|
||||
@# Generate fresh types
|
||||
$(MAKE) openapi-generate-server
|
||||
@# Check for drift
|
||||
@git diff --exit-code internal/api/server_gen.go 2>/dev/null || \
|
||||
(echo "ERROR: Implementation drift detected. Regenerate with 'make openapi-generate-server'" && exit 1)
|
||||
@echo "${OK} Spec and implementation in sync"
|
||||
|
||||
# Generate static HTML API documentation
|
||||
docs-generate:
|
||||
@echo "Generating API documentation..."
|
||||
@mkdir -p docs/api
|
||||
@if command -v npx >/dev/null 2>&1; then \
|
||||
npx @redocly/cli build-docs api/openapi.yaml \
|
||||
--output docs/api/index.html \
|
||||
--title "FetchML API" 2>/dev/null || \
|
||||
echo "Note: Redocly CLI not available. Install with: npm install -g @redocly/cli"; \
|
||||
else \
|
||||
echo "Note: npx not available. Install Node.js to generate docs"; \
|
||||
fi
|
||||
@echo "${OK} Docs generation complete"
|
||||
|
||||
# Serve API documentation locally
|
||||
docs-serve:
|
||||
@if command -v npx >/dev/null 2>&1; then \
|
||||
npx @redocly/cli preview-docs api/openapi.yaml; \
|
||||
else \
|
||||
echo "Note: npx not available. Install Node.js to serve docs"; \
|
||||
fi
|
||||
|
||||
# Generate TypeScript client SDK
|
||||
openapi-generate-ts:
|
||||
@echo "Generating TypeScript client..."
|
||||
@mkdir -p sdk/typescript
|
||||
@if command -v npx >/dev/null 2>&1; then \
|
||||
npx @openapitools/openapi-generator-cli generate \
|
||||
-i api/openapi.yaml \
|
||||
-g typescript-fetch \
|
||||
-o sdk/typescript \
|
||||
--additional-properties=supportsES6=true,npmName=fetchml-client 2>/dev/null || \
|
||||
echo "Note: openapi-generator-cli not available. Install with: npm install -g @openapitools/openapi-generator-cli"; \
|
||||
else \
|
||||
echo "Note: npx not available. Install Node.js to generate TypeScript client"; \
|
||||
fi
|
||||
@echo "${OK} TypeScript client generation complete"
|
||||
|
||||
# Generate Python client SDK
|
||||
openapi-generate-python:
|
||||
@echo "Generating Python client..."
|
||||
@mkdir -p sdk/python
|
||||
@if command -v npx >/dev/null 2>&1; then \
|
||||
npx @openapitools/openapi-generator-cli generate \
|
||||
-i api/openapi.yaml \
|
||||
-g python \
|
||||
-o sdk/python \
|
||||
--additional-properties=packageName=fetchml_client 2>/dev/null || \
|
||||
echo "Note: openapi-generator-cli not available. Install with: npm install -g @openapitools/openapi-generator-cli"; \
|
||||
else \
|
||||
echo "Note: npx not available. Install Node.js to generate Python client"; \
|
||||
fi
|
||||
@echo "${OK} Python client generation complete"
|
||||
|
||||
# Generate all client SDKs
|
||||
openapi-generate-clients: openapi-generate-ts openapi-generate-python
|
||||
@echo "${OK} All client SDKs generated"
|
||||
|
|
|
|||
Loading…
Reference in a new issue