Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions .githooks/pre-commit

This file was deleted.

6 changes: 3 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
- Go: `cd go && go test ./...`
- .NET: `cd dotnet && dotnet test test/GitHub.Copilot.SDK.Test.csproj`
- **.NET testing note:** Never add `InternalsVisibleTo` to any project file when writing tests. Tests must only access public APIs.
- Java: `cd java && mvn clean verify` (full build + tests), `mvn spotless:apply` (format code before commit)
- Java: `cd java && mvn clean verify` (full build + tests), `mvn -pl sdk spotless:apply` (format code)
- Java single test: `cd java && mvn test -Dtest=CopilotClientTest` | single method: `mvn test -Dtest=ToolsTest#testToolInvocation`
- Java format check only: `mvn spotless:check` | Build without tests: `mvn clean package -DskipTests`
- Java formatting and Javadoc checks: `mvn -pl sdk spotless:check checkstyle:check` | Build without tests: `mvn clean package -DskipTests`
- **Java testing note:** Always use `mvn verify` without `-q` and without piping through `grep`. Never add `InternalsVisibleTo` equivalent — tests must only access public APIs.
- Use configured LSPs for supported operations like finding references instead of pattern matching, renaming symbols, etc.

Expand All @@ -57,7 +57,7 @@
- Some scripts (typegen, formatting) call external tools: `gofmt`, `dotnet format`, `tsx` (available via npm), `quicktype`/`quicktype-core` (used by the Node typegen script), and `prettier` (provided as an npm devDependency). Most of these are available through the repo's package scripts or devDependencies—run `just install` (and `cd nodejs && npm ci`) to install them. Ensure the required tools are available in CI / developer machines.
- Tests may assume `node >= 18`, `python >= 3.9`, platform differences handled (Windows uses `shell=True` for npx in harness).
- Java requires JDK 17+ and Maven 3.9+. Java E2E tests also require Node.js (for the replay proxy).
- Java pre-commit hook runs `mvn spotless:check`. Enable with `git config core.hooksPath .githooks` (auto-enabled in Copilot coding agent environment via `copilot-setup-steps.yml`).
- Java formatting and Javadoc checks use `just format-java` and `just lint-java` from the repository root, and are included in `just format` and `just lint`. CI enforces Spotless and Checkstyle; `mvn verify` alone does not run Spotless.

## Where to add new code or tests 🧭

Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ jobs:
with:
version: v0.82.10

# Enable repository pre-commit hooks (Spotless checks for Java source changes)
- name: Enable pre-commit hooks
run: git config core.hooksPath .githooks

# Install JavaScript dependencies
- name: Install Node.js dependencies
working-directory: ./nodejs
Expand Down
19 changes: 16 additions & 3 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,6 @@ Requires JDK 25 or later and a supported [Node.js version](../nodejs/README.md#p
git clone https://github.com/github/copilot-sdk.git
cd copilot-sdk/java

# Enable git hooks for code formatting
git config core.hooksPath .githooks

# Build and test with JDK 25
mvn test-compile jar:jar
mvn verify -Dskip.test.harness=true
Expand All @@ -589,6 +586,22 @@ mvn verify -Dskip.test.harness=true
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
```

#### Formatting and linting

From the repository root, run `just format-java` to apply formatting and `just lint-java` to check formatting and Javadoc. These recipes are also included in `just format` and `just lint`.

Without `just`, run the equivalent Maven commands from `java/`:

```bash
# Apply formatting
mvn -pl sdk spotless:apply

# Check formatting and Javadoc
mvn -pl sdk spotless:check checkstyle:check
```

CI enforces both checks. Spotless runs explicitly in CI; `mvn verify` alone does not check formatting.

#### Development Setup for native embedding

Run native-runtime Maven commands from the `java` directory. Native packaging requires Node.js in addition to JDK 25 and Maven because `copilot-native/scripts/fetch-native.mjs` retrieves the pinned runtime package from the corresponding GitHub release.
Expand Down
14 changes: 12 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ default:
@just --list

# Format all code across all languages
format: format-go format-python format-nodejs format-dotnet format-rust
format: format-go format-python format-nodejs format-dotnet format-java format-rust

# Lint all code across all languages
lint: lint-go lint-python lint-nodejs lint-dotnet lint-rust
lint: lint-go lint-python lint-nodejs lint-dotnet lint-java lint-rust

# Run tests for all languages
test: test-go test-python test-nodejs test-dotnet test-rust test-harness test-corrections
Expand All @@ -31,6 +31,11 @@ format-dotnet:
@echo "=== Formatting .NET code ==="
@cd dotnet && dotnet format src/GitHub.Copilot.SDK.csproj

# Format Java code
format-java:
@echo "=== Formatting Java code ==="
@cd java && mvn -pl sdk spotless:apply

# Lint Go code
lint-go:
@echo "=== Linting Go code ==="
Expand All @@ -51,6 +56,11 @@ lint-dotnet:
@echo "=== Linting .NET code ==="
@cd dotnet && dotnet format src/GitHub.Copilot.SDK.csproj --verify-no-changes

# Lint Java code
lint-java:
@echo "=== Linting Java code ==="
@cd java && mvn -pl sdk spotless:check checkstyle:check

# Test Go code
test-go:
@echo "=== Testing Go code ==="
Expand Down
Loading