Skip to content

Commit e3c67b6

Browse files
authored
Merge branch 'main' into release-redisenterprise-Microsoft.Cache-2025-05-01-preview
2 parents 0f3cc9e + 1b47f62 commit e3c67b6

File tree

1,049 files changed

+109940
-25506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,049 files changed

+109940
-25506
lines changed

.github/package-lock.json

Lines changed: 37 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
"dependencies": "Runtime dependencies must be kept to an absolute minimum for performance, ideally with no transitive dependencies"
55
},
66
"dependencies": {
7-
"marked": "^15.0.7",
8-
"yaml": "^2.7.0"
7+
"@apidevtools/json-schema-ref-parser": "^11.9.3",
8+
"js-yaml": "^4.1.0",
9+
"marked": "^15.0.7"
910
},
1011
"devDependencies": {
1112
"@eslint/js": "^9.22.0",
1213
"@octokit/webhooks-types": "^7.5.1",
1314
"@tsconfig/node20": "^20.1.4",
1415
"@types/github-script": "github:actions/github-script",
16+
"@types/js-yaml": "^4.0.9",
1517
"@types/node": "^20.0.0",
1618
"@vitest/coverage-v8": "^3.0.7",
1719
"eslint": "^9.22.0",

.github/src/changed-files.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ import { diff } from "./git.js";
44

55
/**
66
* @param {Object} [options]
7-
* @param {string} [options.baseCommitish] Defaults to "HEAD^"
8-
* @param {string} [options.headCommitish] Defaults to "HEAD"
7+
* @param {string} [options.baseCommitish] Default: "HEAD^".
8+
* @param {string} [options.cwd] Current working directory. Default: process.cwd().
9+
* @param {string} [options.headCommitish] Default: "HEAD".
910
* @param {import('./types.js').ILogger} [options.logger]
10-
* @returns {Promise<string[]>} List of changed files, relative to the repo root. Example: ["specification/foo/Microsoft.Foo/main.tsp"]
11+
* @returns {Promise<string[]>} List of changed files, using posix paths, relative to options.cwd. Example: ["specification/foo/Microsoft.Foo/main.tsp"].
1112
*/
1213
export async function getChangedFiles(options = {}) {
13-
const { baseCommitish = "HEAD^", headCommitish = "HEAD", logger } = options;
14+
const {
15+
baseCommitish = "HEAD^",
16+
cwd,
17+
headCommitish = "HEAD",
18+
logger,
19+
} = options;
1420

1521
// TODO: If we need to filter based on status, instead of passing an argument to `--diff-filter,
1622
// consider using "--name-status" instead of "--name-only", and return an array of objects like
@@ -19,6 +25,7 @@ export async function getChangedFiles(options = {}) {
1925
// filter based on status with a single call to `git diff`.
2026
const result = await diff(baseCommitish, headCommitish, {
2127
args: "--name-only",
28+
cwd,
2229
logger: logger,
2330
});
2431

.github/src/exec.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@
22

33
import child_process from "child_process";
44
import { promisify } from "util";
5-
const exec = promisify(child_process.exec);
5+
const execImpl = promisify(child_process.exec);
66

77
/**
88
* @param {string} command
99
* @param {Object} [options]
10+
* @param {string} [options.cwd] Current working directory. Default: process.cwd().
1011
* @param {import('./types.js').ILogger} [options.logger]
1112
* @param {number} [options.maxBuffer]
1213
*/
13-
export async function execRoot(command, options = {}) {
14-
// Node default is 1024 * 1024, which is too small for some git commands returning many entities or large file content.
15-
// To support "git show", should be larger than the largest swagger file in the repo (2.5 MB as of 2/28/2025).
16-
const defaultMaxBuffer = 16 * 1024 * 1024;
14+
export async function exec(command, options = {}) {
15+
const {
16+
cwd,
17+
logger,
18+
// Node default is 1024 * 1024, which is too small for some git commands returning many entities or large file content.
19+
// To support "git show", should be larger than the largest swagger file in the repo (2.5 MB as of 2/28/2025).
20+
maxBuffer = 16 * 1024 * 1024,
21+
} = options;
1722

18-
const { logger, maxBuffer = defaultMaxBuffer } = options;
19-
20-
logger?.info(`execRoot("${command}")`);
23+
logger?.info(`exec("${command}")`);
2124

2225
// TODO: Handle errors
23-
const result = await exec(command, {
24-
cwd: process.env.GITHUB_WORKSPACE,
26+
const result = await execImpl(command, {
27+
cwd,
2528
maxBuffer,
2629
});
2730

.github/src/git.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22

3-
import { buildCmd, execRoot } from "./exec.js";
3+
import { buildCmd, exec } from "./exec.js";
44

55
/**
66
* @typedef {import('./types.js').ILogger} ILogger
@@ -11,64 +11,66 @@ import { buildCmd, execRoot } from "./exec.js";
1111
* @param {string} headCommitish
1212
* @param {Object} [options]
1313
* @param {string} [options.args]
14+
* @param {string} [options.cwd] Current working directory. Default: process.cwd().
1415
* @param {ILogger} [options.logger]
1516
* @returns {Promise<string>}
1617
*/
1718
export async function diff(baseCommitish, headCommitish, options = {}) {
18-
const { args, logger } = options;
19+
const { args, cwd, logger } = options;
1920

2021
const cmd = buildCmd("diff", args, baseCommitish, headCommitish);
2122

22-
return await execGit(cmd, {
23-
logger: logger,
24-
});
23+
return await execGit(cmd, { cwd, logger });
2524
}
2625

2726
/**
2827
* @param {string} treeIsh
2928
* @param {string} path
3029
* @param {Object} [options]
3130
* @param {string} [options.args]
31+
* @param {string} [options.cwd] Current working directory. Default process.cwd().
3232
* @param {ILogger} [options.logger]
3333
* @returns {Promise<string>}
3434
*/
3535
export async function lsTree(treeIsh, path, options = {}) {
36-
const { args, logger } = options;
36+
const { args, cwd, logger } = options;
3737

3838
const cmd = buildCmd("ls-tree", args, treeIsh, path);
3939

40-
return await execGit(cmd, {
41-
logger: logger,
42-
});
40+
return await execGit(cmd, { cwd, logger });
4341
}
4442

4543
/**
4644
* @param {string} treeIsh
4745
* @param {string} path
4846
* @param {Object} [options]
4947
* @param {string} [options.args]
48+
* @param {string} [options.cwd] Current working directory. Default: process.cwd().
5049
* @param {ILogger} [options.logger]
5150
* @returns {Promise<string>}
5251
*/
5352
export async function show(treeIsh, path, options = {}) {
54-
const { args, logger } = options;
53+
const { args, cwd, logger } = options;
5554

5655
const cmd = buildCmd("show", args, `${treeIsh}:${path}`);
5756

58-
return await execGit(cmd, { logger: logger });
57+
return await execGit(cmd, { cwd, logger });
5958
}
6059

6160
/**
6261
* @param {string} args
6362
* @param {Object} [options]
63+
* @param {string} [options.cwd] Current working directory. Default: process.cwd().
6464
* @param {ILogger} [options.logger]
6565
* @returns {Promise<string>}
6666
*/
67-
async function execGit(args, options) {
67+
async function execGit(args, options = {}) {
68+
const { cwd, logger } = options;
69+
6870
// Ensure that git displays filenames as they are (without escaping)
6971
const defaultConfig = "-c core.quotepath=off";
7072

7173
const cmd = buildCmd("git", defaultConfig, args);
7274

73-
return await execRoot(cmd, options);
75+
return await exec(cmd, { cwd, logger });
7476
}

.github/src/readme.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

3+
import yaml from "js-yaml";
34
import { marked } from "marked";
4-
import yaml from "yaml";
55

66
/**
77
* @param {string} markdown
@@ -24,7 +24,7 @@ export async function getInputFiles(markdown, options = {}) {
2424
const tag =
2525
block.lang?.match(/yaml \$\(tag\) == '([^']*)'/)?.[1] || "default";
2626

27-
const obj = yaml.parse(block.text);
27+
const obj = /** @type {any} */ (yaml.load(block.text));
2828
const blockFiles = /** @type string[] */ (obj["input-file"] || []);
2929

3030
logger?.info(`Input files for tag '${tag}': ${JSON.stringify(blockFiles)}`);

.github/test/exec.test.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EOL } from "os";
22
import { describe, expect, it } from "vitest";
3-
import { buildCmd, execRoot } from "../src/exec.js";
3+
import { buildCmd, exec } from "../src/exec.js";
44
import { createMockLogger } from "./mocks.js";
55

66
describe("exec", () => {
@@ -9,21 +9,21 @@ describe("exec", () => {
99
const expected = `${str}${EOL}`;
1010

1111
it.each([{}, { logger: createMockLogger() }])(
12-
"execRoot succeeds with default buffer (options: %o)",
12+
"exec succeeds with default buffer (options: %o)",
1313
async (options) => {
14-
await expect(execRoot(cmd, options)).resolves.toEqual(expected);
14+
await expect(exec(cmd, options)).resolves.toEqual(expected);
1515
},
1616
);
1717

18-
it("execRoot succeeds with exact-sized buffer", async () => {
19-
await expect(
20-
execRoot(cmd, { maxBuffer: expected.length }),
21-
).resolves.toEqual(expected);
18+
it("exec succeeds with exact-sized buffer", async () => {
19+
await expect(exec(cmd, { maxBuffer: expected.length })).resolves.toEqual(
20+
expected,
21+
);
2222
});
2323

24-
it("execRoot fails with too-small buffer", async () => {
24+
it("exec fails with too-small buffer", async () => {
2525
await expect(
26-
execRoot(cmd, { maxBuffer: expected.length - 1 }),
26+
exec(cmd, { maxBuffer: expected.length - 1 }),
2727
).rejects.toThrowError(
2828
expect.objectContaining({ code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER" }),
2929
);

.github/test/git.test.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,37 @@ describe("git", () => {
2828

2929
describe("mocked", () => {
3030
it("diff", async () => {
31-
const execRootSpy = vi
32-
.spyOn(exec, "execRoot")
33-
.mockResolvedValue("test diff");
31+
const execSpy = vi.spyOn(exec, "exec").mockResolvedValue("test diff");
3432

3533
await expect(diff("HEAD^", "HEAD")).resolves.toBe("test diff");
3634

37-
expect(execRootSpy).toBeCalledWith(
35+
expect(execSpy).toBeCalledWith(
3836
"git -c core.quotepath=off diff HEAD^ HEAD",
3937
expect.anything(),
4038
);
4139
});
4240

4341
it("lsTree", async () => {
44-
const execRootSpy = vi
45-
.spyOn(exec, "execRoot")
46-
.mockResolvedValue("test lstree");
42+
const execSpy = vi.spyOn(exec, "exec").mockResolvedValue("test lstree");
4743

4844
await expect(
4945
lsTree("HEAD", "specification/contosowidgetmanager"),
5046
).resolves.toBe("test lstree");
5147

52-
expect(execRootSpy).toBeCalledWith(
48+
expect(execSpy).toBeCalledWith(
5349
"git -c core.quotepath=off ls-tree HEAD specification/contosowidgetmanager",
5450
expect.anything(),
5551
);
5652
});
5753

5854
it("show", async () => {
59-
const execRootSpy = vi
60-
.spyOn(exec, "execRoot")
61-
.mockResolvedValue("test show");
55+
const execSpy = vi.spyOn(exec, "exec").mockResolvedValue("test show");
6256

6357
await expect(
6458
show("HEAD", "specification/contosowidgetmanager/cspell.yaml"),
6559
).resolves.toBe("test show");
6660

67-
expect(execRootSpy).toBeCalledWith(
61+
expect(execSpy).toBeCalledWith(
6862
"git -c core.quotepath=off show HEAD:specification/contosowidgetmanager/cspell.yaml",
6963
expect.anything(),
7064
);

.github/workflows/src/arm-incremental-typespec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ import { CoreLogger } from "./core-logger.js";
1818
* @returns {Promise<boolean>}
1919
*/
2020
export default async function incrementalTypeSpec({ core }) {
21-
const options = { logger: new CoreLogger(core) };
21+
const options = {
22+
cwd: process.env.GITHUB_WORKSPACE,
23+
logger: new CoreLogger(core),
24+
};
2225

2326
const changedFiles = await getChangedFiles(options);
2427

0 commit comments

Comments
 (0)