Remove advanced templating option #4930
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: js | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| actions: write | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| node-version: [20, 22] | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY}} | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY}} | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY}} | |
| outputs: | |
| artifact-name: ${{ steps.artifact.outputs.name }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| registry-url: "https://registry.npmjs.org" | |
| - uses: pnpm/action-setup@v4 | |
| - name: "verify ci" | |
| shell: bash | |
| run: | | |
| make js-verify-ci | |
| - name: Determine artifact name | |
| id: artifact | |
| env: | |
| ARTIFACT_NAME: javascript-sdk-dev-${{ github.run_id }} | |
| run: | | |
| echo "Artifact: $ARTIFACT_NAME" | |
| echo "name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT" | |
| - name: Prepare artifact | |
| id: prepare_artifact | |
| working-directory: js | |
| shell: bash | |
| run: | | |
| mkdir -p artifacts | |
| PACKED_TARBALL=$(npm pack --pack-destination artifacts) | |
| echo "packed_tarball=$PACKED_TARBALL" >> "$GITHUB_OUTPUT" | |
| - name: Build and pack @braintrust/otel | |
| id: prepare_otel_artifact | |
| shell: bash | |
| run: | | |
| # Install the built braintrust package in otel-js to satisfy peer dependency | |
| BRAINTRUST_TARBALL=$(ls js/artifacts/braintrust-*.tgz | head -n 1) | |
| if [ -z "$BRAINTRUST_TARBALL" ]; then | |
| echo "Error: braintrust tarball not found" | |
| exit 1 | |
| fi | |
| echo "Using braintrust tarball: $BRAINTRUST_TARBALL" | |
| # Install braintrust and OpenTelemetry peer dependencies in otel-js directory for build | |
| # Use pnpm to match the workspace, with no-save flags to avoid modifying lockfile | |
| cd integrations/otel-js | |
| if ! npm_config_save=false npm_config_lockfile=false pnpm add \ | |
| file:../../$BRAINTRUST_TARBALL \ | |
| @opentelemetry/api@^1.9.0 \ | |
| @opentelemetry/core@^1.9.0 \ | |
| @opentelemetry/exporter-trace-otlp-http@^0.35.0 \ | |
| @opentelemetry/sdk-trace-base@^1.9.0; then | |
| echo "Error: Failed to install dependencies" | |
| exit 1 | |
| fi | |
| # Build the otel package | |
| pnpm run build | |
| # Pack the otel package | |
| PACKED_OTEL_TARBALL=$(npm pack --pack-destination ../../js/artifacts) | |
| echo "packed_otel_tarball=$PACKED_OTEL_TARBALL" >> "$GITHUB_OUTPUT" | |
| - name: Build and pack @braintrust/templates-nunjucks | |
| id: prepare_templates_nunjucks_artifact | |
| shell: bash | |
| run: | | |
| cd integrations/templates-nunjucks | |
| pnpm run build | |
| PACKED_NUNJUCKS_TARBALL=$(npm pack --pack-destination ../../js/artifacts) | |
| echo "packed_nunjucks_tarball=$PACKED_NUNJUCKS_TARBALL" >> "$GITHUB_OUTPUT" | |
| - name: List artifacts before upload | |
| shell: bash | |
| run: | | |
| echo "Braintrust tarball: ${{ steps.prepare_artifact.outputs.packed_tarball }}" | |
| echo "Otel tarball: ${{ steps.prepare_otel_artifact.outputs.packed_otel_tarball }}" | |
| echo "Templates-nunjucks tarball: ${{ steps.prepare_templates_nunjucks_artifact.outputs.packed_nunjucks_tarball }}" | |
| ls -la js/artifacts/ | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.artifact.outputs.name }}-${{ matrix.node-version }}-dist | |
| path: | | |
| js/artifacts/${{ steps.prepare_artifact.outputs.packed_tarball }} | |
| js/artifacts/${{ steps.prepare_otel_artifact.outputs.packed_otel_tarball }} | |
| js/artifacts/${{ steps.prepare_templates_nunjucks_artifact.outputs.packed_nunjucks_tarball }} | |
| retention-days: 1 | |
| api-compatibility: | |
| runs-on: ubuntu-latest | |
| # Run in parallel with build job | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node-version: [20] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history to access main branch for baseline | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| registry-url: "https://registry.npmjs.org" | |
| - uses: pnpm/action-setup@v4 | |
| - name: Get published braintrust version for cache key | |
| id: published-version | |
| shell: bash | |
| run: | | |
| PUBLISHED_VERSION=$(npm view braintrust version 2>/dev/null || echo "none") | |
| echo "version=$PUBLISHED_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Published version: $PUBLISHED_VERSION" | |
| - name: Cache API compatibility test tarball | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.npm/_cacache | |
| key: braintrust-tarball-${{ steps.published-version.outputs.version }}-${{ runner.os }} | |
| restore-keys: | | |
| braintrust-tarball-${{ steps.published-version.outputs.version }}- | |
| braintrust-tarball- | |
| - name: Build baseline from main branch for API compatibility | |
| shell: bash | |
| run: | | |
| # Save current state | |
| CURRENT_REF=$(git rev-parse HEAD) | |
| BASELINE_DIR="$HOME/braintrust-baseline" | |
| mkdir -p "$BASELINE_DIR" | |
| # Checkout main and build | |
| echo "Building baseline from main branch..." | |
| git checkout origin/main || { echo "Could not checkout main"; exit 0; } | |
| # Install and build main | |
| pnpm install --frozen-lockfile || { echo "Baseline install failed"; git checkout "$CURRENT_REF"; exit 0; } | |
| pnpm run build || { echo "Baseline build failed"; git checkout "$CURRENT_REF"; exit 0; } | |
| # Copy built .d.ts files to baseline directory | |
| if [ -d "js/dist" ]; then | |
| mkdir -p "$BASELINE_DIR/js/dist" | |
| cp js/dist/*.d.ts "$BASELINE_DIR/js/dist/" 2>/dev/null || true | |
| cp js/dist/*.d.mts "$BASELINE_DIR/js/dist/" 2>/dev/null || true | |
| echo "Copied main/browser dist files" | |
| fi | |
| if [ -d "js/dev/dist" ]; then | |
| mkdir -p "$BASELINE_DIR/js/dev/dist" | |
| cp js/dev/dist/*.d.ts "$BASELINE_DIR/js/dev/dist/" 2>/dev/null || true | |
| cp js/dev/dist/*.d.mts "$BASELINE_DIR/js/dev/dist/" 2>/dev/null || true | |
| echo "Copied dev dist files" | |
| fi | |
| if [ -d "js/util/dist" ]; then | |
| mkdir -p "$BASELINE_DIR/js/util/dist" | |
| cp js/util/dist/*.d.ts "$BASELINE_DIR/js/util/dist/" 2>/dev/null || true | |
| cp js/util/dist/*.d.mts "$BASELINE_DIR/js/util/dist/" 2>/dev/null || true | |
| echo "Copied util dist files" | |
| fi | |
| # Return to original commit | |
| git checkout "$CURRENT_REF" | |
| # Set environment variable for test to find baseline | |
| echo "BASELINE_DIR=$BASELINE_DIR" >> $GITHUB_ENV | |
| echo "Baseline created at $BASELINE_DIR" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build current branch | |
| run: pnpm run build | |
| - name: Run API compatibility test | |
| env: | |
| BASELINE_DIR: ${{ env.BASELINE_DIR }} | |
| run: | | |
| cd js && pnpm test:api-compat | |
| # Smoke v2: Auto-discovery of scenarios | |
| smoke-discover: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| scenarios: ${{ steps.discover.outputs.scenarios }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Discover scenarios | |
| id: discover | |
| working-directory: js/smoke | |
| shell: bash | |
| run: | | |
| echo "Discovering local and integration scenarios..." | |
| SCRIPTDIR="../../integrations" | |
| # Local scenarios (under js/smoke/scenarios): emit their directory names | |
| LOCAL=$(find scenarios -mindepth 1 -maxdepth 1 -type d -exec test -f {}/Makefile \; -print | sed 's|scenarios/||' | tr '\n' ' ') | |
| # Integration scenarios: emit as integration/name | |
| INTEGRATIONS=$(find "$SCRIPTDIR" -type f -path '*/scenarios/*/Makefile' 2>/dev/null | sed "s|^$SCRIPTDIR/||" | sed 's|/Makefile$$||' | sed 's|/scenarios/|/|' | tr '\n' ' ') | |
| ALL="${LOCAL} ${INTEGRATIONS}" | |
| # Convert space-separated list to JSON array | |
| SCENARIOS=$(printf "%s\n" $ALL | jq -R -s -c 'split("\n") | map(select(length>0))') | |
| echo "scenarios=$SCENARIOS" >> "$GITHUB_OUTPUT" | |
| echo "Discovered scenarios: $SCENARIOS" | |
| smoke-test: | |
| needs: [build, smoke-discover] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| scenario: ${{ fromJson(needs.smoke-discover.outputs.scenarios) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup mise | |
| uses: jdx/mise-action@v2 | |
| with: | |
| working_directory: js/smoke | |
| - uses: pnpm/action-setup@v4 | |
| - name: Download build artifact (node 20) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ needs.build.outputs.artifact-name }}-20-dist | |
| path: js/artifacts | |
| run-id: ${{ github.run_id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare artifacts at well-known paths | |
| working-directory: js/artifacts | |
| shell: bash | |
| run: | | |
| # Copy braintrust tarball to well-known path | |
| for f in braintrust-[0-9]*.tgz; do | |
| if [ -f "$f" ]; then | |
| cp "$f" braintrust-latest.tgz | |
| echo "Copied $f to braintrust-latest.tgz" | |
| break | |
| fi | |
| done | |
| # Copy otel tarball to well-known path | |
| for f in braintrust-otel-[0-9]*.tgz; do | |
| if [ -f "$f" ]; then | |
| cp "$f" braintrust-otel-latest.tgz | |
| echo "Copied $f to braintrust-otel-latest.tgz" | |
| break | |
| fi | |
| done | |
| # Copy templates-nunjucks-js tarball to well-known path | |
| for f in braintrust-templates-nunjucks-js-[0-9]*.tgz; do | |
| if [ -f "$f" ]; then | |
| cp "$f" braintrust-templates-nunjucks-js-latest.tgz | |
| echo "Copied $f to braintrust-templates-nunjucks-js-latest.tgz" | |
| break | |
| fi | |
| done | |
| - name: Build shared test package (once for all scenarios) | |
| working-directory: js/smoke/shared | |
| shell: bash | |
| run: | | |
| npm ci | |
| npm run build | |
| - name: Run scenario ${{ matrix.scenario }} | |
| working-directory: js/smoke | |
| shell: bash | |
| env: | |
| BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }} | |
| CI: true | |
| BRAINTRUST_TAR: ../artifacts/braintrust-latest.tgz | |
| BRAINTRUST_OTEL_TAR: ../artifacts/braintrust-otel-latest.tgz | |
| BRAINTRUST_TEMPLATES_NUNJUCKS_JS_TAR: ../artifacts/braintrust-templates-nunjucks-js-latest.tgz | |
| SMOKE_V2_SHARED_DIST: shared/dist | |
| run: | | |
| make test ${{ matrix.scenario }} |