diff --git a/tools/spec-gen-sdk/CHANGELOG.md b/tools/spec-gen-sdk/CHANGELOG.md index 6ee86725182..a35f4c4def6 100644 --- a/tools/spec-gen-sdk/CHANGELOG.md +++ b/tools/spec-gen-sdk/CHANGELOG.md @@ -1,5 +1,9 @@ # Release +## 2025-12-18 - 0.9.5 + +- Override 'generateFromTypeSpec' value by the result in 'generateOutput.json' for .NET + ## 2025-12-12 - 0.9.4 - Updated 'generateFromTypeSpec' value to the result returned from the language script for .NET diff --git a/tools/spec-gen-sdk/package-lock.json b/tools/spec-gen-sdk/package-lock.json index 0f48bf5dc50..c664d1a978f 100644 --- a/tools/spec-gen-sdk/package-lock.json +++ b/tools/spec-gen-sdk/package-lock.json @@ -1,12 +1,12 @@ { "name": "@azure-tools/spec-gen-sdk", - "version": "0.9.4", + "version": "0.9.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@azure-tools/spec-gen-sdk", - "version": "0.9.4", + "version": "0.9.5", "license": "MIT", "dependencies": { "ajv": "^6.12.6", diff --git a/tools/spec-gen-sdk/package.json b/tools/spec-gen-sdk/package.json index 845ce17573e..ee14f1069d6 100644 --- a/tools/spec-gen-sdk/package.json +++ b/tools/spec-gen-sdk/package.json @@ -5,7 +5,7 @@ "email": "azsdkteam@microsoft.com", "url": "https://github.com/Azure/azure-sdk-tools" }, - "version": "0.9.4", + "version": "0.9.5", "description": "A TypeScript implementation of the API specification to SDK tool", "tags": [ "spec-gen-sdk" diff --git a/tools/spec-gen-sdk/src/automation/reportStatus.ts b/tools/spec-gen-sdk/src/automation/reportStatus.ts index c7ce2bb5893..619e584eef0 100644 --- a/tools/spec-gen-sdk/src/automation/reportStatus.ts +++ b/tools/spec-gen-sdk/src/automation/reportStatus.ts @@ -5,12 +5,13 @@ import { setSdkAutoStatus } from '../utils/runScript'; import { extractPathFromSpecConfig, mapToObject } from '../utils/utils'; import { vsoAddAttachment, vsoLogError, vsoLogWarning } from './logging'; import { ExecutionReport, PackageReport } from '../types/ExecutionReport'; -import { deleteTmpJsonFile, writeTmpJsonFile } from '../utils/fsUtils'; +import { deleteTmpJsonFile, readTmpJsonFile, writeTmpJsonFile } from '../utils/fsUtils'; import { marked } from "marked"; -import { toolError, toolWarning } from '../utils/messageUtils'; +import { externalError, toolError, toolWarning } from '../utils/messageUtils'; import { FailureType, WorkflowContext } from '../types/Workflow'; import { setFailureType } from '../utils/workflowUtils'; import { commentDetailView, renderHandlebarTemplate } from '../utils/reportStatusUtils'; +import { getGenerateOutput } from '../types/GenerateOutput'; export const generateReport = (context: WorkflowContext) => { context.logger.log('section', 'Generate report'); @@ -25,10 +26,9 @@ export const generateReport = (context: WorkflowContext) => { let markdownContent = ''; let message = ""; let isTypeSpec = false; - let hasPkgFromTypeSpec = false; let generateFromTypeSpec = false; - if (!context.config.sdkName.includes('net') && context.specConfigPath && context.specConfigPath.endsWith('tspconfig.yaml')) { + if (context.specConfigPath && context.specConfigPath.endsWith('tspconfig.yaml')) { generateFromTypeSpec = true; } for (const pkg of context.handledPackages) { @@ -80,12 +80,20 @@ export const generateReport = (context: WorkflowContext) => { `hasSuppressions [${hasSuppressions}] ` + `hasAbsentSuppressions [${hasAbsentSuppressions}]` ); - hasPkgFromTypeSpec = hasPkgFromTypeSpec || isTypeSpec; } - // only for .NET SDK, use the flag returned from the .NET automation to mark the whole generationFromTypeSpec - if (context.config.sdkName.includes('net') && hasPkgFromTypeSpec) { - generateFromTypeSpec = true; + // for .NET SDK in spec PR scenario, override generateFromTypeSpec by the value returned from the .NET automation script + if (context.config.sdkName.includes('net') && context.config.runMode === 'spec-pull-request') { + generateFromTypeSpec = false; + const generateOutputJson = readTmpJsonFile(context, 'generateOutput.json'); + if (generateOutputJson === undefined) { + message = externalError('Failed to read generateOutput.json. Please check if the generate script is configured correctly.'); + throw new Error(message); + } + const generateOutput = getGenerateOutput(generateOutputJson); + if (generateOutput?.packages?.[0]?.typespecProject) { + generateFromTypeSpec = true; + } } if (context.config.pullNumber && markdownContent) {