Skip to content

Commit 1c16b62

Browse files
authored
Introduce a root folder to save the logs and artifacts (#9715)
* Saved logs in separated folder * Added a root folder to save artifacts and logs
1 parent 7f6ee75 commit 1c16b62

4 files changed

Lines changed: 24 additions & 16 deletions

File tree

tools/spec-gen-sdk/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release
22

3+
## 2025-01-27 - 0.1.5
4+
5+
- Introduced a root folder to save all the logs and artifacts
6+
37
## 2025-01-22 - 0.1.4
48

59
- Deprecated 'azure-sdk-for-net-track2' and repurposed 'azure-sdk-for-net' for the .NET track2 SDK

tools/spec-gen-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"email": "azsdkteam@microsoft.com",
66
"url": "https://github.com/Azure/azure-sdk-tools"
77
},
8-
"version": "0.1.4",
8+
"version": "0.1.5",
99
"description": "A TypeScript implementation of the API specification to SDK tool",
1010
"tags": [
1111
"spec-gen-sdk"

tools/spec-gen-sdk/src/automation/entrypoint.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as fs from 'fs';
1+
import {existsSync, mkdirSync, readFileSync, rmSync} from 'fs';
22
import * as winston from 'winston';
33
import { getRepoKey, RepoKey } from '../utils/repo';
44
import {
@@ -67,18 +67,22 @@ export const getSdkAutoContext = async (options: SdkAutoOptions): Promise<SdkAut
6767
logger.add(loggerTestTransport());
6868
}
6969

70-
const fullLogFileName = path.join(options.workingFolder, 'full.log');
71-
const filteredLogFileName = path.join(options.workingFolder, 'filtered.log');
70+
const logFolder = path.join(options.workingFolder, 'out/logs');
71+
if (!existsSync(logFolder)) {
72+
mkdirSync(logFolder, { recursive: true });
73+
}
74+
const fullLogFileName = path.join(logFolder, 'full.log');
75+
const filteredLogFileName = path.join(logFolder, 'filtered.log');
7276
// eg: spec-gen-sdk-java-result.html
73-
const htmlLogFileName = path.join(options.workingFolder, `spec-gen-sdk-${options.sdkName.substring("azure-sdk-for-".length)}-result.html`);
74-
if (fs.existsSync(fullLogFileName)) {
75-
fs.rmSync(fullLogFileName);
77+
const htmlLogFileName = path.join(logFolder, `spec-gen-sdk-${options.sdkName.substring("azure-sdk-for-".length)}-result.html`);
78+
if (existsSync(fullLogFileName)) {
79+
rmSync(fullLogFileName);
7680
}
77-
if (fs.existsSync(filteredLogFileName)) {
78-
fs.rmSync(filteredLogFileName);
81+
if (existsSync(filteredLogFileName)) {
82+
rmSync(filteredLogFileName);
7983
}
80-
if (fs.existsSync(htmlLogFileName)) {
81-
fs.rmSync(htmlLogFileName);
84+
if (existsSync(htmlLogFileName)) {
85+
rmSync(htmlLogFileName);
8286
}
8387
logger.add(loggerFileTransport(fullLogFileName));
8488
logger.info(`Log to ${fullLogFileName}`);
@@ -92,11 +96,11 @@ export const getSdkAutoContext = async (options: SdkAutoOptions): Promise<SdkAut
9296
const swaggerToSdkConfig = getSwaggerToSdkConfig(swaggerToSdkConfigContent);
9397

9498
return {
95-
htmlLogFileName,
9699
config: options,
97100
logger,
98101
fullLogFileName,
99102
filteredLogFileName,
103+
htmlLogFileName,
100104
specRepoConfig,
101105
sdkRepoConfig,
102106
swaggerToSdkConfig,
@@ -152,7 +156,7 @@ export const getLanguageByRepoName = (repoName: string) => {
152156
export const loadConfigContent = (fileName: string, logger: winston.Logger) => {
153157
logger.info(`Load config file: ${fileName}`);
154158
try {
155-
const fileContent = fs.readFileSync(fileName).toString();
159+
const fileContent = readFileSync(fileName).toString();
156160
const result = JSON.parse(fileContent);
157161
return result;
158162
}

tools/spec-gen-sdk/src/automation/workflowPackage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const workflowPkgDetectArtifacts = async (context: WorkflowContext, pkg: Package
114114
* @param context
115115
* @param pkg
116116
*
117-
* Copy sdk artifact path to {work_dir}/generatedSdkArtifacts
117+
* Copy sdk artifact path to {work_dir}/out/generatedSdkArtifacts
118118
*/
119119
const workflowPkgSaveSDKArtifact = async (context: WorkflowContext, pkg: PackageData) => {
120120
context.logger.info(`Save ${pkg.artifactPaths.length} artifact to Azure devOps.`);
@@ -126,7 +126,7 @@ const workflowPkgSaveSDKArtifact = async (context: WorkflowContext, pkg: Package
126126
return;
127127
}
128128

129-
const destination = path.join(context.config.workingFolder, 'generatedSdkArtifacts');
129+
const destination = path.join(context.config.workingFolder, 'out/generatedSdkArtifacts');
130130
if (!existsSync(destination)) {
131131
fs.mkdirSync(destination, { recursive: true });
132132
}
@@ -152,7 +152,7 @@ const workflowPkgSaveApiViewArtifact = async (context: WorkflowContext, pkg: Pac
152152
}
153153

154154
const language = pkg.language ?? getLanguageByRepoName(context.sdkRepoConfig.mainRepository.name);
155-
const destination = path.join(context.config.workingFolder, 'sdkApiViewArtifacts');
155+
const destination = path.join(context.config.workingFolder, 'out/sdkApiViewArtifacts');
156156
if (!existsSync(destination)) {
157157
fs.mkdirSync(destination, { recursive: true });
158158
}

0 commit comments

Comments
 (0)