-
Notifications
You must be signed in to change notification settings - Fork 1.5k
211 lines (204 loc) · 8.52 KB
/
Copy pathsdk-nodejs.yml
File metadata and controls
211 lines (204 loc) · 8.52 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
# Invoked by sdk.yml to run Node.js SDK builds, tests, packaging checks,
# documentation validation, full subprocess coverage, and focused in-process
# smoke coverage on standard platforms and x64 musl.
name: "SDK Node.js"
env:
HUSKY: 0
POWERSHELL_UPDATECHECK: Off
SDK_HOME: ${{ inputs.sdk-home }}
SETUP_NODE_TIMEOUT_MINUTES: 10
on:
workflow_call:
inputs:
platform:
required: false
type: string
default: all
sdk-home:
required: true
type: string
outputs:
capi-result:
description: "Standard-platform CAPI job result, independent of BYOK jobs"
# Direct result outputs can be empty: https://github.com/actions/runner/issues/2495
value: ${{ fromJSON(toJSON(jobs.nodejs)).result }}
permissions:
contents: read
jobs:
nodejs:
name: "Node.js (${{ matrix.os }}, CAPI)"
if: contains(fromJSON('["all","linux-x64","darwin-arm64","win32-x64"]'), inputs.platform)
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(inputs.platform == 'linux-x64' && '["ubuntu-latest"]' || inputs.platform == 'darwin-arm64' && '["macos-latest"]' || inputs.platform == 'win32-x64' && '["windows-latest"]' || '["ubuntu-latest","macos-latest","windows-latest"]') }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: ${{ inputs.sdk-home }}/nodejs
steps:
- uses: actions/checkout@v7
timeout-minutes: 4
with:
persist-credentials: false
- uses: ./.github/actions/download-sdk-runtime
with:
artifact-name: ${{ runner.os == 'Linux' && format('executable-sdk-{0}-{1}-gnu', runner.os, runner.arch) || format('executable-sdk-{0}-{1}', runner.os, runner.arch) }}
path: ${{ github.workspace }}
- run: node "$SDK_HOME/scripts/ci/runtime-artifact.mjs" restore && node "$SDK_HOME/scripts/ci/runtime-artifact.mjs" prepare
working-directory: .
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
cache-dependency-path: ${{ inputs.sdk-home }}/nodejs/package-lock.json
- run: npm ci --ignore-scripts
- name: Install generator test dependencies
run: npm ci --ignore-scripts
working-directory: ${{ inputs.sdk-home }}/scripts/codegen
# TEMPORARY MERGE QUEUE REDUCTION: pull requests and main pushes retain
# static checks; merge groups rerun only SDK compatibility coverage.
- if: github.event_name != 'merge_group' && runner.os == 'Linux'
run: npm run format:check
- if: github.event_name != 'merge_group' && runner.os == 'Linux'
run: npm run lint
- if: github.event_name != 'merge_group' && runner.os == 'Linux'
run: npm run typecheck
- run: npm run build
- if: runner.os == 'Linux'
env:
COPILOT_SDK_RUNTIME_PLATFORMS: linux-x64
run: |
npm run pack:release
npm run verify:release-packages
- run: npm ci --ignore-scripts
working-directory: ${{ inputs.sdk-home }}/test/harness
- if: runner.os == 'Linux'
run: npm test
working-directory: ${{ inputs.sdk-home }}/test/harness
- if: runner.os == 'Linux'
run: npm ci
working-directory: ${{ inputs.sdk-home }}/scripts/corrections
- if: runner.os == 'Linux'
run: npm test
working-directory: ${{ inputs.sdk-home }}/scripts/corrections
- if: runner.os == 'Windows'
run: pwsh.exe -Command "Write-Host 'PowerShell ready'"
- name: Test out-of-process
id: subprocess
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
run: |
if [ "$GITHUB_EVENT_NAME" = "merge_group" ]; then
npm test -- --reporter=default --reporter=json --outputFile="$RUNNER_TEMP/sdk-nodejs-results.json"
else
npm test
fi
- name: Upload merge-queue Node.js test results
if: always() && github.event_name == 'merge_group' && runner.os == 'Linux'
continue-on-error: true
uses: actions/upload-artifact@v7
with:
name: suspected-flakes-sdk-nodejs-${{ github.run_attempt }}-linux
path: ${{ runner.temp }}/sdk-nodejs-results.json
if-no-files-found: warn
retention-days: 7
- name: Test in-process smoke
if: ${{ !cancelled() && github.event_name != 'merge_group' && (steps.subprocess.outcome == 'success' || steps.subprocess.outcome == 'failure') }}
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
COPILOT_SDK_DEFAULT_CONNECTION: inprocess
run: npm test -- test/e2e/inprocess_ffi.e2e.test.ts test/e2e/auth_host.e2e.test.ts
- name: Validate documentation examples
if: github.event_name != 'merge_group' && runner.os == 'Linux'
working-directory: ${{ inputs.sdk-home }}/scripts/docs-validation
run: |
npm ci
npm run extract
npm run validate:ts
# Keep each BYOK backend on its own runner; shared runtime E2E coverage belongs
# in TypeScript rather than repeating these sweeps across SDK languages.
nodejs-backends:
name: "Node.js (ubuntu-latest, ${{ matrix.backend }})"
if: github.event_name != 'merge_group' && (inputs.platform == 'all' || inputs.platform == 'linux-x64')
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
backend: [anthropic-messages, openai-responses, openai-completions]
defaults:
run:
shell: bash
working-directory: ${{ inputs.sdk-home }}/nodejs
env:
COPILOT_SDK_E2E_BACKEND: ${{ matrix.backend }}
steps:
- uses: actions/checkout@v7
timeout-minutes: 4
with:
persist-credentials: false
- uses: ./.github/actions/download-sdk-runtime
with:
artifact-name: executable-sdk-Linux-X64-gnu
path: ${{ github.workspace }}
- run: node "$SDK_HOME/scripts/ci/runtime-artifact.mjs" restore && node "$SDK_HOME/scripts/ci/runtime-artifact.mjs" prepare
working-directory: .
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
cache-dependency-path: ${{ inputs.sdk-home }}/nodejs/package-lock.json
- run: npm ci --ignore-scripts
- run: npm run build
- run: npm ci --ignore-scripts
working-directory: ${{ inputs.sdk-home }}/test/harness
- name: Test out-of-process E2Es
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
run: npm test -- test/e2e
nodejs-musl-x64:
name: "Node.js (Alpine x64, CAPI)"
if: inputs.platform == 'all' || inputs.platform == 'linuxmusl-x64'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
timeout-minutes: 4
with:
persist-credentials: false
- uses: ./.github/actions/download-sdk-runtime
with:
artifact-name: executable-sdk-Linux-X64-musl
path: ${{ github.workspace }}
- run: node "$SDK_HOME/scripts/ci/runtime-artifact.mjs" restore
working-directory: .
- uses: ./.github/actions/run-alpine-tests
env:
COPILOT_HMAC_KEY: ${{ secrets.COPILOT_DEVELOPER_CLI_INTEGRATION_HMAC_KEY }}
with:
image: node:22-alpine
sdk-root: /workspace/${{ inputs.sdk-home }}
workdir: /workspace/${{ inputs.sdk-home }}/nodejs
command: |
npm ci --ignore-scripts
(cd "$COPILOT_SDK_ROOT/scripts/codegen" && npm ci --ignore-scripts)
npm run build
(cd "$COPILOT_SDK_ROOT/test/harness" && npm ci --ignore-scripts)
export GITHUB_ENV=/tmp/copilot-sdk-runtime.env
export COPILOT_RUNTIME_TARGET=linuxmusl-x64
export COPILOT_RUNTIME_OUTPUT_DIRECTORY=/workspace/.sdk-runtime/linuxmusl-x64
node "$COPILOT_SDK_ROOT/scripts/ci/runtime-artifact.mjs" prepare
set -a
. "$GITHUB_ENV"
set +a
case "$COPILOT_CLI_PATH" in
*/prebuilds/linuxmusl-x64/copilot-runtime) ;;
*) echo "Expected the linuxmusl-x64 runtime, got: $COPILOT_CLI_PATH" >&2; exit 1 ;;
esac
test -x "$COPILOT_CLI_PATH"
test -f "$(dirname "$COPILOT_CLI_PATH")/runtime.node"
status=0
npm test || status=$?
COPILOT_SDK_DEFAULT_CONNECTION=inprocess npm test -- test/e2e/inprocess_ffi.e2e.test.ts test/e2e/auth_host.e2e.test.ts || status=$?
exit "$status"