Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate track2 and refine code for PR scenario #9682

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions tools/spec-gen-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Release

## 2025-01-22 - 0.1.4

- Deprecated 'azure-sdk-for-net-track2' and repurposed 'azure-sdk-for-net' for the .NET track2 SDK
- Added functionality to generate an HTML file for the filtered log

## 2025-01-14 - 0.1.3

- Ensure the PrBranch variable is consistently set in all scenarios
Expand Down
2 changes: 1 addition & 1 deletion tools/spec-gen-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "azsdkteam@microsoft.com",
"url": "https://github.com/Azure/azure-sdk-tools"
},
"version": "0.1.3",
"version": "0.1.4",
"description": "A TypeScript implementation of the API specification to SDK tool",
"tags": [
"spec-gen-sdk"
Expand Down
7 changes: 5 additions & 2 deletions tools/spec-gen-sdk/src/automation/entrypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export const getSdkAutoContext = async (options: SdkAutoOptions): Promise<SdkAut
if (fs.existsSync(filteredLogFileName)) {
fs.rmSync(filteredLogFileName);
}
if (fs.existsSync(htmlLogFileName)) {
fs.rmSync(htmlLogFileName);
}
logger.add(loggerFileTransport(fullLogFileName));
logger.info(`Log to ${fullLogFileName}`);
const localSpecConfigPath = path.join(options.localSpecRepoPath, specConfigPath);
Expand Down Expand Up @@ -121,8 +124,8 @@ export const sdkAutoMain = async (options: SdkAutoOptions) => {
}
if (workflowContext) {
generateReport(workflowContext);
await saveFilteredLog(workflowContext);
await generateHtmlFromFilteredLog(workflowContext);
saveFilteredLog(workflowContext);
generateHtmlFromFilteredLog(workflowContext);
}
await loggerWaitToFinish(sdkContext.logger);
return workflowContext?.status;
Expand Down
4 changes: 2 additions & 2 deletions tools/spec-gen-sdk/src/automation/reportStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const generateReport = (context: WorkflowContext) => {
context.logger.log('endsection', 'Generate report');
}

export const saveFilteredLog = async (context: WorkflowContext) => {
export const saveFilteredLog = (context: WorkflowContext) => {
context.logger.log('section', 'Save filtered log');
let hasBreakingChange = false;
let isBetaMgmtSdk = true;
Expand Down Expand Up @@ -147,7 +147,7 @@ export const saveFilteredLog = async (context: WorkflowContext) => {
context.logger.log('endsection', 'Save filtered log status');
};

export const generateHtmlFromFilteredLog = async (context: WorkflowContext) => {
export const generateHtmlFromFilteredLog = (context: WorkflowContext) => {
context.logger.log('section', 'Generate HTML from filtered log');
const RegexMarkdownSplit = /^(.*?)(<ul>.*)$/s;
const RegexNoteBlock = /> \[!NOTE\]\s*>\s*(.*)/;
Expand Down
25 changes: 13 additions & 12 deletions tools/spec-gen-sdk/src/automation/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ export const workflowInit = async (context: SdkAutoContext): Promise<WorkflowCon

export const workflowMain = async (context: WorkflowContext) => {
if (context.config.pullNumber) {
await workflowValidateSdkConfigForSpecPr(context);
const changedSpecs = await workflowDetectChangedSpec({ ...context });
await workflowValidateSdkConfigForSpecPr(context, changedSpecs);
await workflowCallInitScript(context);
await workflowGenerateSdkForSpecPr(context);
await workflowGenerateSdkForSpecPr(context, changedSpecs);
} else {
await workflowValidateSdkConfig(context);
await workflowCallInitScript(context);
Expand All @@ -133,18 +134,16 @@ export const workflowMain = async (context: WorkflowContext) => {
setSdkAutoStatus(context, 'succeeded');
};

export const workflowValidateSdkConfigForSpecPr = async (context: SdkAutoContext) => {
const specContext = workflowInitSpecRepo(context);
const changedSpecs = await workflowDetectChangedSpec({ ...context, ...specContext });
export const workflowValidateSdkConfigForSpecPr = async (context: WorkflowContext, changedSpecs: ChangedSpecs[]) => {

context.logger.log('section', 'Validate SDK configuration');
const sdkToGenerate = new Set<string>();

const commit = await specContext.specRepo.revparse(branchMain);
const commit = await context.specRepo.revparse(context.config.specCommitSha);
for (const ch of changedSpecs) {
if (ch.typespecProject) {
const entry = await specContext.specRepo.revparse(`${commit}:${ch.typespecProject}`);
const blob = await specContext.specRepo.catFile(['-p', entry]);
const entry = await context.specRepo.revparse(`${commit}:${ch.typespecProject}`);
const blob = await context.specRepo.catFile(['-p', entry]);
const content = blob.toString();
const config = findSDKToGenerateFromTypeSpecProject(content, context.specRepoConfig);
// todo map the sdkName by the sdk language
Expand All @@ -154,8 +153,8 @@ export const workflowValidateSdkConfigForSpecPr = async (context: SdkAutoContext
}
sdkToGenerate.add(context.config.sdkName);
} else if (ch.readmeMd) {
const entry = await specContext.specRepo.revparse(`${commit}:${ch.readmeMd}`);
const blob = await specContext.specRepo.catFile(['-p', entry]);
const entry = await context.specRepo.revparse(`${commit}:${ch.readmeMd}`);
const blob = await context.specRepo.catFile(['-p', entry]);
const content = blob.toString();
const config = findSwaggerToSDKConfiguration(content);
if (!config || config.repositories.length === 0) {
Expand All @@ -170,6 +169,9 @@ export const workflowValidateSdkConfigForSpecPr = async (context: SdkAutoContext
}
}

if (changedSpecs.length === 0) {
throw new Error(`No changed specs are detected and SDK generation is skipped.`);
}
if (sdkToGenerate.size === 0) {
throw new Error(`No SDKs are enabled for generation. Please check the configuration in the realted tspconfig.yaml or readme.md`);
}
Expand Down Expand Up @@ -329,8 +331,7 @@ const workflowHandleReadmeMdOrTypeSpecProject = async (context: WorkflowContext,
context.pendingPackages = [];
};

const workflowGenerateSdkForSpecPr = async (context: WorkflowContext) => {
const changedSpecs = await workflowDetectChangedSpec(context);
const workflowGenerateSdkForSpecPr = async (context: WorkflowContext, changedSpecs: ChangedSpecs[]) => {
context.logger.remove(context.messageCaptureTransport);
const callMode =
context.swaggerToSdkConfig.advancedOptions.generationCallMode ??
Expand Down
7 changes: 0 additions & 7 deletions tools/spec-gen-sdk/src/types/sdks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export type SdkName =
| "azure-sdk-for-java"
| "azure-sdk-for-js"
| "azure-sdk-for-net"
| "azure-sdk-for-net-track2"
| "azure-sdk-for-python";

export const sdkLabels: {
Expand Down Expand Up @@ -50,12 +49,6 @@ export const sdkLabels: {
breakingChangeSuppression: undefined,
breakingChangeSuppressionApproved: undefined,
},
"azure-sdk-for-net-track2": {
breakingChange: undefined,
breakingChangeApproved: undefined,
breakingChangeSuppression: undefined,
breakingChangeSuppressionApproved: undefined
},
"azure-sdk-for-python": {
breakingChange: "BreakingChange-Python-Sdk",
breakingChangeApproved: "BreakingChange-Python-Sdk-Approved",
Expand Down
Loading