Skip to content

Commit 08d53c3

Browse files
Sync eng/common directory with azure-sdk-tools for PR 16330 (#48049)
* Convert eval CI glue scripts from .js to .ts (Node type stripping) Rename the 7 source + 4 test modules under eng/common/scripts/eval to .ts and rewrite relative import specifiers to .ts (Node native type erasure, no build step). Pipeline node invocations and the npm test script gain --experimental-strip-types --disable-warning=ExperimentalWarning so they run on Node 22.6-22.17 (local) and unflagged on 22.18+ (CI). engines bumped to >=22.6. Addresses Mike Harder feedback to prefer .ts with type erasure over .js. * Reuse azure-rest-api-specs exec primitives in eval git sync Vendor .github/shared/src/exec.js from azure-rest-api-specs (@ef7dd74) as lib/exec.ts (TS port, erasable syntax) under eng/common so it syncs into the language repos. Rewire sync-eval-git-repo invokeGit onto the async execFile helper (no-shell child_process.execFile, git stderr surfaced only on failure); syncRepo and init-eval-git-fixtures main become async accordingly. README documents the vendored file and provenance. Addresses Mike Harder feedback to reuse the shared exec primitives; see #16296. * Polish: keep vendored exec.ts faithful to upstream; note shard spawnSync rationale * Drop --disable-warning=ExperimentalWarning; keep only --experimental-strip-types --------- Co-authored-by: helen229 <gaoh@microsoft.com>
1 parent 48a7fbb commit 08d53c3

19 files changed

Lines changed: 217 additions & 57 deletions

eng/common/pipelines/templates/jobs/eval-shard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
patterns+=(--pattern "$tok")
102102
done
103103
set +f
104-
node "$(Build.SourcesDirectory)/eng/common/scripts/eval/init-eval-git-fixtures.js" \
104+
node --experimental-strip-types "$(Build.SourcesDirectory)/eng/common/scripts/eval/init-eval-git-fixtures.ts" \
105105
--eval-root "$(Build.SourcesDirectory)/${{ parameters.vallyRoot }}" \
106106
"${patterns[@]}"
107107
displayName: 'Prime eval git fixtures'

eng/common/pipelines/templates/jobs/eval-summarize.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
# Renders the rollup to the run's Summary tab (##vso[task.uploadsummary]).
3131
- script: |
32-
node "$(Build.SourcesDirectory)/eng/common/scripts/eval/build-eval-summary.js" \
32+
node --experimental-strip-types "$(Build.SourcesDirectory)/eng/common/scripts/eval/build-eval-summary.ts" \
3333
--results-root "$(Pipeline.Workspace)/eval-results" \
3434
--output-path "$(Build.ArtifactStagingDirectory)/eval-summary.md"
3535
displayName: 'Render Markdown rollup'

eng/common/pipelines/templates/jobs/generate-eval-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
set +f
3838
fi
3939
base="$(Build.SourcesDirectory)/${{ parameters.vallyRoot }}"
40-
node "$(Build.SourcesDirectory)/eng/common/scripts/eval/collect-stimuli.js" \
40+
node --experimental-strip-types "$(Build.SourcesDirectory)/eng/common/scripts/eval/collect-stimuli.ts" \
4141
--eval-root "$base" \
4242
--path-base "$base" \
4343
"${patterns[@]}" \

eng/common/pipelines/templates/steps/eval-invoke.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ steps:
2727
scriptLocation: inlineScript
2828
workingDirectory: ${{ parameters.vallyRoot }}
2929
inlineScript: |
30-
node "$(Build.SourcesDirectory)/eng/common/scripts/eval/invoke-eval-shard.js" \
30+
node --experimental-strip-types "$(Build.SourcesDirectory)/eng/common/scripts/eval/invoke-eval-shard.ts" \
3131
--eval-args "$(evalArgs)" \
3232
--shard-name "$(shardName)" \
3333
--output-dir "$(Build.SourcesDirectory)/artifacts/vally-results/$(shardName)" \
@@ -37,7 +37,7 @@ steps:
3737

3838
- ${{ else }}:
3939
- script: |
40-
node "$(Build.SourcesDirectory)/eng/common/scripts/eval/invoke-eval-shard.js" \
40+
node --experimental-strip-types "$(Build.SourcesDirectory)/eng/common/scripts/eval/invoke-eval-shard.ts" \
4141
--eval-args "$(evalArgs)" \
4242
--shard-name "$(shardName)" \
4343
--output-dir "$(Build.SourcesDirectory)/artifacts/vally-results/$(shardName)" \

eng/common/scripts/eval/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The Vally eval harness ships hand-written ES modules under lib/ (glob.js, verdict.js).
1+
# The Vally eval harness ships hand-written ES modules under lib/ (glob.ts, verdict.ts).
22
# Most repos ignore a top-level `lib/` (Python build output); re-include ours here so the
33
# harness stays tracked wherever eng/common is synced (else node fails ERR_MODULE_NOT_FOUND).
44
# Living in eng/common means this fix travels with the sync to every language SDK repo, so no

eng/common/scripts/eval/README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# eval-scripts (CI glue + pinned Vally CLI)
22

3-
This folder holds the JavaScript glue the Vally eval CI runs (matrix sharding, the shard
3+
This folder holds the TypeScript glue the Vally eval CI runs (matrix sharding, the shard
44
runner, the JUnit summary) **and** pins the [`@microsoft/vally-cli`](https://www.npmjs.com/package/@microsoft/vally-cli)
55
version those shards install. The CLI and its full transitive dependency tree are locked by
66
the committed `package-lock.json` instead of resolved fresh from semver ranges on every run.
@@ -10,6 +10,23 @@ templates.
1010
- The only dependency should be `@microsoft/vally-cli`, pinned to the version CI should evaluate with.
1111
- `package-lock.json` must be committed so `npm ci` is deterministic.
1212

13+
## TypeScript (no build step)
14+
15+
The `*.ts` sources run directly through Node's native type stripping (erasable syntax only —
16+
no `enum`/`namespace`/parameter properties, no emit). CI pins Node `22.x`, which strips types
17+
unflagged on `>=22.18`; the pipeline `node` invocations and the `npm test` script pass
18+
`--experimental-strip-types` so the same sources also run on older local Node (`>=22.6`), which
19+
prints a harmless `ExperimentalWarning`. Relative imports use explicit `.ts` specifiers, as Node requires.
20+
21+
## Vendored files
22+
23+
- `lib/exec.ts` was **copied from azure-rest-api-specs** (`.github/shared/src/exec.js`
24+
@ `ef7dd74c13aa9ca12b67b33b9dc4b5d1419a46f0`) and ported to TypeScript. It lives here under
25+
`eng/common` (rather than the specs repo's `.github/shared` path) so it travels with the
26+
eng/common sync into the language repos. Re-vendor from upstream rather than editing locally;
27+
see [azure-sdk-tools#16296](https://github.com/Azure/azure-sdk-tools/issues/16296) for the plan
28+
to share these primitives instead of copying.
29+
1330
## Updating the Vally CLI version
1431

1532
1. Bump `@microsoft/vally-cli` in `package.json`.

eng/common/scripts/eval/build-eval-summary.js renamed to eng/common/scripts/eval/build-eval-summary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import fs from "node:fs";
66
import path from "node:path";
77
import { pathToFileURL } from "node:url";
8-
import { globFiles } from "./lib/glob.js";
8+
import { globFiles } from "./lib/glob.ts";
99

1010
// Maps a JUnit file path back to its shard and job attempt. Result artifacts download into
1111
// folders named `eval-result-<shardName>-<attempt>` (the attempt suffix keeps "Rerun failed

eng/common/scripts/eval/collect-stimuli.js renamed to eng/common/scripts/eval/collect-stimuli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import fs from "node:fs";
77
import path from "node:path";
88
import { pathToFileURL } from "node:url";
9-
import { globFiles } from "./lib/glob.js";
9+
import { globFiles } from "./lib/glob.ts";
1010

1111
// Fallback patterns when run with no --pattern. Mirrors archetype-eval.yml's evalGlobs default.
1212
const DEFAULT_PATTERNS = [

eng/common/scripts/eval/init-eval-git-fixtures.js renamed to eng/common/scripts/eval/init-eval-git-fixtures.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import fs from "node:fs";
66
import path from "node:path";
77
import { pathToFileURL } from "node:url";
8-
import { globFiles } from "./lib/glob.js";
9-
import { syncRepo } from "./sync-eval-git-repo.js";
8+
import { globFiles } from "./lib/glob.ts";
9+
import { syncRepo } from "./sync-eval-git-repo.ts";
1010

1111
export const DEFAULT_PATTERNS = [
1212
"evals/tools/*.eval.yaml",
@@ -113,7 +113,7 @@ function parseArgs(argv) {
113113
return options;
114114
}
115115

116-
function main(argv) {
116+
async function main(argv) {
117117
const options = parseArgs(argv);
118118
const root = path.resolve(options.evalRoot);
119119

@@ -139,7 +139,7 @@ function main(argv) {
139139
const sparseCheckoutPaths = known ? known.sparse : [];
140140
const cacheRoot = path.dirname(fixture.cachePath);
141141
console.log(`[prime-fixtures] Priming ${fixture.repoName} @ ${fixture.ref} from ${repoUrl}`);
142-
syncRepo({
142+
await syncRepo({
143143
cacheRoot,
144144
repoUrl,
145145
repoName: fixture.repoName,
@@ -154,10 +154,8 @@ function main(argv) {
154154
}
155155

156156
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
157-
try {
158-
main(process.argv.slice(2));
159-
} catch (error) {
160-
console.error(error.message);
157+
main(process.argv.slice(2)).catch((error) => {
158+
console.error(error instanceof Error ? error.message : error);
161159
process.exit(1);
162-
}
160+
});
163161
}

eng/common/scripts/eval/invoke-eval-shard.js renamed to eng/common/scripts/eval/invoke-eval-shard.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { spawnSync } from "node:child_process";
55
import path from "node:path";
66
import { fileURLToPath, pathToFileURL } from "node:url";
7-
import { getVallyShardVerdict } from "./lib/verdict.js";
7+
import { getVallyShardVerdict } from "./lib/verdict.ts";
88

99
// The pinned Vally CLI is installed next to this script (package.json + node_modules live here),
1010
// so the npm --prefix is just this file's own directory.
@@ -30,6 +30,9 @@ export function runShard({ evalArgs, shardName, outputDir, threshold = 0.8 }) {
3030
);
3131

3232
// Do NOT abort on a non-zero exit — the verdict below is authoritative.
33+
// Uses spawnSync (not the vendored execFile helper) on purpose: the shard needs vally's output
34+
// streamed live to the log (stdio: "inherit") and must keep going on a non-zero exit, whereas
35+
// the exec helper captures output and rejects on failure.
3336
const proc = spawnSync(
3437
"npm",
3538
[

0 commit comments

Comments
 (0)