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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/java-sdk-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
run: mvn javadoc:javadoc -q

- name: Verify CLI works
run: node target/copilot-sdk/nodejs/node_modules/@github/copilot/index.js --version
run: node ../nodejs/node_modules/@github/copilot/index.js --version

- name: Run spotless check
if: matrix.test-jdk == '25'
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/update-copilot-dependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ jobs:
git checkout -b "$BRANCH"
fi
# Stage everything except java/.lastmerge so it doesn't create a
# spurious diff in the no-changes check below. The ':!...' pathspec
# (exclude magic) tells git to skip that one file.
git add -A -- ':!java/.lastmerge'
git add -A
if git diff --cached --quiet; then
echo "No changes detected; skipping commit and PR creation."
Expand All @@ -178,16 +175,6 @@ jobs:
- Re-ran code generators
- Formatted generated code"
# Record the sync point AFTER the commit so that .lastmerge contains
# the SHA of the commit that actually includes the bumped
# nodejs/package.json. Java's build reads .lastmerge to clone the
# monorepo at that commit and extract the test harness + CLI version
# from nodejs/package.json. If we wrote .lastmerge BEFORE committing,
# it would point to the parent commit which still has the OLD version,
# causing Java tests to run against a stale CLI.
git rev-parse HEAD > java/.lastmerge
git add java/.lastmerge
git commit --amend --no-edit
git push origin "$BRANCH" --force-with-lease
PR_BODY=$(cat <<'BODY_EOF'
Expand All @@ -197,7 +184,7 @@ jobs:
- Updated `@github/copilot` in `nodejs/package.json` and `test/harness/package.json`
- Re-ran all code generators (`scripts/codegen`)
- Formatted generated output
- Updated Java codegen dependency, `.lastmerge`, POM property, and regenerated Java types
- Updated Java codegen dependency, POM property, and regenerated Java types
### Java Handwritten Code Adaptation Plan
Expand Down
1 change: 0 additions & 1 deletion java/.lastmerge

This file was deleted.

173 changes: 27 additions & 146 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,24 @@
<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Directory where the copilot-sdk repo will be cloned for tests -->
<copilot.sdk.clone.dir>${project.build.directory}/copilot-sdk</copilot.sdk.clone.dir>
<copilot.tests.dir>${copilot.sdk.clone.dir}/test</copilot.tests.dir>
<!--
Root of the monorepo. Since the Java SDK now lives inside the
monorepo (java/ directory), we point directly at the repo root
instead of cloning a separate copy into target/.
-->
<copilot.sdk.root>${project.basedir}/..</copilot.sdk.root>
<copilot.tests.dir>${copilot.sdk.root}/test</copilot.tests.dir>
<!--
Path to the Copilot CLI entry point used by the SDK tests. Defaults
to the CLI installed under target/copilot-sdk/nodejs by the
install-nodejs-cli-dependencies execution. Surefire injects this
into the test JVM as the COPILOT_CLI_PATH environment variable, so
`mvn verify` is self-contained and the developer never has to set
it manually. Override on the command line to point at a different
CLI build, e.g.:
to the CLI installed under the monorepo's nodejs/ directory.
Surefire injects this into the test JVM as the COPILOT_CLI_PATH
environment variable, so `mvn verify` is self-contained and the
developer never has to set it manually. Override on the command
line to point at a different CLI build, e.g.:
mvn verify -Dcopilot.cli.path=/some/other/copilot/index.js
-->
<copilot.cli.path>${copilot.sdk.clone.dir}/nodejs/node_modules/@github/copilot/index.js</copilot.cli.path>
<!-- Set to true (via -Pskip-test-harness) to skip git-clone + npm install of test harness -->
<copilot.cli.path>${copilot.sdk.root}/nodejs/node_modules/@github/copilot/index.js</copilot.cli.path>
<!-- Set to true (via -Pskip-test-harness) to skip npm install of test harness -->
<skip.test.harness>false</skip.test.harness>
<!--
Whether to skip the install-nodejs-cli-dependencies execution
Expand All @@ -76,23 +79,12 @@
<!-- Extra JVM args for Surefire; overridden by the jdk21+ profile -->
<surefire.jvm.args />
<!--
The version of the @github/copilot npm package that the reference implementation
commit pinned in .lastmerge depends on. Mirrors the value of dependencies."@github/copilot"
in target/copilot-sdk/nodejs/package.json after the reference impl is cloned/reset to the
commit in .lastmerge.
The pinned version of the @github/copilot npm package used by CI
workflows (java-smoke-test.yml, update-copilot-dependency.yml) to
install the correct CLI for smoke tests and codegen updates.

The previously mentioned package.json contains the SINGLE
SOURCE OF TRUTH for the Copilot CLI version that all paths
(build-test.yml, run-smoke-test.yml,
update-copilot-dependency.yml, setup-copilot action) must
pin to. It is updated automatically by
.github/scripts/reference-impl-sync/sync-cli-version-from-reference-impl.sh,
which is called from merge-reference-impl-finish.sh
whenever .lastmerge is updated.

DO NOT EDIT MANUALLY. To update, run the
reference-impl-sync workflow and deal with the subsequent
PR.
DO NOT EDIT MANUALLY. Updated by the update-copilot-dependency
workflow.
-->
<readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>^1.0.57</readonly-copilot-sdk-ref-impl-version-from-lastmerge-file-updated-by-reference-impl-sync>

Expand Down Expand Up @@ -167,35 +159,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<!--
The default-clean execution uses failOnError=false
because external processes (VS Code language servers,
orphaned Node.js test-harness processes) can hold
file descriptors on target/copilot-sdk/ just long
enough to prevent deletion. The post-clean-sweep
retries immediately afterward (by which time the
transient locks have cleared) to ensure target/ is
fully removed.
-->
<id>default-clean</id>
<configuration>
<retryOnError>true</retryOnError>
<failOnError>false</failOnError>
</configuration>
</execution>
<execution>
<id>post-clean-sweep</id>
<phase>post-clean</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<retryOnError>true</retryOnError>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -207,78 +170,11 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.5.0</version>
</plugin>
<!-- Clone or update the official copilot-sdk repository for test resources, and copy image to site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>clone-or-update-copilot-sdk</id>
<phase>generate-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${skip.test.harness}</skip>
<target xmlns:if="ant:if" xmlns:unless="ant:unless">
<!-- Load the target commit from .lastmerge file -->
<loadfile property="copilot.sdk.commit" srcFile="${project.basedir}/.lastmerge">
<filterchain>
<striplinebreaks />
<trim />
</filterchain>
</loadfile>

<!-- Check if .git directory exists -->
<condition property="repo.exists">
<available file="${copilot.sdk.clone.dir}/.git" type="dir" />
</condition>

<!-- If repo exists, fetch and reset to the target commit -->
<sequential if:set="repo.exists">
<echo message="Updating existing copilot-sdk repository to commit ${copilot.sdk.commit}..." />
<exec executable="git" dir="${copilot.sdk.clone.dir}" failonerror="true">
<arg value="fetch" />
<arg value="--depth" />
<arg value="1" />
<arg value="origin" />
<arg value="${copilot.sdk.commit}" />
</exec>
<exec executable="git" dir="${copilot.sdk.clone.dir}" failonerror="true">
<arg value="reset" />
<arg value="--hard" />
<arg value="FETCH_HEAD" />
</exec>
</sequential>

<!-- If repo doesn't exist, clone it at the specific commit -->
<sequential unless:set="repo.exists">
<echo message="Cloning copilot-sdk repository at commit ${copilot.sdk.commit}..." />
<delete dir="${copilot.sdk.clone.dir}" quiet="true" />
<exec executable="git" failonerror="true">
<arg value="clone" />
<arg value="--depth" />
<arg value="1" />
<arg value="https://github.com/github/copilot-sdk.git" />
<arg value="${copilot.sdk.clone.dir}" />
</exec>
<exec executable="git" dir="${copilot.sdk.clone.dir}" failonerror="true">
<arg value="fetch" />
<arg value="--depth" />
<arg value="1" />
<arg value="origin" />
<arg value="${copilot.sdk.commit}" />
</exec>
<exec executable="git" dir="${copilot.sdk.clone.dir}" failonerror="true">
<arg value="reset" />
<arg value="--hard" />
<arg value="FETCH_HEAD" />
</exec>
</sequential>
</target>
</configuration>
</execution>
<execution>
<id>print-test-jdk-banner</id>
<phase>process-test-classes</phase>
Expand All @@ -292,14 +188,6 @@
</configuration>
</execution>
</executions>
<dependencies>
<!-- Required for if:set and unless:set -->
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.17</version>
</dependency>
</dependencies>
</plugin>
<!-- Install harness dependencies -->
<plugin>
Expand All @@ -316,24 +204,17 @@
<configuration>
<skip>${skip.test.harness}</skip>
<executable>npm</executable>
<workingDirectory>${copilot.sdk.clone.dir}/test/harness</workingDirectory>
<workingDirectory>${copilot.sdk.root}/test/harness</workingDirectory>
<arguments>
<argument>install</argument>
</arguments>
Comment on lines 204 to 210
</configuration>
</execution>
<!--
Install the @github/copilot CLI declared by
target/copilot-sdk/nodejs/package.json. This is the CLI
version the SDK tests must run against (independent of
the older pin in test/harness/package.json which is
incidental to harness internals). Mirrors what
.github/workflows/build-test.yml does manually so that
`mvn clean verify` is self-contained: the prior
target/copilot-sdk/nodejs/node_modules is wiped by
clean, but this re-creates it before tests run.
Uses npm ci with the ignore-scripts flag, matching
build-test.yml.
Install the @github/copilot CLI declared by the
monorepo's nodejs/package.json. This is the CLI version
the SDK tests must run against. Uses npm ci with the
ignore-scripts flag, matching build-test.yml.
-->
<execution>
<id>install-nodejs-cli-dependencies</id>
Expand All @@ -344,7 +225,7 @@
<configuration>
<skip>${skip.cli.install}</skip>
<executable>npm</executable>
<workingDirectory>${copilot.sdk.clone.dir}/nodejs</workingDirectory>
<workingDirectory>${copilot.sdk.root}/nodejs</workingDirectory>
<arguments>
<argument>ci</argument>
<argument>--ignore-scripts</argument>
Expand Down Expand Up @@ -407,7 +288,7 @@
<rerunFailingTestsCount>2</rerunFailingTestsCount>
<systemPropertyVariables>
<copilot.tests.dir>${copilot.tests.dir}</copilot.tests.dir>
<copilot.sdk.dir>${copilot.sdk.clone.dir}</copilot.sdk.dir>
<copilot.sdk.dir>${copilot.sdk.root}</copilot.sdk.dir>
</systemPropertyVariables>
<!--
Set COPILOT_CLI_PATH for the forked test JVM so the SDK
Expand Down Expand Up @@ -709,7 +590,7 @@ did not produce the multi-release output. Re-build on JDK 25+ and verify the
</plugins>
</build>
</profile>
<!-- Skip git-clone + npm install of the copilot-sdk test harness -->
<!-- Skip npm install of the copilot-sdk test harness -->
<profile>
<id>skip-test-harness</id>
<properties>
Expand Down
Loading