Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (128 loc) · 5.66 KB
/
Copy pathMakefile
File metadata and controls
153 lines (128 loc) · 5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Formae GitLab Plugin Makefile
# Plugin metadata - extracted from formae-plugin.pkl
PLUGIN_NAME := $(shell pkl eval -x 'name' formae-plugin.pkl 2>/dev/null || echo "gitlab")
PLUGIN_VERSION := $(shell pkl eval -x 'version' formae-plugin.pkl 2>/dev/null || echo "0.0.0")
PLUGIN_NAMESPACE := $(shell pkl eval -x 'namespace' formae-plugin.pkl 2>/dev/null || echo "GitLab")
GO := go
GOFLAGS := -trimpath
BINARY := $(PLUGIN_NAME)
PLUGIN_BASE_DIR := $(HOME)/.pel/formae/plugins
INSTALL_DIR := $(PLUGIN_BASE_DIR)/$(PLUGIN_NAME)/v$(PLUGIN_VERSION)
.PHONY: all build test test-unit test-integration lint lint-reuse add-license schema-version verify-schema gen-pkl clean install install-dev help clean-environment conformance-test conformance-test-crud conformance-test-discovery conformance-test-crud-run conformance-test-discovery-run
all: build
## schema-version: Write schema/pkl/VERSION from the plugin manifest
schema-version:
@mkdir -p schema/pkl && echo "$(PLUGIN_VERSION)" > schema/pkl/VERSION
## build: Build the plugin binary
build: schema-version
$(GO) build $(GOFLAGS) -o bin/$(BINARY) .
## test: Run all tests
test:
$(GO) test -v ./...
## test-unit: Run unit tests only
test-unit:
$(GO) test -v -tags=unit ./...
## test-integration: Run integration tests (requires GITLAB_TOKEN, GITLAB_TEST_GROUP, GITLAB_TEST_PROJECT)
test-integration:
$(GO) test -v -tags=integration -timeout 5m ./...
## lint: Run golangci-lint
lint:
golangci-lint run
## lint-reuse: Check REUSE license compliance
lint-reuse:
./scripts/lint_reuse.sh
## add-license: Add license headers to source files (idempotent)
add-license:
./scripts/add_license.sh
## verify-schema: Validate Pkl schema files
verify-schema: schema-version
$(GO) run github.com/platform-engineering-labs/formae/pkg/plugin/testutil/cmd/verify-schema --namespace $(PLUGIN_NAMESPACE) ./schema/pkl
## gen-pkl: Resolve all Pkl project dependencies
gen-pkl:
pkl project resolve schema/pkl
pkl project resolve testdata
## clean: Remove build artifacts
clean:
rm -rf bin/ dist/
## install: Build and install plugin locally
install: build
@echo "Installing $(PLUGIN_NAME) v$(PLUGIN_VERSION) (namespace: $(PLUGIN_NAMESPACE))..."
@rm -rf $(PLUGIN_BASE_DIR)/$(PLUGIN_NAME)
@mkdir -p $(INSTALL_DIR)/schema/pkl
@cp bin/$(BINARY) $(INSTALL_DIR)/$(BINARY)
@cp -r schema/pkl/* $(INSTALL_DIR)/schema/pkl/
@if [ -f schema/Config.pkl ]; then cp schema/Config.pkl $(INSTALL_DIR)/schema/; fi
@cp formae-plugin.pkl $(INSTALL_DIR)/
@echo "Installed to $(INSTALL_DIR)"
## install-dev: Build and install plugin as v0.0.0 (for formae debug builds)
DEV_INSTALL_DIR := $(PLUGIN_BASE_DIR)/$(PLUGIN_NAME)/v0.0.0
install-dev: build
@echo "Installing $(PLUGIN_NAME) v0.0.0 (dev)..."
@rm -rf $(PLUGIN_BASE_DIR)/$(PLUGIN_NAME)
@mkdir -p $(DEV_INSTALL_DIR)/schema/pkl
@cp bin/$(BINARY) $(DEV_INSTALL_DIR)/$(BINARY)
@cp -r schema/pkl/* $(DEV_INSTALL_DIR)/schema/pkl/
@if [ -f schema/Config.pkl ]; then cp schema/Config.pkl $(DEV_INSTALL_DIR)/schema/; fi
@cp formae-plugin.pkl $(DEV_INSTALL_DIR)/
## help: Show this help message
help:
@echo "Available targets:"
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /'
## clean-environment: Clean up test resources on the target project
clean-environment:
@./scripts/ci/clean-environment.sh
## conformance-test: Run all conformance tests (CRUD + discovery)
## Usage: make conformance-test [TEST=resource] [PARALLEL=1] [TIMEOUT=60]
## Calls clean-environment before and after tests.
##
## Parameters:
## TEST - Filter tests by name pattern (e.g., TEST=group)
## PARALLEL - Concurrent tests inside the SDK (default: 1 = sequential)
## TIMEOUT - Test timeout in minutes (default: 60)
##
## The conformance SDK installs the latest released formae via orbital
## unless FORMAE_BINARY is set (e.g. by nightly which builds from source).
conformance-test: install
@echo "Pre-test cleanup..."
@./scripts/ci/clean-environment.sh || true
@echo ""
@$(MAKE) conformance-test-crud-run conformance-test-discovery-run TEST=$(TEST) PARALLEL=$(PARALLEL) TIMEOUT=$(TIMEOUT); \
TEST_EXIT=$$?; \
echo ""; \
echo "Post-test cleanup..."; \
./scripts/ci/clean-environment.sh || true; \
exit $$TEST_EXIT
## conformance-test-crud: Run CRUD tests with cleanup (convenience for local dev)
conformance-test-crud: install
@echo "Pre-test cleanup..."
@./scripts/ci/clean-environment.sh || true
@echo ""
@$(MAKE) conformance-test-crud-run TEST=$(TEST) PARALLEL=$(PARALLEL) TIMEOUT=$(TIMEOUT); \
TEST_EXIT=$$?; \
echo ""; \
echo "Post-test cleanup..."; \
./scripts/ci/clean-environment.sh || true; \
exit $$TEST_EXIT
## conformance-test-discovery: Run discovery tests with cleanup (convenience for local dev)
conformance-test-discovery: install
@echo "Pre-test cleanup..."
@./scripts/ci/clean-environment.sh || true
@echo ""
@$(MAKE) conformance-test-discovery-run TEST=$(TEST) PARALLEL=$(PARALLEL) TIMEOUT=$(TIMEOUT); \
TEST_EXIT=$$?; \
echo ""; \
echo "Post-test cleanup..."; \
./scripts/ci/clean-environment.sh || true; \
exit $$TEST_EXIT
## conformance-test-crud-run: Run only CRUD lifecycle tests (no cleanup)
## Used by CI matrix jobs where cleanup is managed separately.
conformance-test-crud-run:
@echo "Running CRUD conformance tests..."
@FORMAE_TEST_FILTER="$(TEST)" FORMAE_TEST_TYPE=crud FORMAE_TEST_PARALLEL="$(PARALLEL)" \
$(GO) test -tags=conformance -v -timeout $(or $(TIMEOUT),60)m ./...
## conformance-test-discovery-run: Run only discovery tests (no cleanup)
## Used by CI matrix jobs where cleanup is managed separately.
conformance-test-discovery-run:
@echo "Running discovery conformance tests..."
@FORMAE_TEST_FILTER="$(TEST)" FORMAE_TEST_TYPE=discovery FORMAE_TEST_PARALLEL="$(PARALLEL)" \
$(GO) test -tags=conformance -v -timeout $(or $(TIMEOUT),60)m ./...