Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/codegen-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- 'go/rpc/**'
- 'rust/src/generated/**'
- 'sdk-protocol-version.json'
- 'java/src/main/java/com/github/copilot/SdkProtocolVersion.java'
- 'java/sdk/src/main/java/com/github/copilot/SdkProtocolVersion.java'
- '.github/workflows/codegen-check.yml'
workflow_dispatch:

Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Verify Java protocol version matches
run: |
EXPECTED=$(jq -r '.version' sdk-protocol-version.json)
ACTUAL=$(grep -oP 'LATEST\(\K[0-9]+' java/src/main/java/com/github/copilot/SdkProtocolVersion.java)
ACTUAL=$(grep -oP 'LATEST\(\K[0-9]+' java/sdk/src/main/java/com/github/copilot/SdkProtocolVersion.java)
if [ "$EXPECTED" != "$ACTUAL" ]; then
echo "::error::Java SDK protocol version ($ACTUAL) does not match sdk-protocol-version.json ($EXPECTED). Java manages its own SdkProtocolVersion.java via java/scripts/codegen/. Update it to match."
exit 1
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docs-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ on:
- 'python/copilot/**'
- 'go/**/*.go'
- 'dotnet/src/**'
- 'java/src/**'
- 'java/sdk/src/**'
- 'java/pom.xml'
- 'java/sdk/pom.xml'
- 'scripts/docs-validation/**'
- '.github/workflows/docs-validation.yml'
workflow_dispatch:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ You are an automation agent that fixes handwritten Java SDK source and test code

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

## Boundaries

- ❌ Do NOT edit anything under `java/src/generated/java/`
- ❌ Do NOT edit anything under `java/sdk/src/generated/java/`
- ❌ Do NOT edit `java/scripts/codegen/java.ts`
- ❌ Do NOT create or modify tests in the `com.github.copilot.generated` test package (`java/src/test/java/com/github/copilot/sdk/generated/`)
- ✅ DO edit `java/src/main/java/com/github/copilot/sdk/**`
- ✅ DO edit `java/src/test/java/com/github/copilot/sdk/**` (excluding the `generated` subpackage)
- ❌ Do NOT create or modify tests in the `com.github.copilot.generated` test package (`java/sdk/src/test/java/com/github/copilot/sdk/generated/`)
- ✅ DO edit `java/sdk/src/main/java/com/github/copilot/sdk/**`
- ✅ DO edit `java/sdk/src/test/java/com/github/copilot/sdk/**` (excluding the `generated` subpackage)
- ✅ DO add new test methods or test classes if new user-facing API surface is introduced

## Instructions
Expand Down Expand Up @@ -146,7 +146,7 @@ mvn verify -Dskip.test.harness=true
If this passes, commit and push:

```bash
git add java/src/main/java java/src/test/java
git add java/sdk/src/main/java java/sdk/src/test/java
git commit -m "Fix handwritten Java code for @github/copilot schema changes

Adapt constructor calls, enum references, and test assertions to match
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/java-codegen-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ on:
- main
paths:
- 'java/scripts/codegen/**'
- 'java/src/generated/**'
- 'java/sdk/src/generated/**'
- '.github/workflows/java-codegen-check.yml'
pull_request:
paths:
- 'java/scripts/codegen/**'
- 'java/src/generated/**'
- 'java/sdk/src/generated/**'
- '.github/workflows/java-codegen-check.yml'
workflow_dispatch:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/java-codegen-fix.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions .github/workflows/java-codegen-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ You are an automation agent that fixes Java compilation and test failures caused

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.

**❌❌❌ YOU MUST NEVER EDIT any of the java source code in `java/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/src/generated`.
**❌❌❌ 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`.

The branch to fix is: `${{ inputs.branch }}`
The PR number is: `${{ inputs.pr_number }}`
Expand All @@ -66,7 +66,7 @@ ${{ inputs.error_summary }}

## Architecture overview

The code generator (`java/scripts/codegen/java.ts`) reads JSON schemas from `node_modules/@github/copilot/schemas/` and produces Java source files under `java/src/generated/java/`. These generated types are consumed by handwritten code in `java/src/main/java/` (primarily `CopilotSession.java`) and tested by handwritten tests in `java/src/test/java/`.
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/`.

When `@github/copilot` is bumped, the schemas may change in ways the code generator does not yet handle. Common schema changes include:

Expand Down Expand Up @@ -126,7 +126,7 @@ Before making fixes, determine whether the failure is caused by:
- New schemas exist but no corresponding Java types were generated

**(B) Handwritten code referencing old generated type names/shapes.** Signs:
- Compilation errors in `java/src/main/java/` or `java/src/test/java/` referencing types that no longer exist
- Compilation errors in `java/sdk/src/main/java/` or `java/sdk/src/test/java/` referencing types that no longer exist
- Test data using old JSON field names

Often **both** (A) and (B) apply: the codegen needs fixing first, then handwritten code needs updating.
Expand Down Expand Up @@ -162,7 +162,7 @@ If the diagnosis shows the code generator does not handle the new schema format:

4. **Verify the generated output** looks reasonable:
```bash
git diff --stat java/src/generated/java/
git diff --stat java/sdk/src/generated/java/
```

**You may ONLY modify `java/scripts/codegen/java.ts`.** Do not modify `package.json`, `package-lock.json`, or any other file under `java/scripts/codegen/`.
Expand All @@ -179,12 +179,12 @@ For each attempt:
2. **Read the generated types** to understand what changed. Check the generated files that the handwritten code references:
```bash
# Example: check what a generated type looks like now
cat java/src/generated/java/com/github/copilot/generated/rpc/<TypeName>.java
cat java/sdk/src/generated/java/com/github/copilot/generated/rpc/<TypeName>.java
```

3. **Fix the affected source files.** You may modify files under:
- `java/src/main/java/` — handwritten SDK source code
- `java/src/test/java/` — handwritten test code
- `java/sdk/src/main/java/` — handwritten SDK source code
- `java/sdk/src/test/java/` — handwritten test code

Common fixes:
- Update type references from old nested types to new standalone types (e.g. `SessionMcpListResultServersItem` → `McpServer`)
Expand Down Expand Up @@ -236,12 +236,12 @@ Do **NOT** push broken code.

## Important constraints

- **NEVER** hand-edit files under `java/src/generated/java/` — these are auto-generated. They are updated by running `cd java/scripts/codegen && npx tsx java.ts`.
- **NEVER** modify `java/pom.xml` — build config is not in scope
- **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`.
- **NEVER** modify `java/sdk/pom.xml` — build config is not in scope
- **NEVER** modify `java/scripts/codegen/package.json` or `java/scripts/codegen/package-lock.json` — dependency versions are not in scope
- **NEVER** modify files under `.github/` — workflow files are not in scope
- You **MAY** modify `java/scripts/codegen/java.ts` to fix the code generator
- You **MAY** modify files under `java/src/main/java/` and `java/src/test/java/` to fix handwritten code
- You **MAY** modify files under `java/sdk/src/main/java/` and `java/sdk/src/test/java/` to fix handwritten code
- Always run `cd java && mvn spotless:apply` before committing to ensure code formatting
- Maximum 3 fix attempts before reporting failure via `noop`
- Only push if `mvn verify` passes
60 changes: 53 additions & 7 deletions .github/workflows/java-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,52 @@ permissions:
contents: read

jobs:
java-sdk-inprocess:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to integrate this in the regular job as a matrix ([default, inprocess]) rather than having a completely separate leg for it?

name: "Java SDK InProcess Tests"
if: github.event.repository.fork == false
runs-on: ubuntu-latest
continue-on-error: true

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Making the only real in-process test job continue-on-error means FFI regressions can never block this PR or later merges. Since this change introduces the transport, this job should be required once it is added.

defaults:
run:
shell: bash
working-directory: ./java
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: "25"
distribution: "microsoft"
cache: "maven"

- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
with:
node-version: 22

- name: Run Java SDK tests (InProcess)
env:
CI: "true"
run: mvn clean verify -Pinprocess

- name: Generate Test Report Summary
if: always()
uses: ./.github/actions/java-test-report
with:
title: "Copilot Java SDK :: Test Results InProcess"

- name: Upload test results on failure
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: java-test-results-inprocess
path: |
java/sdk/target/surefire-reports/
java/sdk/target/surefire-reports-isolated/
java/sdk/target/failsafe-reports/
retention-days: 7

java-sdk:
name: "Java SDK Tests (JDK ${{ matrix.test-jdk }})"
if: github.event.repository.fork == false
Expand Down Expand Up @@ -96,17 +142,17 @@ jobs:
run: |
echo "Running tests against JDK 25-built classes using JDK 17 runtime..."
java -version
mvn jacoco:prepare-agent@wire-up-coverage-instrumentation antrun:run@print-test-jdk-banner surefire:test failsafe:integration-test failsafe:verify jacoco:report@build-coverage-report-from-tests -Denforcer.skip=true
mvn -pl sdk jacoco:prepare-agent@wire-up-coverage-instrumentation antrun:run@print-test-jdk-banner surefire:test failsafe:integration-test failsafe:verify jacoco:report@build-coverage-report-from-tests -Denforcer.skip=true

- name: Upload test results for site generation
if: success() && github.ref == 'refs/heads/main' && matrix.test-jdk == '25'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: test-results-for-site
path: |
java/target/jacoco-test-results/sdk-tests.exec
java/target/surefire-reports/
java/target/surefire-reports-isolated/
java/sdk/target/jacoco-test-results/sdk-tests.exec
java/sdk/target/surefire-reports/
java/sdk/target/surefire-reports-isolated/
retention-days: 1

- name: Generate Test Report Summary
Expand All @@ -121,7 +167,7 @@ jobs:
with:
name: java-test-results-jdk-${{ matrix.test-jdk }}
path: |
java/target/surefire-reports/
java/target/surefire-reports-isolated/
java/target/failsafe-reports/
java/sdk/target/surefire-reports/
java/sdk/target/surefire-reports-isolated/
java/sdk/target/failsafe-reports/
retention-days: 7
Loading
Loading