-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
685 lines (580 loc) · 28 KB
/
Makefile
File metadata and controls
685 lines (580 loc) · 28 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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
# Basecamp SDK Makefile
#
# Orchestrates both Smithy spec and Go SDK
.PHONY: all check clean help setup tools provenance-sync provenance-check sync-status bump sync-spec-version sync-spec-version-check sync-api-version sync-api-version-check release
# Default: run all checks
all: check
#------------------------------------------------------------------------------
# Smithy targets
#------------------------------------------------------------------------------
.PHONY: smithy-validate smithy-build smithy-check smithy-clean smithy-mapper behavior-model behavior-model-check
# Validate Smithy spec
smithy-validate: smithy-mapper
@echo "==> Validating Smithy spec..."
cd spec && smithy validate
# Build the custom Smithy OpenAPI mapper
smithy-mapper:
@echo "==> Building Smithy OpenAPI mapper..."
cd spec/smithy-bare-arrays && ./gradlew publishToMavenLocal --quiet
# Build OpenAPI from Smithy (also regenerates behavior model + syncs API version)
smithy-build: behavior-model smithy-mapper
@$(MAKE) sync-spec-version
@echo "==> Building OpenAPI from Smithy..."
cd spec && smithy build
cp spec/build/smithy/openapi/openapi/Basecamp.openapi.json openapi.json
@echo "==> Post-processing OpenAPI for Go types..."
./scripts/enhance-openapi-go-types.sh
@echo "Updated openapi.json"
@$(MAKE) sync-api-version
# Check that openapi.json is up to date
smithy-check: smithy-validate smithy-mapper
@$(MAKE) sync-spec-version-check
@echo "==> Checking OpenAPI freshness..."
@cd spec && smithy build
@TMPFILE=$$(mktemp) && \
cp spec/build/smithy/openapi/openapi/Basecamp.openapi.json "$$TMPFILE" && \
./scripts/enhance-openapi-go-types.sh "$$TMPFILE" "$$TMPFILE" > /dev/null 2>&1 && \
(diff -q openapi.json "$$TMPFILE" > /dev/null 2>&1 || \
(rm -f "$$TMPFILE" && echo "ERROR: openapi.json is out of date. Run 'make smithy-build'" && exit 1)) && \
rm -f "$$TMPFILE"
@echo "openapi.json is up to date"
# Clean Smithy build artifacts
smithy-clean:
rm -rf spec/build spec/smithy-bare-arrays/build spec/smithy-bare-arrays/.gradle
# Generate behavior model from Smithy spec
behavior-model: smithy-mapper
@echo "==> Generating behavior model..."
@cd spec && smithy build
./scripts/generate-behavior-model
@echo "Updated behavior-model.json"
# Check that behavior-model.json is up to date
behavior-model-check:
@echo "==> Checking behavior model freshness..."
@./scripts/generate-behavior-model spec/build/smithy/source/model/model.json behavior-model.json.tmp
@diff -q behavior-model.json behavior-model.json.tmp > /dev/null 2>&1 || \
(rm -f behavior-model.json.tmp && echo "ERROR: behavior-model.json is out of date. Run 'make behavior-model'" && exit 1)
@rm -f behavior-model.json.tmp
@echo "behavior-model.json is up to date"
.PHONY: url-routes url-routes-check
# Generate url-routes.json from OpenAPI spec
url-routes:
@echo "==> Generating URL routes..."
./scripts/generate-url-routes
@echo "Updated go/pkg/basecamp/url-routes.json"
# Check that url-routes.json is up to date
url-routes-check:
@echo "==> Checking URL routes freshness..."
@./scripts/generate-url-routes openapi.json go/pkg/basecamp/url-routes.json.tmp
@diff -q go/pkg/basecamp/url-routes.json go/pkg/basecamp/url-routes.json.tmp > /dev/null 2>&1 || \
(rm -f go/pkg/basecamp/url-routes.json.tmp && echo "ERROR: url-routes.json is out of date. Run 'make url-routes'" && exit 1)
@rm -f go/pkg/basecamp/url-routes.json.tmp
@echo "url-routes.json is up to date"
#------------------------------------------------------------------------------
# API Provenance targets
#------------------------------------------------------------------------------
# Copy api-provenance.json into Go package for go:embed
provenance-sync:
@cp spec/api-provenance.json go/pkg/basecamp/api-provenance.json
# Check that the Go embedded provenance matches the canonical spec file
provenance-check:
@diff -q spec/api-provenance.json go/pkg/basecamp/api-provenance.json > /dev/null 2>&1 || \
(echo "ERROR: go/pkg/basecamp/api-provenance.json is out of date. Run 'make provenance-sync'" && exit 1)
@echo "api-provenance.json is up to date"
# Show upstream changes since last spec sync (queries GitHub via gh CLI).
BC3_API_REPO ?= basecamp/bc3-api
BC3_REPO ?= basecamp/bc3
sync-status:
@command -v gh > /dev/null 2>&1 || { echo "ERROR: gh CLI not found. Install: https://cli.github.com"; exit 1; }
@gh auth status > /dev/null 2>&1 || { echo "ERROR: gh not authenticated. Run: gh auth login"; exit 1; }
@REV=$$(jq -r '.bc3_api.revision // empty' spec/api-provenance.json); \
if [ -z "$$REV" ]; then \
echo "==> bc3-api: no baseline revision set"; \
else \
echo "==> bc3-api changes since last sync ($$(echo $$REV | cut -c1-7)):"; \
gh api "repos/$(BC3_API_REPO)/compare/$$REV...HEAD" \
--jq '[.files[] | select(.filename | startswith("sections/"))] | if length == 0 then " (no changes in sections/)" else .[] | " " + .status[:1] + " " + .filename end'; \
fi
@echo ""
@REV=$$(jq -r '.bc3.revision // empty' spec/api-provenance.json); \
if [ -z "$$REV" ]; then \
echo "==> bc3: no baseline revision set"; \
else \
echo "==> bc3 API changes since last sync ($$(echo $$REV | cut -c1-7)):"; \
gh api "repos/$(BC3_REPO)/compare/$$REV...HEAD" \
--jq '[.files[] | select(.filename | startswith("app/controllers/"))] | if length == 0 then " (no changes in app/controllers/)" else .[] | " " + .status[:1] + " " + .filename end'; \
fi
#------------------------------------------------------------------------------
# Version management
#------------------------------------------------------------------------------
# Bump SDK version across all languages: make bump VERSION=x.y.z
bump:
ifndef VERSION
$(error VERSION is required. Usage: make bump VERSION=x.y.z)
endif
@./scripts/bump-version.sh $(VERSION)
# Tag and push a global release: make release VERSION=x.y.z
release:
ifndef VERSION
$(error VERSION is required. Usage: make release VERSION=x.y.z)
endif
@echo "Releasing v$(VERSION)..."
@# Verify version constants match
@grep -qF 'Version = "$(VERSION)"' go/pkg/basecamp/version.go || \
{ echo "ERROR: Go version does not match $(VERSION). Run 'make bump VERSION=$(VERSION)' first."; exit 1; }
@grep -qF '"version": "$(VERSION)"' typescript/package.json || \
{ echo "ERROR: TypeScript version does not match $(VERSION). Run 'make bump VERSION=$(VERSION)' first."; exit 1; }
@grep -qF 'VERSION = "$(VERSION)"' ruby/lib/basecamp/version.rb || \
{ echo "ERROR: Ruby version does not match $(VERSION). Run 'make bump VERSION=$(VERSION)' first."; exit 1; }
@grep -qF 'const val VERSION = "$(VERSION)"' kotlin/sdk/src/commonMain/kotlin/com/basecamp/sdk/BasecampConfig.kt || \
{ echo "ERROR: Kotlin version does not match $(VERSION). Run 'make bump VERSION=$(VERSION)' first."; exit 1; }
@grep -qF 'version = "$(VERSION)"' kotlin/sdk/build.gradle.kts || \
{ echo "ERROR: Kotlin Gradle project version does not match $(VERSION). Run 'make bump VERSION=$(VERSION)' first."; exit 1; }
@grep -qF 'public static let version = "$(VERSION)"' swift/Sources/Basecamp/BasecampConfig.swift || \
{ echo "ERROR: Swift version does not match $(VERSION). Run 'make bump VERSION=$(VERSION)' first."; exit 1; }
@grep -qF 'VERSION = "$(VERSION)"' python/src/basecamp/_version.py || \
{ echo "ERROR: Python version does not match $(VERSION). Run 'make bump VERSION=$(VERSION)' first."; exit 1; }
@git diff --quiet && git diff --cached --quiet || \
{ echo "ERROR: Working tree has uncommitted changes. Commit first."; exit 1; }
@# Verify we're on main — release tags must be on the default branch
@BRANCH=$$(git rev-parse --abbrev-ref HEAD); \
if [ "$$BRANCH" != "main" ]; then \
echo "ERROR: Must be on main branch to release (currently on $$BRANCH)."; exit 1; \
fi
@# Push main first — release workflows verify the tag commit is reachable from origin/main
git push origin main
git tag "v$(VERSION)"
git push origin "v$(VERSION)"
@echo "Pushed v$(VERSION) — all SDK release workflows will trigger."
# Sync Smithy service version from spec/api-provenance.json
sync-spec-version:
@./scripts/sync-spec-version.sh
# Check that the Smithy service version matches spec/api-provenance.json
sync-spec-version-check:
@echo "==> Checking Smithy service version freshness..."
@command -v jq > /dev/null 2>&1 || { echo "ERROR: jq not found. Install jq to run sync-spec-version-check (used by 'make check')."; exit 1; }
@PROVENANCE_DATE=$$(jq -r '.bc3_api.date' spec/api-provenance.json); \
BC3_DATE=$$(jq -r '.bc3.date' spec/api-provenance.json); \
SMITHY_VER=$$(sed -n 's/^ version: "\(.*\)"/\1/p' spec/basecamp.smithy | head -1); \
if [ -z "$$PROVENANCE_DATE" ] || [ "$$PROVENANCE_DATE" = "null" ]; then echo "ERROR: Could not read bc3_api.date from spec/api-provenance.json"; exit 1; fi; \
if [ -z "$$BC3_DATE" ] || [ "$$BC3_DATE" = "null" ]; then echo "ERROR: Could not read bc3.date from spec/api-provenance.json"; exit 1; fi; \
if [ "$$PROVENANCE_DATE" != "$$BC3_DATE" ]; then echo "ERROR: Provenance dates differ: bc3_api.date=$$PROVENANCE_DATE bc3.date=$$BC3_DATE"; exit 1; fi; \
if [ "$$SMITHY_VER" != "$$PROVENANCE_DATE" ]; then echo "ERROR: Smithy service version is out of date. Run 'make sync-spec-version'"; exit 1; fi
@echo "Smithy service version is up to date"
# Sync API_VERSION constants from openapi.json info.version
sync-api-version:
@./scripts/sync-api-version.sh
# Check that API_VERSION constants match openapi.json info.version
sync-api-version-check:
@echo "==> Checking API version freshness..."
@command -v jq > /dev/null 2>&1 || { echo "ERROR: jq not found. Install jq to run sync-api-version-check (used by 'make check')."; exit 1; }
@API_VER=$$(jq -r '.info.version' openapi.json); \
ok=true; \
grep -q "const APIVersion = \"$$API_VER\"" go/pkg/basecamp/version.go || ok=false; \
grep -q "export const API_VERSION = \"$$API_VER\"" typescript/src/client.ts || ok=false; \
grep -q "API_VERSION = \"$$API_VER\"" ruby/lib/basecamp/version.rb || ok=false; \
grep -q "const val API_VERSION = \"$$API_VER\"" kotlin/sdk/src/commonMain/kotlin/com/basecamp/sdk/BasecampConfig.kt || ok=false; \
grep -q "public static let apiVersion = \"$$API_VER\"" swift/Sources/Basecamp/BasecampConfig.swift || ok=false; \
grep -q "API_VERSION = \"$$API_VER\"" python/src/basecamp/_version.py || ok=false; \
if [ "$$ok" = false ]; then echo "ERROR: API_VERSION constants are out of date. Run 'make sync-api-version'"; exit 1; fi
@echo "API version constants are up to date"
#------------------------------------------------------------------------------
# Go SDK targets (delegates to go/Makefile)
#------------------------------------------------------------------------------
.PHONY: go-test go-lint go-check go-clean go-check-drift
go-test:
@$(MAKE) -C go test
go-lint:
@$(MAKE) -C go lint
go-check:
@$(MAKE) -C go check
go-clean:
@$(MAKE) -C go clean
# Check for drift between generated client and service layer
go-check-drift:
@echo "==> Checking service layer drift..."
@./scripts/check-service-drift.sh
#------------------------------------------------------------------------------
# TypeScript SDK targets
#------------------------------------------------------------------------------
.PHONY: ts-install ts-generate ts-generate-services ts-build ts-test ts-typecheck ts-check ts-clean
TS_NODE_STAMP := typescript/node_modules/.install-stamp
$(TS_NODE_STAMP): typescript/package-lock.json typescript/package.json
@echo "==> Installing TypeScript dependencies..."
cd typescript && npm ci
@touch $(TS_NODE_STAMP)
ts-install: $(TS_NODE_STAMP)
ts-generate: ts-install
ts-generate-services: ts-install
ts-build: ts-install
ts-test: ts-install
ts-typecheck: ts-install
# Generate TypeScript types and metadata from OpenAPI
ts-generate:
@echo "==> Generating TypeScript SDK..."
cd typescript && npm run generate
# Generate TypeScript services from OpenAPI
ts-generate-services:
@echo "==> Generating TypeScript services..."
cd typescript && npx tsx scripts/generate-services.ts
# Build TypeScript SDK
ts-build:
@echo "==> Building TypeScript SDK..."
cd typescript && npm run build
# Run TypeScript tests
ts-test:
@echo "==> Running TypeScript tests..."
cd typescript && npm run test
# Run TypeScript type checking
ts-typecheck:
@echo "==> Type checking TypeScript SDK..."
cd typescript && npm run typecheck
# Run all TypeScript checks
ts-check: ts-typecheck ts-test
@echo "==> TypeScript SDK checks passed"
# Clean TypeScript build artifacts
ts-clean:
@echo "==> Cleaning TypeScript SDK..."
rm -rf typescript/dist typescript/node_modules
#------------------------------------------------------------------------------
# Ruby SDK targets
#------------------------------------------------------------------------------
.PHONY: rb-generate rb-generate-services rb-build rb-test rb-check rb-doc rb-clean
# Generate Ruby types and metadata from OpenAPI
rb-generate:
@echo "==> Generating Ruby SDK types and metadata..."
cd ruby && ruby scripts/generate-metadata.rb > lib/basecamp/generated/metadata.json
cd ruby && ruby scripts/generate-types.rb > lib/basecamp/generated/types.rb
@echo "Generated lib/basecamp/generated/metadata.json and types.rb"
# Generate Ruby services from OpenAPI
rb-generate-services:
@echo "==> Generating Ruby services..."
cd ruby && ruby scripts/generate-services.rb
# Build Ruby SDK (install deps)
RB_STAMP := ruby/.bundle/.install-stamp
$(RB_STAMP): ruby/Gemfile ruby/Gemfile.lock ruby/basecamp-sdk.gemspec
@echo "==> Installing Ruby dependencies..."
cd ruby && bundle install
@mkdir -p $(dir $(RB_STAMP))
@touch $(RB_STAMP)
rb-build: $(RB_STAMP)
# Run Ruby tests
rb-test: rb-build
@echo "==> Running Ruby tests..."
cd ruby && bundle exec rake test
# Run all Ruby checks
rb-check: rb-test
@echo "==> Running Ruby linter..."
cd ruby && bundle exec rubocop
@echo "==> Ruby SDK checks passed"
# Generate Ruby documentation
rb-doc: rb-build
@echo "==> Generating Ruby documentation..."
cd ruby && bundle exec rake doc
@echo "Documentation generated in ruby/doc/"
# Clean Ruby build artifacts
rb-clean:
@echo "==> Cleaning Ruby SDK..."
rm -rf ruby/.bundle ruby/vendor ruby/doc ruby/coverage
#------------------------------------------------------------------------------
# Python SDK targets
#------------------------------------------------------------------------------
.PHONY: py-generate py-generate-services py-build py-test py-typecheck py-check py-check-drift py-clean
py-generate: py-generate-services
cd python && uv run python scripts/generate_types.py
cd python && uv run python scripts/generate_metadata.py
cd python && uv run ruff format src/basecamp/generated/
py-generate-services:
cd python && uv run python scripts/generate_services.py
py-build:
cd python && uv sync --dev
py-test:
cd python && uv run pytest --cov --cov-report=term-missing --cov-fail-under=60
py-typecheck:
cd python && uv run mypy src/basecamp/ --ignore-missing-imports
py-check: py-check-drift py-test py-typecheck
cd python && uv run ruff check src/ tests/
cd python && uv run ruff format --check src/ tests/
py-check-drift:
@echo "==> Checking Python service drift..."
@./scripts/check-python-service-drift.sh
py-clean:
rm -rf python/dist python/.pytest_cache python/src/*.egg-info python/.venv
#------------------------------------------------------------------------------
# Conformance Test targets
#------------------------------------------------------------------------------
.PHONY: conformance conformance-go conformance-kotlin conformance-typescript conformance-ruby conformance-python conformance-build
# Build conformance test runner
conformance-build:
@echo "==> Building conformance test runner..."
cd conformance/runner/go && go build -o conformance-runner .
# Run Go conformance tests
conformance-go: conformance-build
@echo "==> Running Go conformance tests..."
cd conformance/runner/go && ./conformance-runner
# Run Kotlin conformance tests
conformance-kotlin:
@echo "==> Running Kotlin conformance tests..."
cd kotlin && ./gradlew :conformance:run
# Run TypeScript conformance tests
conformance-typescript:
@echo "==> Running TypeScript conformance tests..."
cd conformance/runner/typescript && npm ci && npm test
# Run Ruby conformance tests
conformance-ruby:
@echo "==> Running Ruby conformance tests..."
cd conformance/runner/ruby && bundle install --quiet && ruby runner.rb
# Run Python conformance tests
conformance-python:
@echo "==> Running Python conformance tests..."
cd conformance/runner/python && uv sync && uv run python runner.py
# Run all conformance tests
conformance: conformance-go conformance-kotlin conformance-typescript conformance-ruby conformance-python
@echo "==> Conformance tests passed"
#------------------------------------------------------------------------------
# Kotlin SDK targets
#------------------------------------------------------------------------------
.PHONY: kt-generate-services kt-build kt-test kt-check kt-check-drift kt-clean gradle-stop
# Generate Kotlin services from OpenAPI
kt-generate-services:
@echo "==> Generating Kotlin services..."
cd kotlin && ./gradlew :generator:run --args="--openapi ../openapi.json --behavior ../behavior-model.json --output sdk/src/commonMain/kotlin/com/basecamp/sdk/generated"
# Build Kotlin SDK
kt-build:
@echo "==> Building Kotlin SDK..."
cd kotlin && ./gradlew :basecamp-sdk:build
# Run Kotlin tests
kt-test:
@echo "==> Running Kotlin tests..."
cd kotlin && ./gradlew :basecamp-sdk:check
# Run all Kotlin checks
kt-check: kt-test
@echo "==> Kotlin SDK checks passed"
# Check for drift between generated Kotlin services and OpenAPI spec
kt-check-drift:
@echo "==> Checking Kotlin service drift..."
@./scripts/check-kotlin-service-drift.sh
# Clean Kotlin build artifacts
kt-clean:
@echo "==> Cleaning Kotlin SDK..."
cd kotlin && ./gradlew clean
# Stop any lingering Gradle daemons
gradle-stop:
-cd kotlin && ./gradlew --stop
-cd spec/smithy-bare-arrays && ./gradlew --stop
#------------------------------------------------------------------------------
# Swift SDK targets (delegates to swift/Makefile)
#------------------------------------------------------------------------------
HAS_SWIFT := $(shell command -v swift 2>/dev/null)
IS_MACOS := $(filter Darwin,$(shell uname -s))
.PHONY: swift-build swift-test swift-check swift-clean swift-generate
# Build Swift SDK (macOS only — SDK requires Apple platforms)
swift-build:
ifdef IS_MACOS
@$(MAKE) -C swift build
else
@echo "SKIP: swift-build (macOS only)"
endif
# Run Swift tests (macOS only)
swift-test:
ifdef IS_MACOS
@$(MAKE) -C swift test
else
@echo "SKIP: swift-test (macOS only)"
endif
# Run all Swift checks (macOS only)
swift-check:
ifdef IS_MACOS
@$(MAKE) -C swift check
else
@echo "SKIP: swift-check (macOS only)"
endif
# Regenerate Swift SDK services from OpenAPI spec (needs swift on any platform)
swift-generate:
ifdef HAS_SWIFT
@$(MAKE) -C swift generate
else
$(error swift is required for swift-generate but was not found)
endif
# Clean Swift build artifacts
swift-clean:
ifdef HAS_SWIFT
@$(MAKE) -C swift clean
else
rm -rf swift/.build
endif
#------------------------------------------------------------------------------
# GitHub Actions lint targets
#------------------------------------------------------------------------------
.PHONY: lint-actions
# Lint GitHub Actions workflows (requires actionlint + zizmor)
lint-actions:
@command -v actionlint >/dev/null || (echo "Install actionlint: go install github.com/rhysd/actionlint/cmd/actionlint@latest" && exit 1)
@command -v zizmor >/dev/null || (echo "Install zizmor: https://docs.zizmor.sh/installation/" && exit 1)
actionlint
zizmor .
#------------------------------------------------------------------------------
# Setup & tool installation
#------------------------------------------------------------------------------
.PHONY: setup tools
# One-command setup for a fresh clone: install runtimes + dev tools
setup:
@command -v mise >/dev/null 2>&1 || { echo "ERROR: mise not found. Install: https://mise.jdx.dev"; exit 1; }
mise install
mise exec -- $(MAKE) tools
# Pinned tool versions — update these when bumping tools
SMITHY_CLI_VERSION := 1.68.0
GOLANGCI_LINT_VERSION := v2.11.4
ACTIONLINT_VERSION := v1.7.11
# Install development tools and prerequisites
tools:
@echo "==> Installing Smithy CLI..."
@command -v smithy >/dev/null 2>&1 || { \
if command -v brew >/dev/null 2>&1; then brew tap smithy-lang/tap && brew install smithy-cli; \
elif [ "$$(uname -s)" = "Linux" ]; then \
command -v curl >/dev/null 2>&1 || { echo "ERROR: curl is required"; exit 1; }; \
command -v unzip >/dev/null 2>&1 || { echo "ERROR: unzip is required"; exit 1; }; \
ARCH=$$(uname -m); \
case "$$ARCH" in x86_64) SUFFIX=linux-x86_64;; aarch64) SUFFIX=linux-aarch64;; *) echo "Unsupported arch: $$ARCH" && exit 1;; esac; \
TMPDIR=$$(mktemp -d) && \
trap 'rm -rf "$$TMPDIR"' EXIT && \
echo "Downloading smithy-cli-$$SUFFIX..." && \
curl -fsSL "https://github.com/smithy-lang/smithy/releases/download/$(SMITHY_CLI_VERSION)/smithy-cli-$$SUFFIX.zip" -o "$$TMPDIR/smithy.zip" && \
unzip -qo "$$TMPDIR/smithy.zip" -d "$$TMPDIR" && \
sudo "$$TMPDIR/smithy-cli-$$SUFFIX/install"; \
else echo "Install Smithy CLI: https://smithy.io/2.0/guides/smithy-cli/cli_installation.html" && exit 1; \
fi; \
}
@echo "==> Installing Go tools..."
@command -v go >/dev/null 2>&1 || { echo "ERROR: go not found. Run 'make setup' or install Go first."; exit 1; }
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
go install github.com/rhysd/actionlint/cmd/actionlint@$(ACTIONLINT_VERSION)
@command -v zizmor >/dev/null 2>&1 || { \
echo "==> Installing zizmor..."; \
if command -v brew >/dev/null 2>&1; then brew install zizmor; \
elif command -v pacman >/dev/null 2>&1; then sudo pacman -S --noconfirm zizmor; \
elif command -v pip3 >/dev/null 2>&1; then pip3 install zizmor; \
else echo "Install zizmor: https://docs.zizmor.sh/installation/" && exit 1; \
fi; \
}
@command -v jq >/dev/null 2>&1 || { \
echo "==> Installing jq..."; \
if command -v brew >/dev/null 2>&1; then brew install jq; \
elif command -v pacman >/dev/null 2>&1; then sudo pacman -S --noconfirm jq; \
elif command -v apt-get >/dev/null 2>&1; then sudo apt-get install -y jq; \
else echo "ERROR: jq is required. Install via your package manager." && exit 1; \
fi; \
}
@command -v node >/dev/null 2>&1 || echo "NOTE: node/npm is required for the TypeScript SDK"
@command -v ruby >/dev/null 2>&1 || echo "NOTE: ruby/bundler is required for the Ruby SDK"
@command -v swift >/dev/null 2>&1 || echo "NOTE: swift is optional (macOS: xcode-select --install, Arch: yay -S swift-bin)"
@echo "==> Done"
#------------------------------------------------------------------------------
# Combined targets
#------------------------------------------------------------------------------
# Run all checks (Smithy + Go + TypeScript + Ruby + Kotlin + Swift + Python + Behavior Model + Conformance + Provenance + Actions lint)
check: lint-actions sync-spec-version-check smithy-check behavior-model-check provenance-check sync-api-version-check go-check-drift kt-check-drift go-check ts-check rb-check kt-check swift-check py-check conformance
@echo "==> All checks passed"
# Clean all build artifacts
clean: smithy-clean go-clean ts-clean rb-clean kt-clean swift-clean py-clean
# Help
help:
@echo "Basecamp SDK Makefile"
@echo ""
@echo "Smithy:"
@echo " smithy-validate Validate Smithy spec syntax"
@echo " smithy-mapper Build custom OpenAPI mapper JAR"
@echo " smithy-build Build OpenAPI from Smithy (updates openapi.json)"
@echo " smithy-check Verify openapi.json is up to date"
@echo " sync-spec-version Sync Smithy service version from provenance"
@echo " sync-spec-version-check Verify Smithy service version matches provenance"
@echo " smithy-clean Remove Smithy build artifacts"
@echo ""
@echo "Behavior Model:"
@echo " behavior-model Generate behavior-model.json from Smithy spec"
@echo " behavior-model-check Verify behavior-model.json is up to date"
@echo ""
@echo "URL Routes:"
@echo " url-routes Generate url-routes.json from OpenAPI spec"
@echo " url-routes-check Verify url-routes.json is up to date"
@echo ""
@echo "Go SDK:"
@echo " go-test Run Go tests"
@echo " go-lint Run Go linter"
@echo " go-check Run all Go checks"
@echo " go-check-drift Check service layer drift vs generated client"
@echo " go-clean Remove Go build artifacts"
@echo ""
@echo "TypeScript SDK:"
@echo " ts-generate Generate types and metadata from OpenAPI"
@echo " ts-generate-services Generate service classes from OpenAPI"
@echo " ts-build Build TypeScript SDK"
@echo " ts-test Run TypeScript tests"
@echo " ts-typecheck Run TypeScript type checking"
@echo " ts-check Run all TypeScript checks"
@echo " ts-clean Remove TypeScript build artifacts"
@echo ""
@echo "Kotlin SDK:"
@echo " kt-generate-services Generate service classes from OpenAPI"
@echo " kt-build Build Kotlin SDK"
@echo " kt-test Run Kotlin tests"
@echo " kt-check Run all Kotlin checks"
@echo " kt-check-drift Check service drift vs OpenAPI spec"
@echo " kt-clean Remove Kotlin build artifacts"
@echo " gradle-stop Stop any lingering Gradle daemons"
@echo ""
@echo "Swift SDK:"
@echo " swift-generate Generate service classes from OpenAPI"
@echo " swift-build Build Swift SDK"
@echo " swift-test Run Swift tests"
@echo " swift-check Run all Swift checks"
@echo " swift-clean Remove Swift build artifacts"
@echo ""
@echo "Conformance:"
@echo " conformance Run all conformance tests"
@echo " conformance-go Run Go conformance tests"
@echo " conformance-kotlin Run Kotlin conformance tests"
@echo " conformance-typescript Run TypeScript conformance tests"
@echo " conformance-ruby Run Ruby conformance tests"
@echo " conformance-python Run Python conformance tests"
@echo " conformance-build Build Go conformance test runner"
@echo ""
@echo "Ruby SDK:"
@echo " rb-generate Generate types and metadata from OpenAPI"
@echo " rb-generate-services Generate service classes from OpenAPI"
@echo " rb-build Build Ruby SDK (install deps)"
@echo " rb-test Run Ruby tests (with coverage)"
@echo " rb-check Run all Ruby checks"
@echo " rb-doc Generate YARD documentation"
@echo " rb-clean Remove Ruby build artifacts"
@echo ""
@echo "Python SDK:"
@echo " py-generate Generate types and metadata from OpenAPI"
@echo " py-generate-services Generate service classes from OpenAPI"
@echo " py-build Build Python SDK (install deps)"
@echo " py-test Run Python tests"
@echo " py-check Run all Python checks"
@echo " py-check-drift Check service drift vs OpenAPI spec"
@echo " py-clean Remove Python build artifacts"
@echo ""
@echo "Provenance:"
@echo " provenance-sync Copy provenance into Go package for go:embed"
@echo " provenance-check Verify Go embedded provenance is up to date"
@echo " sync-status Show upstream changes since last spec sync"
@echo ""
@echo "Version & Release:"
@echo " bump VERSION=x.y.z Bump SDK version across all languages"
@echo " sync-api-version Sync API_VERSION from openapi.json"
@echo " sync-api-version-check Verify API_VERSION constants are up to date"
@echo " release VERSION=x.y.z Tag and push a global release (triggers all SDK releases)"
@echo ""
@echo "GitHub Actions:"
@echo " lint-actions Lint GitHub Actions workflows (actionlint + zizmor)"
@echo ""
@echo "Setup:"
@echo " setup One-command setup (mise install + tools)"
@echo " tools Install development tools (smithy, golangci-lint, actionlint, zizmor)"
@echo ""
@echo "Combined:"
@echo " check Run all checks (Smithy + behavior-model/drift + Go + TypeScript + Ruby + Swift + Kotlin + Python + Conformance + Provenance + API version sync + Actions lint)"
@echo " clean Remove all build artifacts"
@echo " help Show this help"