Skip to content

Commit ad4f529

Browse files
Merge pull request #303 from sushobhit-lt/DOT-5825
add github URL argument support
2 parents 578be66 + dd91556 commit ad4f529

File tree

7 files changed

+21
-6
lines changed

7 files changed

+21
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-cli",
3-
"version": "4.1.15",
3+
"version": "4.1.16",
44
"description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
55
"files": [
66
"dist/**/*"

src/commander/commander.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ program
2020
.option('--markBaseline', 'Mark this build baseline')
2121
.option('--baselineBranch <string>', 'Mark this build baseline')
2222
.option('--baselineBuild <string>', 'Mark this build baseline')
23+
.option('--githubURL <string>', 'GitHub URL including commitId')
2324
.addCommand(exec)
2425
.addCommand(capture)
2526
.addCommand(configWeb)

src/lib/ctx.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default (options: Record<string, string>): Context => {
2626
try {
2727
if (options.config) {
2828
config = JSON.parse(fs.readFileSync(options.config, 'utf-8'));
29-
logger.debug(`Config file ${options.config} loaded: ${JSON.stringify(config, null, 2)}`);
29+
// TODO: Mask sensitive data of config file
30+
// logger.debug(`Config file ${options.config} loaded: ${JSON.stringify(config, null, 2)}`);
3031

3132
// resolutions supported for backward compatibility
3233
if (config.web?.resolutions) {
@@ -148,7 +149,8 @@ export default (options: Record<string, string>): Context => {
148149
fetchResults: fetchResultObj,
149150
fetchResultsFileName: fetchResultsFileObj,
150151
baselineBranch: options.baselineBranch || '',
151-
baselineBuild: options.baselineBuild || ''
152+
baselineBuild: options.baselineBuild || '',
153+
githubURL : options.githubURL || ''
152154
},
153155
cliVersion: version,
154156
totalSnapshots: -1,

src/lib/git.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export default (ctx: Context): Git => {
3333
ctx.env.SMART_GIT = false
3434
}
3535
}
36+
let githubURL;
37+
if (ctx.options.githubURL && ctx.options.githubURL.startsWith('https://')) {
38+
githubURL = ctx.options.githubURL;
39+
}
3640
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
3741
let gitInfo = JSON.parse(fs.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, 'utf-8'));
3842

@@ -46,7 +50,7 @@ export default (ctx: Context): Git => {
4650
commitId: gitInfo.commit_id.slice(0,6) || '',
4751
commitMessage: gitInfo.commit_body || '',
4852
commitAuthor: gitInfo.commit_author || '',
49-
githubURL: (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : '',
53+
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : '',
5054
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
5155
}
5256
} else {
@@ -73,7 +77,7 @@ export default (ctx: Context): Git => {
7377
commitId: res[0] || '',
7478
commitMessage: res[2] || '',
7579
commitAuthor: res[7] || '',
76-
githubURL: (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : '',
80+
githubURL: githubURL ? githubURL : (ctx.env.GITHUB_ACTIONS) ? `${constants.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : '',
7781
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ''
7882
};
7983
}

src/lib/server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export default async (ctx: Context): Promise<FastifyInstance<Server, IncomingMes
6464
console.log(`Failed to fetch capabilities for sessionId ${sessionId}: ${error.message}`);
6565
}
6666
}
67+
68+
if (capsBuildId && capsBuildId !== '') {
69+
process.env.SMARTUI_BUILD_ID = capsBuildId;
70+
}
6771
}
6872

6973
ctx.testType = testType;

src/tasks/getGitInfo.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1616
try {
1717
ctx.git = getGitInfo(ctx);
1818
task.output = chalk.gray(`branch: ${ctx.git.branch}, commit: ${ctx.git.commitId}, author: ${ctx.git.commitAuthor}`);
19+
if (ctx.git.githubURL && ctx.git.githubURL !== '') {
20+
task.output += chalk.gray(`, githubURL: ${ctx.git.githubURL}`);
21+
}
1922
task.title = 'Fetched git information'
2023
} catch (error: any) {
2124
ctx.log.debug(error);

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ export interface Context {
6161
fetchResults?: boolean,
6262
fetchResultsFileName?: string,
6363
baselineBranch?: string,
64-
baselineBuild?: string
64+
baselineBuild?: string,
65+
githubURL?: string
6566
}
6667
cliVersion: string;
6768
totalSnapshots: number;

0 commit comments

Comments
 (0)