Skip to content

Replace typespec-java PowerShell automation with TypeScript - #5170

Merged
Xiaofei Cao (XiaofeiCao) merged 5 commits into
mainfrom
copilot/move-away-from-powershell-script
Aug 6, 2026
Merged

Xiaofei Cao (XiaofeiCao) merged 5 commits into
mainfrom
copilot/move-away-from-powershell-script

Conversation

Copilot AI commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

PowerShell terminal control output can disrupt Turbo builds and has previously caused CI failures through stderr handling. Move Java emitter automation to Node-native TypeScript.

  • Build automation

    • Replace source copying, pinned-core extraction, generator builds, test synchronization, regeneration, and Spector scripts.
    • Use execa for Git, Maven, pnpm, and TypeSpec commands.
    • Preserve concurrent generation, cleanup, patching, and core commit pinning.
  • CI integration

    • Run Java coverage steps as standard scripts instead of PowerShell tasks.
    • Point package commands directly at TypeScript entry points.
  • Coverage and documentation

    • Add focused tests for core source selection, pinned-commit extraction, and cleanup.
    • Update contributor and emitter-test documentation for the new commands.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: XiaofeiCao <92354331+XiaofeiCao@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added eng emitter:java Issues for @azure-tools/typespec-java emitter labels Aug 6, 2026
Co-authored-by: XiaofeiCao <92354331+XiaofeiCao@users.noreply.github.com>
Copilot AI changed the title [WIP] Migrate build scripts from PowerShell to TypeScript Replace typespec-java PowerShell automation with TypeScript Aug 6, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@azure-tools/typespec-java@5170

commit: bd7e909

@XiaofeiCao

Copy link
Copy Markdown
Member

Copilot rename core-source.ts to core-commit.ts

Co-authored-by: XiaofeiCao <92354331+XiaofeiCao@users.noreply.github.com>

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Copilot rename core-source.ts to core-commit.ts

Renamed the implementation and test to core-commit.ts / core-commit.test.ts and updated all imports in fbbdf48.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A few newly updated docs/messages are now inaccurate or non-actionable (referencing non-existent files or suggesting running a .ts path directly), and should be corrected before merge.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR migrates @azure-tools/typespec-java build/regeneration/e2e automation from PowerShell scripts to Node-native TypeScript entrypoints to avoid terminal control output issues that have impacted Turbo/CI.

Changes:

  • Replaced PowerShell-based automation (copy sources, build generator, regenerate, sync tests, run Spector e2e) with TypeScript scripts using execa and Node fs APIs.
  • Updated CI (GitHub Actions + ADO pipeline job) to invoke the new scripts via standard script steps and node ...ts entrypoints.
  • Added focused unit tests for the pinned-core extraction logic (core-commit.ts) and updated Java emitter-test documentation accordingly.
File summaries
File Description
pnpm-lock.yaml Adds lockfile entries for new script dependencies (execa, tar).
packages/typespec-java/vitest.config.ts Expands Vitest include globs to run new eng/**/*.test.ts tests.
packages/typespec-java/SyncTests.ps1 Removes PowerShell sync script (replaced by TS).
packages/typespec-java/Spector-Tests.ps1 Removes PowerShell Spector test runner (replaced by TS).
packages/typespec-java/package.json Switches scripts to node ./eng/scripts/*.ts and adds execa/tar dev deps.
packages/typespec-java/Generate.ps1 Removes PowerShell regeneration script (replaced by TS).
packages/typespec-java/eng/scripts/sync-tests.ts New TS implementation for syncing core test sources and applying core.test.patch.
packages/typespec-java/eng/scripts/spector-tests.ts New TS implementation for starting/stopping Spector server, running Maven tests, staging coverage.
packages/typespec-java/eng/scripts/generate.ts New TS implementation of regeneration workflow with concurrency and per-spec options.
packages/typespec-java/eng/scripts/core-commit.ts New shared TS helper to read sources from pinned core commit via git archive without mutating submodule checkout.
packages/typespec-java/eng/scripts/core-commit.test.ts Adds unit tests validating pin-absent behavior, pinned extraction, and cleanup.
packages/typespec-java/eng/scripts/copy-sources.ts New TS copy+patch flow for emitter+generator sources from core/.
packages/typespec-java/eng/scripts/build-generator.ts New TS wrapper to build the patched generator JAR via Maven.
packages/typespec-java/emitter-tests/spector.config.yaml Updates comment to reference TS regenerator instead of PowerShell.
packages/typespec-java/emitter-tests/resolve-spector-specs.js Updates header comments to reference TS regenerator.
packages/typespec-java/emitter-tests/readme.md Updates contributor docs/commands and clarifies the TS-based workflow.
packages/typespec-java/CoreCommit.ps1 Removes PowerShell pinned-core helper (replaced by TS).
packages/typespec-java/Copy-Sources.ps1 Removes PowerShell copy+patch script (replaced by TS).
packages/typespec-java/CONTRIBUTING.md Updates contributor docs to reference TS scripts/commands instead of PowerShell.
packages/typespec-java/Build-Generator.ps1 Removes PowerShell generator build script (replaced by TS).
eng/pipelines/jobs/spector-coverage.yml Replaces pwsh steps with script steps for Java spector coverage.
.github/workflows/ci-java.yml Updates workflow comments to reference TS regenerator.
.chronus/changes/copilot-move-away-from-powershell-script-2026-7-6-3-2-25.md Adds changelog entry for the automation migration.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file

Suppressed comments (1)

packages/typespec-java/CONTRIBUTING.md:153

  • emitter-tests/package.json is referenced as needing version/.tgz updates, but emitter-tests/ has no package.json and the tests consume the workspace build directly. The instructions should be updated to avoid pointing people at a non-existent file.
submodule stays unchanged. The bump must also be reflected in `emitter-tests/package.json` (its
`version` and the `*.tgz` dependency) — rerun `pnpm sync-tests` or update it manually.
  • Files reviewed: 22/23 changed files
  • Comments generated: 3
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread packages/typespec-java/CONTRIBUTING.md Resolved
Co-authored-by: XiaofeiCao <92354331+XiaofeiCao@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new spector-tests.ts currently swallows some ENOENT failures during coverage staging, which can hide real setup/CI problems.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file

Suppressed comments (1)

packages/typespec-java/eng/scripts/spector-tests.ts:40

  • The ENOENT handler around copyFile() will also swallow failures where the destination path is missing (e.g., node_modules/@azure-tools/azure-http-specs isn’t installed), which would silently skip staging the coverage file. It should only ignore ENOENT when the source coverage report wasn’t produced, and still fail if the destination can’t be written.
try {
  await copyFile(
    join(emitterTestsRoot, "tsp-spector-coverage-java.json"),
    join(packageRoot, "node_modules", "@azure-tools", "azure-http-specs", "spec-coverage.json"),
  );
  • Files reviewed: 22/23 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@azure-sdk-automation

Copy link
Copy Markdown
Contributor

You can try these changes here

🛝 Playground 🌐 Website

@XiaofeiCao
Xiaofei Cao (XiaofeiCao) added this pull request to the merge queue Aug 6, 2026
Merged via the queue into main with commit 10a4d18 Aug 6, 2026
34 checks passed
@XiaofeiCao
Xiaofei Cao (XiaofeiCao) deleted the copilot/move-away-from-powershell-script branch August 6, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:java Issues for @azure-tools/typespec-java emitter eng

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typespec-java, eng, Move away from PowerShell script in build

4 participants