Skip to content

Commit 9ec8e9d

Browse files
authored
Smoke v2 (#1283)
## Braintrust JS SDK Smoke Tests v2 ### Design Principles 1. **Well-Known Tarball Paths**: Uses version-agnostic paths like `braintrust-latest.tgz` so package.json never changes 2. **Build Before Install**: Ensures artifacts exist before npm tries to install them 3. **Track Lock Files**: Commits lock files to catch transitive dependency issues 4. **Makefile as Source of Truth**: Single clear interface (`make test`) for every scenario 5. **Expected Failures Support**: Uses `xfail` status to document known platform limitations without failing tests ### Quick Start ```bash # Run all scenarios make test # Run specific scenario make test otel-v1 # List available scenarios make list ``` ### What's Improved from v1 - ✅ No version-specific tarballs (eliminates package.json churn) - ✅ Peer dependencies fully specified (no `--legacy-peer-deps` workaround) - ✅ Auto-discovery (no manual registration) - ✅ Shared test package for DRY test logic - ✅ Lock files tracked (surfaces packaging issues early) This infrastructure ensures the Braintrust SDK "just works" across the JavaScript ecosystem's diverse runtime landscape.
1 parent 9108e84 commit 9ec8e9d

191 files changed

Lines changed: 5815 additions & 32359 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/js.yaml

Lines changed: 50 additions & 382 deletions
Large diffs are not rendered by default.

js/smoke/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

js/smoke/Makefile

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Auto-discover scenarios (any folder in scenarios/ with a Makefile)
2+
SCENARIOS := $(shell find scenarios -mindepth 1 -maxdepth 1 -type d -exec test -f {}/Makefile \; -print | sed 's|scenarios/||' | sort)
3+
4+
.PHONY: help setup test list clean
5+
6+
# =============================================================================
7+
# Help
8+
# =============================================================================
9+
10+
help:
11+
@echo "Smoke Test Infrastructure"
12+
@echo ""
13+
@echo "Available targets:"
14+
@echo " make test - Run all scenarios (builds SDK once if needed)"
15+
@echo " make test <scenario> - Run specific scenario (e.g., make test otel-v1)"
16+
@echo " make setup - Ensure SDK artifacts + shared package are ready"
17+
@echo " make clean - Remove all build artifacts (force rebuild)"
18+
@echo " make list - List discovered scenarios"
19+
@echo ""
20+
@echo "Environment variables:"
21+
@echo " BRAINTRUST_TAR - Path to braintrust tarball (auto-set by parent when running locally)"
22+
@echo " BRAINTRUST_OTEL_TAR - Path to otel tarball (auto-set by parent when running locally)"
23+
@echo " SMOKE_V2_SHARED_DIST - Path to shared package dist (auto-set by parent when running locally)"
24+
@echo ""
25+
@echo "Running individual scenarios:"
26+
@echo " cd scenarios/otel-v1 && make test - Runs standalone, builds if needed"
27+
@echo ""
28+
@echo "Discovered scenarios:"
29+
@for scenario in $(SCENARIOS); do echo " - $$scenario"; done
30+
31+
# =============================================================================
32+
# Setup - Build SDK + shared package
33+
# =============================================================================
34+
35+
setup:
36+
@echo "==> Setting up smoke"
37+
@mkdir -p ../artifacts
38+
39+
@# Build SDK and create tarball if not provided
40+
@if [ -n "$(BRAINTRUST_TAR)" ] && [ -f "$(BRAINTRUST_TAR)" ]; then \
41+
echo "==> Using provided BRAINTRUST_TAR: $(BRAINTRUST_TAR)"; \
42+
else \
43+
echo "==> Building SDK and creating tarball"; \
44+
cd ../../.. && pnpm exec turbo build --filter=braintrust && pnpm --filter=braintrust pack --pack-destination sdk/js/artifacts; \
45+
\
46+
for f in sdk/js/artifacts/braintrust-*.tgz; do \
47+
if [ "$$(basename $$f)" != "braintrust-latest.tgz" ] && \
48+
[ "$$(basename $$f)" != "braintrust-otel-latest.tgz" ]; then \
49+
cp "$$f" sdk/js/artifacts/braintrust-latest.tgz; \
50+
break; \
51+
fi; \
52+
done; \
53+
fi
54+
55+
@# Build shared package if not provided
56+
@if [ -n "$(SMOKE_V2_SHARED_DIST)" ] && [ -d "$(SMOKE_V2_SHARED_DIST)" ]; then \
57+
echo "==> Using provided SMOKE_V2_SHARED_DIST: $(SMOKE_V2_SHARED_DIST)"; \
58+
else \
59+
if [ ! -d shared/dist ]; then \
60+
echo "==> Building shared package"; \
61+
cd shared && npm ci && npm run build; \
62+
else \
63+
echo "==> Shared package already built"; \
64+
fi; \
65+
fi
66+
67+
# =============================================================================
68+
# Clean - Remove all build artifacts
69+
# =============================================================================
70+
71+
clean:
72+
@echo "==> Cleaning smoke artifacts"
73+
rm -rf ../artifacts/*.tgz
74+
rm -rf shared/dist shared/node_modules
75+
76+
# =============================================================================
77+
# Test - Run scenarios
78+
# =============================================================================
79+
80+
test:
81+
@REQUESTED="$(filter-out test,$(MAKECMDGOALS))"; \
82+
\
83+
if [ -z "$$REQUESTED" ]; then \
84+
SCENARIOS_TO_RUN="$(SCENARIOS)"; \
85+
echo "==> Running all scenarios"; \
86+
else \
87+
SCENARIOS_TO_RUN=""; \
88+
for scenario in $$REQUESTED; do \
89+
if [ ! -d "scenarios/$$scenario" ]; then \
90+
echo "Error: Scenario '$$scenario' not found"; \
91+
echo "Available scenarios:"; \
92+
for s in $(SCENARIOS); do echo " - $$s"; done; \
93+
exit 1; \
94+
fi; \
95+
SCENARIOS_TO_RUN="$$SCENARIOS_TO_RUN $$scenario"; \
96+
done; \
97+
echo "==> Running scenarios:$$SCENARIOS_TO_RUN"; \
98+
fi; \
99+
\
100+
$(MAKE) setup; \
101+
\
102+
: $${BRAINTRUST_TAR:=../artifacts/braintrust-latest.tgz}; \
103+
: $${BRAINTRUST_OTEL_TAR:=../artifacts/braintrust-otel-latest.tgz}; \
104+
: $${SMOKE_V2_SHARED_DIST:=shared/dist}; \
105+
export BRAINTRUST_TAR BRAINTRUST_OTEL_TAR SMOKE_V2_SHARED_DIST; \
106+
\
107+
for scenario in $$SCENARIOS_TO_RUN; do \
108+
echo ""; \
109+
echo "=== Testing $$scenario ==="; \
110+
$(MAKE) -C scenarios/$$scenario test || exit 1; \
111+
done; \
112+
\
113+
echo ""; \
114+
echo "✓ All requested scenarios passed"
115+
116+
# =============================================================================
117+
# List - Show discovered scenarios
118+
# =============================================================================
119+
120+
list:
121+
@echo "Discovered scenarios:"
122+
@for scenario in $(SCENARIOS); do echo " - $$scenario"; done
123+
124+
# =============================================================================
125+
# Make scenario names valid targets (no-ops to support "make test otel-v1")
126+
# =============================================================================
127+
128+
$(SCENARIOS):
129+
@:

0 commit comments

Comments
 (0)