Skip to content

Commit 5455c2a

Browse files
committed
workflow params
1 parent 1f6a9a3 commit 5455c2a

3 files changed

Lines changed: 69 additions & 16 deletions

File tree

‎.github/workflows/js.yaml‎

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
os: [ubuntu-latest]
20-
node-version: [22]
19+
os: [ubuntu-latest, windows-latest]
20+
node-version: [20, 22]
2121

2222
env:
2323
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY}}
2424
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY}}
2525
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY}}
2626

27+
outputs:
28+
artifact-name: ${{ steps.artifact.outputs.name }}
29+
2730
steps:
2831
- uses: actions/checkout@v4
2932
- uses: actions/setup-node@v4
@@ -32,20 +35,35 @@ jobs:
3235
registry-url: "https://registry.npmjs.org"
3336
- uses: pnpm/action-setup@v4
3437
- name: "verify ci"
38+
shell: bash
39+
run: |
40+
npm install
41+
npm run build
42+
43+
- name: Determine artifact name
44+
id: artifact
45+
env:
46+
ARTIFACT_NAME: javascript-sdk-dev-${{ github.run_id }}
3547
run: |
36-
pnpm install
37-
pnpm run build
48+
echo "Artifact: $ARTIFACT_NAME"
49+
echo "name=$ARTIFACT_NAME" >> "$GITHUB_OUTPUT"
3850
- name: Upload build artifacts
39-
if: matrix.node-version == '22' && matrix.os == 'ubuntu-latest'
4051
uses: actions/upload-artifact@v4
4152
with:
42-
name: javascript-sdk-dev-${{ github.run_id }}-${{ matrix.node-version }}-dist
53+
name: ${{ steps.artifact.outputs.name }}-${{ matrix.os }}-${{ matrix.node-version }}-dist
4354
path: js/dist/
4455
retention-days: 1
4556

4657
integration-tests:
4758
needs: build
4859
runs-on: ubuntu-latest
60+
61+
strategy:
62+
fail-fast: false
63+
matrix:
64+
os: [ubuntu-latest, windows-latest]
65+
node-version: [20, 22]
66+
4967
steps:
5068
- name: Checkout repository
5169
uses: actions/checkout@v4
@@ -56,55 +74,72 @@ jobs:
5674
- name: Backup original NodeSDK package.json
5775
working-directory: js/examples/otel
5876
run: cp package.json package.json.bak
59-
60-
- name: Determine artifact name
77+
78+
- name: artifact name
6179
id: artifact
62-
run: echo "ARTIFACT_NAME=javascript-sdk-dev-${{ github.run_id }}-22-dist" >> $GITHUB_ENV
80+
run: |
81+
echo "Artifact: ${{ needs.build.outputs.artifact-name }}-${{ matrix.os }}-${{ matrix.node-version }}-dist"
82+
echo "name=${{ needs.build.outputs.artifact-name }}-${{ matrix.os }}-${{ matrix.node-version }}-dist" >> "$GITHUB_OUTPUT"
6383
6484
- name: Download javascript dist artifact
6585
uses: actions/download-artifact@v4
6686
with:
6787
name: ${{ steps.artifact.outputs.name }}
6888
path: js/artifacts
69-
run-id: ${{ inputs.build_run_id }}
89+
run-id: ${{ github.run_id }}
7090
github-token: ${{ secrets.GITHUB_TOKEN }}
7191

7292
- name: Setup Node.js
7393
uses: actions/setup-node@v4
7494
with:
7595
node-version: 22
7696

97+
- name: Temporarily point braintrust dependency to local build
98+
working-directory: js/examples/otel
99+
run: |
100+
# Modify package.json to point 'braintrust' to local artifact
101+
cat "file:../../artifacts/${{ steps.artifact.outputs.name }}"
102+
ls -la ../../artifacts/${{ steps.artifact.outputs.name }}
103+
jq --arg path "file:../../artifacts/${{ steps.artifact.outputs.name }}" '.dependencies.braintrust = $path' package.json > package.temp.json
104+
mv package.temp.json package.json
105+
cat package.json
106+
77107
- name: Install example dependencies
78108
working-directory: js/examples/otel
79-
run: npm install
109+
run: npm install --force
110+
111+
- name: Run CJS check
112+
working-directory: scripts
113+
run: ./verify_cjs.sh
80114

81115
- name: Run NodeSDK as CJS example
82116
working-directory: js/examples/otel
83117
env:
84118
BRAINTRUST_OTEL_COMPAT: false
85119
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
86-
NODE_PATH: ../../artifacts
87120
run: |
88-
node -e "console.log('CJS mode:', typeof require !== 'undefined')"
89121
npm start
90122
91123
- name: Enable ESM for this run
92124
working-directory: js/examples/otel
93125
run: |
94126
jq '. + {"type":"module"}' package.json > package.temp.json
95127
mv package.temp.json package.json
128+
cat package.json
129+
130+
- name: Run ESM check
131+
working-directory: scripts
132+
run: ./verify_esm.sh
96133

97134
- name: Run NodeSDK as ESM example
98135
working-directory: js/examples/otel
99136
env:
100137
BRAINTRUST_OTEL_COMPAT: false
101138
BRAINTRUST_API_KEY: ${{ secrets.BRAINTRUST_API_KEY }}
102-
NODE_PATH: ../../artifacts
103139
run: |
104-
node -e "console.log('ESM mode:', typeof import.meta.url === 'string')"
105140
npm start
106141
107142
- name: Restore original package.json
108143
if: always()
109144
working-directory: js/examples/otel
110-
run: mv package.json.bak package.json
145+
run: mv package.json.bak package.json

‎scripts/verify_cjs.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
node -e '
3+
if (typeof require === "undefined") {
4+
console.error("Error: Not running in CommonJS");
5+
process.exit(1);
6+
} else {
7+
console.log("Running in CommonJS");
8+
}
9+
'

‎scripts/verify_esm.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
node -e '
3+
if (typeof import.meta.url !== "string") {
4+
console.error("Error: Not running in ESM");
5+
process.exit(1);
6+
} else {
7+
console.log("Running in ESM");
8+
}
9+
'

0 commit comments

Comments
 (0)