Skip to content

Commit 570ae11

Browse files
authored
Use GitHub Releases for SDK runtime artifacts (#2505)
* Use CLI release artifacts across SDKs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: daec7b3b-799c-4396-b372-6eb638d0faf8 * Trim runtime migration scope Remove Java and Rust changes because those SDKs were already release-backed, simplify Python's direct runtime staging, and drop the misleading .NET npm URL alias. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: daec7b3b-799c-4396-b372-6eb638d0faf8 * Remove Java Copilot npm consumption Fetch Java codegen schemas from the checksum-verified CLI release artifact and use the shared release-backed CLI setup for smoke tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: daec7b3b-799c-4396-b372-6eb638d0faf8 * Address runtime migration review feedback Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: daec7b3b-799c-4396-b372-6eb638d0faf8 * Reuse prepared runtime in Python E2E tests Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: daec7b3b-799c-4396-b372-6eb638d0faf8 * Address incremental review feedback Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: daec7b3b-799c-4396-b372-6eb638d0faf8 --------- Copilot-Session: daec7b3b-799c-4396-b372-6eb638d0faf8
1 parent 53e74d8 commit 570ae11

33 files changed

Lines changed: 1322 additions & 980 deletions

‎.github/actions/setup-copilot/action.yml‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ outputs:
44
cli-path:
55
description: "Path to the Copilot CLI"
66
value: ${{ steps.cli-path.outputs.path }}
7+
javascript-cli-path:
8+
description: "Path to the JavaScript Copilot CLI entrypoint"
9+
value: ${{ steps.cli-path.outputs.javascript-path }}
710
runs:
811
using: "composite"
912
steps:
@@ -28,10 +31,14 @@ runs:
2831
echo "Could not prepare the Copilot CLI runtime" >&2
2932
exit 1
3033
fi
34+
javascript_cli_path=$(npm --prefix "$(pwd)/nodejs" run --silent prepare:runtime -- --print-legacy-path)
35+
if [ -z "$javascript_cli_path" ]; then
36+
echo "Could not prepare the Copilot CLI JavaScript entrypoint" >&2
37+
exit 1
38+
fi
3139
echo "path=$cli_path" >> $GITHUB_OUTPUT
40+
echo "javascript-path=$javascript_cli_path" >> $GITHUB_OUTPUT
3241
shell: bash
3342
- name: Verify CLI works
34-
run: |
35-
legacy_cli=$(npm --prefix "$(pwd)/nodejs" run --silent prepare:runtime -- --print-legacy-path)
36-
node "$legacy_cli" --version
43+
run: node "${{ steps.cli-path.outputs.javascript-path }}" --version
3744
shell: bash

‎.github/workflows/java-adapt-handwritten-code-to-accept-upgrade-changes.lock.yml‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/java-adapt-handwritten-code-to-accept-upgrade-changes.md‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: |
33
Adapt handwritten Java SDK code to work with regenerated types after a
4-
@github/copilot version bump. Assumes codegen succeeded and generated code
4+
Copilot CLI release update. Assumes codegen succeeded and generated code
55
compiles. Fixes handwritten source and tests only.
66
77
on:
@@ -45,14 +45,13 @@ safe-outputs:
4545

4646
# Java Handwritten Code Adaptation After CLI Upgrade
4747

48-
You are an automation agent that fixes handwritten Java SDK source and test code after a `@github/copilot` version bump has regenerated the typed schemas.
48+
You are an automation agent that fixes handwritten Java SDK source and test code after a Copilot CLI release update has regenerated the typed schemas.
4949

5050
## Assumptions
5151

5252
- The branch `${{ inputs.branch }}` already has:
53-
- Updated `java/scripts/codegen/package.json` with the new version
53+
- Updated the shared CLI release pin in `nodejs/package.json`
5454
- Regenerated `java/sdk/src/generated/java/` code that compiles successfully
55-
- Updated the Java POM CLI/version pin property
5655
- Your job is ONLY to fix **handwritten** code, NOT generated code.
5756

5857
## Boundaries
@@ -147,7 +146,7 @@ If this passes, commit and push:
147146

148147
```bash
149148
git add java/sdk/src/main/java java/sdk/src/test/java
150-
git commit -m "Fix handwritten Java code for @github/copilot schema changes
149+
git commit -m "Fix handwritten Java code for CLI schema changes
151150
152151
Adapt constructor calls, enum references, and test assertions to match
153152
regenerated types after CLI version bump."

‎.github/workflows/java-codegen-check.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ on:
55
branches:
66
- main
77
paths:
8+
- 'nodejs/package.json'
89
- 'java/scripts/codegen/**'
910
- 'java/sdk/src/generated/**'
1011
- '.github/workflows/java-codegen-check.yml'
1112
pull_request:
1213
paths:
14+
- 'nodejs/package.json'
1315
- 'java/scripts/codegen/**'
1416
- 'java/sdk/src/generated/**'
1517
- '.github/workflows/java-codegen-check.yml'
@@ -48,9 +50,13 @@ jobs:
4850
working-directory: ./java/scripts/codegen
4951
run: npm ci
5052

53+
- name: Test schema fetcher
54+
working-directory: ./java/scripts/codegen
55+
run: npm test
56+
5157
- name: Run codegen
5258
working-directory: ./java/scripts/codegen
53-
run: npx tsx java.ts
59+
run: npm run generate
5460

5561
- name: Check for uncommitted changes
5662
id: check-changes
@@ -68,7 +74,7 @@ jobs:
6874
- name: Fail on stale generated files (push to main)
6975
if: steps.check-changes.outputs.changed == 'true' && github.event_name != 'pull_request'
7076
run: |
71-
echo "::error::Generated files are out of date. Run 'cd java/scripts/codegen && npx tsx java.ts' and commit the changes."
77+
echo "::error::Generated files are out of date. Run 'cd java/scripts/codegen && npm run generate' and commit the changes."
7278
git diff
7379
exit 1
7480
@@ -93,7 +99,7 @@ jobs:
9399
if: steps.push-regen.outcome == 'failure'
94100
run: |
95101
echo "::error::Could not push regenerated files to the PR branch. This is expected for Dependabot PRs (read-only token) and fork PRs."
96-
echo "To fix: check out this PR branch locally, run 'cd java/scripts/codegen && npx tsx java.ts', commit, and push."
102+
echo "To fix: check out this PR branch locally, run 'cd java/scripts/codegen && npm run generate', commit, and push."
97103
exit 1
98104
99105
- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5

‎.github/workflows/java-codegen-fix.lock.yml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/java-codegen-fix.md‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ You are an automation agent that fixes Java compilation and test failures caused
5252

5353
## Context
5454

55-
A Dependabot PR bumped the `@github/copilot` npm dependency in `java/scripts/codegen/package.json`. The `java-codegen-check` workflow ran the code generator (`java/scripts/codegen/java.ts`) against the new schemas and `mvn verify` subsequently failed. Your job is to fix **both** the code generator script (if needed) and the handwritten SDK/test source code so the build passes.
55+
A Copilot CLI release pin update fetched new schemas from GitHub Releases. The `java-codegen-check` workflow ran the code generator (`java/scripts/codegen/java.ts`) against those schemas and `mvn verify` subsequently failed. Your job is to fix **both** the code generator script (if needed) and the handwritten SDK/test source code so the build passes.
5656

5757
**❌❌❌ YOU MUST NEVER EDIT any of the java source code in `java/sdk/src/generated/` directly.** ✅✅Rather, the way to affect changes in these files is to change the code generator script and re-generate the classes in `java/sdk/src/generated`.
5858

@@ -66,9 +66,9 @@ ${{ inputs.error_summary }}
6666

6767
## Architecture overview
6868

69-
The code generator (`java/scripts/codegen/java.ts`) reads JSON schemas from `node_modules/@github/copilot/schemas/` and produces Java source files under `java/sdk/src/generated/java/`. These generated types are consumed by handwritten code in `java/sdk/src/main/java/` (primarily `CopilotSession.java`) and tested by handwritten tests in `java/sdk/src/test/java/`.
69+
The code generator (`java/scripts/codegen/java.ts`) reads JSON schemas from `java/scripts/codegen/target/schemas/`. The schemas are extracted from the pinned `github-copilot-<version>-linux-x64.tgz` GitHub Release asset by `fetch-schemas.mjs`. The generator produces Java source files under `java/sdk/src/generated/java/`. These generated types are consumed by handwritten code in `java/sdk/src/main/java/` (primarily `CopilotSession.java`) and tested by handwritten tests in `java/sdk/src/test/java/`.
7070

71-
When `@github/copilot` is bumped, the schemas may change in ways the code generator does not yet handle. Common schema changes include:
71+
When the Copilot CLI release pin is bumped, the schemas may change in ways the code generator does not yet handle. Common schema changes include:
7272

7373
- **`$ref` references**: Inline nested type definitions replaced with `$ref` pointers to `#/definitions/` entries. The code generator must resolve these references and emit standalone Java types instead of nested records.
7474
- **Field type changes**: Numeric fields changing between `double`, `Long`, `int`, etc.
@@ -97,10 +97,10 @@ mvn --version
9797
node --version
9898
```
9999

100-
Install codegen dependencies:
100+
Install codegen dependencies and fetch the pinned release schemas:
101101

102102
```bash
103-
cd java/scripts/codegen && npm ci && cd ../../..
103+
cd java/scripts/codegen && npm ci && npm run fetch:schemas && cd ../../..
104104
```
105105

106106
### Step 1: Reproduce the failure
@@ -135,13 +135,13 @@ To diagnose, compare the current schemas with the generated output:
135135

136136
```bash
137137
# List available schemas
138-
ls java/scripts/codegen/node_modules/@github/copilot/schemas/
138+
ls java/scripts/codegen/target/schemas/
139139

140140
# Check for $ref usage in schemas (indicates the codegen may need $ref resolution)
141-
grep -r '"$ref"' java/scripts/codegen/node_modules/@github/copilot/schemas/ | head -20
141+
grep -r '"$ref"' java/scripts/codegen/target/schemas/ | head -20
142142

143143
# Look at a specific schema that relates to failing types
144-
cat java/scripts/codegen/node_modules/@github/copilot/schemas/<relevant-schema>.json | head -80
144+
head -80 java/scripts/codegen/target/schemas/<relevant-schema>.json
145145
```
146146

147147
### Step 3: Fix the code generator (if needed)
@@ -157,7 +157,7 @@ If the diagnosis shows the code generator does not handle the new schema format:
157157

158158
3. **Re-run code generation** to produce updated generated files:
159159
```bash
160-
cd java/scripts/codegen && npx tsx java.ts && cd ../../..
160+
cd java/scripts/codegen && npm run generate && cd ../../..
161161
```
162162

163163
4. **Verify the generated output** looks reasonable:
@@ -213,7 +213,7 @@ After `mvn verify` passes, commit all changes and use the `push-to-pull-request-
213213

214214
```bash
215215
git add -A
216-
git commit -m "Fix Java codegen and build failures after @github/copilot update
216+
git commit -m "Fix Java codegen and build failures after CLI update
217217
218218
Automated fix applied by java-codegen-fix workflow."
219219
```
@@ -236,7 +236,7 @@ Do **NOT** push broken code.
236236

237237
## Important constraints
238238

239-
- **NEVER** hand-edit files under `java/sdk/src/generated/java/` — these are auto-generated. They are updated by running `cd java/scripts/codegen && npx tsx java.ts`.
239+
- **NEVER** hand-edit files under `java/sdk/src/generated/java/` — these are auto-generated. They are updated by running `cd java/scripts/codegen && npm run generate`.
240240
- **NEVER** modify `java/sdk/pom.xml` — build config is not in scope
241241
- **NEVER** modify `java/scripts/codegen/package.json` or `java/scripts/codegen/package-lock.json` — dependency versions are not in scope
242242
- **NEVER** modify files under `.github/` — workflow files are not in scope

0 commit comments

Comments
 (0)