Skip to content

Commit fe9ff1f

Browse files
authored
Merge branch 'main' into securitycontext-lease-only
2 parents f231699 + 92c741f commit fe9ff1f

422 files changed

Lines changed: 1332 additions & 1114 deletions

File tree

Some content is hidden

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

.github/shared/src/sdk-types.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export const SpecGenSdkArtifactInfoSchema = z.object({
4646
* breakingChange: string | undefined,
4747
* breakingChangeApproved: string | undefined,
4848
* breakingChangeSuppression: string | undefined,
49-
* breakingChangeSuppressionApproved: string | undefined
49+
* breakingChangeSuppressionApproved: string | undefined,
50+
* buildFailed: string | undefined
5051
* }} SdkLabelInfo
5152
*/
5253

@@ -55,7 +56,7 @@ export const SpecGenSdkArtifactInfoSchema = z.object({
5556
*/
5657

5758
/**
58-
* SDK labels mapping for breaking change labels
59+
* SDK labels mapping for breaking change and build-failure labels
5960
* @type {SdkLabels}
6061
* */
6162
export const sdkLabels = {
@@ -64,35 +65,41 @@ export const sdkLabels = {
6465
breakingChangeApproved: "BreakingChange-Go-Sdk-Approved",
6566
breakingChangeSuppression: "BreakingChange-Go-Sdk-Suppression",
6667
breakingChangeSuppressionApproved: "BreakingChange-Go-Sdk-Suppression-Approved",
68+
buildFailed: undefined,
6769
},
6870
"azure-sdk-for-java": {
6971
breakingChange: undefined,
7072
breakingChangeApproved: undefined,
7173
breakingChangeSuppression: undefined,
7274
breakingChangeSuppressionApproved: undefined,
75+
buildFailed: undefined,
7376
},
7477
"azure-sdk-for-js": {
7578
breakingChange: "BreakingChange-JavaScript-Sdk",
7679
breakingChangeApproved: "BreakingChange-JavaScript-Sdk-Approved",
7780
breakingChangeSuppression: "BreakingChange-JavaScript-Sdk-Suppression",
7881
breakingChangeSuppressionApproved: "BreakingChange-JavaScript-Sdk-Suppression-Approved",
82+
buildFailed: undefined,
7983
},
8084
"azure-sdk-for-net": {
8185
breakingChange: undefined,
8286
breakingChangeApproved: undefined,
8387
breakingChangeSuppression: undefined,
8488
breakingChangeSuppressionApproved: undefined,
89+
buildFailed: "auto-sdk-build-fix",
8590
},
8691
"azure-sdk-for-python": {
8792
breakingChange: "BreakingChange-Python-Sdk",
8893
breakingChangeApproved: "BreakingChange-Python-Sdk-Approved",
8994
breakingChangeSuppression: "BreakingChange-Python-Sdk-Suppression",
9095
breakingChangeSuppressionApproved: "BreakingChange-Python-Sdk-Suppression-Approved",
96+
buildFailed: undefined,
9197
},
9298
"azure-sdk-for-rust": {
9399
breakingChange: undefined,
94100
breakingChangeApproved: undefined,
95101
breakingChangeSuppression: undefined,
96102
breakingChangeSuppressionApproved: undefined,
103+
buildFailed: undefined,
97104
},
98105
};

eng/tools/spec-gen-sdk-runner/src/command-helpers.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
type APIViewRequestData,
3+
sdkLabels,
34
SdkName,
45
SdkNameSchema,
56
type SpecGenSdkArtifactInfo,
@@ -313,6 +314,53 @@ export function getBreakingChangeInfo(executionReport: ExecutionReport): boolean
313314
return false;
314315
}
315316

317+
/**
318+
* Determine whether the SDK generation succeeded but the package build failed.
319+
*
320+
* The `warning` execution result is the contract used by the .NET spec-gen-sdk
321+
* script to signal "an SDK was generated but it did not build". That interpretation
322+
* of `warning` is currently .NET-specific. It does not impact other languages because
323+
* the build-failed label is only emitted for languages that configure a `buildFailed`
324+
* label in the centralized `sdkLabels` map (today only .NET); see
325+
* {@link setBuildFailedLabelVariable}. A language opts in by defining its own
326+
* `buildFailed` label once its build-failed contract is established.
327+
*
328+
* @param executionReport - The spec-gen-sdk execution report.
329+
* @returns true when the execution result is `warning`.
330+
*/
331+
export function getBuildFailedInfo(executionReport: ExecutionReport): boolean {
332+
return executionReport.executionResult === "warning";
333+
}
334+
335+
/**
336+
* Emit the build-failed label pipeline variable for the SDK PR-creation flow.
337+
*
338+
* This is intended to be called only from the PR-creation flow (single-spec SDK release
339+
* scenario) and never from plain spec-PR CI validation. The label is applied to the
340+
* generated SDK pull request so that automated build-failure repair can be triggered.
341+
* The label name is sourced from the centralized `sdkLabels` map; languages without a
342+
* configured `buildFailed` label are skipped, which is what scopes this behavior to
343+
* .NET today (see {@link getBuildFailedInfo} for the `warning` contract).
344+
*
345+
* @param commandInput - The command input (provides the SDK language).
346+
* @param executionReport - The spec-gen-sdk execution report.
347+
*/
348+
export function setBuildFailedLabelVariable(
349+
commandInput: SpecGenSdkCmdInput,
350+
executionReport: ExecutionReport,
351+
): void {
352+
if (!getBuildFailedInfo(executionReport)) {
353+
return;
354+
}
355+
const buildFailedLabel = sdkLabels[commandInput.sdkLanguage]?.buildFailed;
356+
if (buildFailedLabel) {
357+
logMessage(
358+
`Runner: SDK generation succeeded but the build failed; setting BuildFailedLabel variable to '${buildFailedLabel}'`,
359+
);
360+
setVsoVariable("BuildFailedLabel", buildFailedLabel);
361+
}
362+
}
363+
316364
/**
317365
* Generate the spec-gen-sdk artifacts.
318366
* @param commandInput - The command input.

eng/tools/spec-gen-sdk-runner/src/commands.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
prepareSpecGenSdkCommand,
2626
resolvePackagePath,
2727
selectGenerationTool,
28+
setBuildFailedLabelVariable,
2829
setPipelineVariables,
2930
} from "./command-helpers.ts";
3031
import { checkEmitterEnabled, type EmitterCheckResult } from "./emitter-check.ts";
@@ -253,6 +254,13 @@ export async function generateSdkForSingleSpec(): Promise<CommandResult> {
253254
installationInstructions,
254255
);
255256

257+
// Flag the generated SDK pull request for automated build-failure repair when the
258+
// build failed (generation succeeded with a warning). This only runs in the PR-creation
259+
// flow, never in plain spec-PR CI validation.
260+
if (executionReport) {
261+
setBuildFailedLabelVariable(commandInput, executionReport);
262+
}
263+
256264
logMessage("ending group logging", LogLevel.EndGroup);
257265
if (executionReport?.vsoLogPath) {
258266
logIssuesToPipeline(executionReport.vsoLogPath, specConfigPathText);

eng/tools/spec-gen-sdk-runner/test/command-helpers.test.ts

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import {
77
appendErrorsToVsoLog,
88
generateArtifact,
99
getBreakingChangeInfo,
10+
getBuildFailedInfo,
1011
getRequiredSettingValue,
1112
getSpecPaths,
1213
logIssuesToPipeline,
1314
parseArguments,
1415
prepareSpecGenSdkCommand,
1516
selectGenerationTool,
17+
setBuildFailedLabelVariable,
1618
setPipelineVariables,
1719
} from "../src/command-helpers.ts";
1820
import * as log from "../src/log.ts";
@@ -448,6 +450,84 @@ describe("commands.ts", () => {
448450
});
449451
});
450452

453+
describe("getBuildFailedInfo", () => {
454+
test("should return true when the execution result is a warning", () => {
455+
const mockExecutionReport: ExecutionReport = {
456+
executionResult: "warning",
457+
packages: [],
458+
};
459+
460+
expect(getBuildFailedInfo(mockExecutionReport)).toBe(true);
461+
});
462+
463+
test("should return false when the execution result is not a warning", () => {
464+
for (const executionResult of ["succeeded", "failed", "notEnabled"] as const) {
465+
const mockExecutionReport: ExecutionReport = {
466+
executionResult,
467+
packages: [],
468+
};
469+
470+
expect(getBuildFailedInfo(mockExecutionReport)).toBe(false);
471+
}
472+
});
473+
});
474+
475+
describe("setBuildFailedLabelVariable", () => {
476+
const mockCommandInput = (sdkLanguage: SdkName) => ({
477+
workingFolder: "/working/folder",
478+
sdkLanguage,
479+
runMode: "",
480+
localSpecRepoPath: "",
481+
localSdkRepoPath: "",
482+
sdkRepoName: "",
483+
specCommitSha: "abc123",
484+
specRepoHttpsUrl: "",
485+
});
486+
487+
beforeEach(() => {
488+
vi.clearAllMocks();
489+
});
490+
491+
test("should set the BuildFailedLabel variable for .NET when the build failed", () => {
492+
vi.spyOn(log, "setVsoVariable").mockImplementation(() => {
493+
// mock implementation intentionally left blank
494+
});
495+
496+
setBuildFailedLabelVariable(mockCommandInput(SdkName.Net), {
497+
executionResult: "warning",
498+
packages: [],
499+
});
500+
501+
expect(log.setVsoVariable).toHaveBeenCalledWith("BuildFailedLabel", "auto-sdk-build-fix");
502+
});
503+
504+
test("should not set the variable when the build did not fail", () => {
505+
vi.spyOn(log, "setVsoVariable").mockImplementation(() => {
506+
// mock implementation intentionally left blank
507+
});
508+
509+
setBuildFailedLabelVariable(mockCommandInput(SdkName.Net), {
510+
executionResult: "succeeded",
511+
packages: [],
512+
});
513+
514+
expect(log.setVsoVariable).not.toHaveBeenCalled();
515+
});
516+
517+
test("should not set the variable for languages without a configured build-failed label", () => {
518+
vi.spyOn(log, "setVsoVariable").mockImplementation(() => {
519+
// mock implementation intentionally left blank
520+
});
521+
522+
setBuildFailedLabelVariable(mockCommandInput(SdkName.Python), {
523+
executionResult: "warning",
524+
packages: [],
525+
});
526+
527+
expect(log.setVsoVariable).not.toHaveBeenCalled();
528+
});
529+
});
530+
451531
describe("generateArtifact", () => {
452532
beforeEach(() => {
453533
vi.clearAllMocks();

specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_CreateOrUpdate.json renamed to specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_CreateOrUpdate.json

File renamed without changes.

specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Delete.json renamed to specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Delete.json

File renamed without changes.

specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Get.json renamed to specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Get.json

File renamed without changes.

specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_ListByApplication.json renamed to specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_ListByApplication.json

File renamed without changes.

specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Patch.json renamed to specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Patch.json

File renamed without changes.

specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_CreateOrUpdate.json renamed to specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_CreateOrUpdate.json

File renamed without changes.

0 commit comments

Comments
 (0)