Skip to content

Commit 9a5ec14

Browse files
committed
removing unnecessary params
1 parent 915c0e6 commit 9a5ec14

File tree

6 files changed

+13
-156
lines changed

6 files changed

+13
-156
lines changed

setup-env/action.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@ inputs:
1313
project-name:
1414
description: 'Project name for the tests'
1515
required: false
16-
rerun-attempt:
17-
description: 'ReRun attempt'
18-
required: false
19-
default: 'none'
20-
repository:
21-
description: 'GitHub context - Repository'
22-
required: false
23-
default: 'none'
24-
run-id:
25-
description: 'GitHub context - Run_ID'
26-
required: false
27-
default: 'none'
2816
github-token:
2917
description: 'GitHub Token for authentication'
3018
required: false

setup-env/config/constants.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ module.exports = {
44
ACCESS_KEY: 'access-key',
55
BUILD_NAME: 'build-name',
66
PROJECT_NAME: 'project-name',
7-
RERUN_ATTEMPT: 'rerun-attempt',
8-
REPOSITORY: 'repository',
9-
RUN_ID: 'run-id',
107
GITHUB_TOKEN: 'github-token',
118
GITHUB_APP: 'github-app',
129
},
@@ -15,7 +12,7 @@ module.exports = {
1512
BROWSERSTACK_USERNAME: 'BROWSERSTACK_USERNAME',
1613
BROWSERSTACK_ACCESS_KEY: 'BROWSERSTACK_ACCESS_KEY',
1714
BROWSERSTACK_BUILD_NAME: 'BROWSERSTACK_BUILD_NAME',
18-
BROWSERSTACK_PROJECT_NAME: 'BROWSERSTACK_PROJECT_NAME'
15+
BROWSERSTACK_PROJECT_NAME: 'BROWSERSTACK_PROJECT_NAME',
1916
},
2017

2118
BROWSERSTACK_TEMPLATE: {

setup-env/dist/index.js

Lines changed: 6 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ module.exports = {
1010
ACCESS_KEY: 'access-key',
1111
BUILD_NAME: 'build-name',
1212
PROJECT_NAME: 'project-name',
13-
RERUN_ATTEMPT: 'rerun-attempt',
14-
REPOSITORY: 'repository',
15-
RUN_ID: 'run-id',
1613
GITHUB_TOKEN: 'github-token',
1714
GITHUB_APP: 'github-app',
1815
},
@@ -21,7 +18,7 @@ module.exports = {
2118
BROWSERSTACK_USERNAME: 'BROWSERSTACK_USERNAME',
2219
BROWSERSTACK_ACCESS_KEY: 'BROWSERSTACK_ACCESS_KEY',
2320
BROWSERSTACK_BUILD_NAME: 'BROWSERSTACK_BUILD_NAME',
24-
BROWSERSTACK_PROJECT_NAME: 'BROWSERSTACK_PROJECT_NAME'
21+
BROWSERSTACK_PROJECT_NAME: 'BROWSERSTACK_PROJECT_NAME',
2522
},
2623

2724
BROWSERSTACK_TEMPLATE: {
@@ -9335,7 +9332,7 @@ const axios = __nccwpck_require__(8757);
93359332
const github = __nccwpck_require__(5438);
93369333
const InputValidator = __nccwpck_require__(4881);
93379334
const constants = __nccwpck_require__(1468);
9338-
const { BROWSERSTACK_TEMPLATE} = __nccwpck_require__(1468);
9335+
const { BROWSERSTACK_TEMPLATE } = __nccwpck_require__(1468);
93399336

93409337
const {
93419338
INPUT,
@@ -9366,11 +9363,11 @@ class ActionInput {
93669363
this.buildName = core.getInput(INPUT.BUILD_NAME);
93679364
this.projectName = core.getInput(INPUT.PROJECT_NAME);
93689365

9369-
this.rerunAttempt = core.getInput(INPUT.RERUN_ATTEMPT);
9370-
this.repository = core.getInput(INPUT.REPOSITORY);
9371-
this.runId = core.getInput(INPUT.RUN_ID);
93729366
this.githubToken = core.getInput(INPUT.GITHUB_TOKEN);
93739367
this.githubApp = core.getInput(INPUT.GITHUB_APP);
9368+
this.rerunAttempt = process?.env?.GITHUB_RUN_ATTEMPT;
9369+
this.runId = process?.env?.GITHUB_RUN_ID;
9370+
this.repository = `${github?.context?.repo?.owner}/${github?.context?.repo?.repo}`;
93749371
} catch (e) {
93759372
throw Error(`Action input failed for reason: ${e.message}`);
93769373
}
@@ -9383,9 +9380,6 @@ class ActionInput {
93839380
this.username = InputValidator.updateUsername(this.username);
93849381
this.buildName = InputValidator.validateBuildName(this.buildName);
93859382
this.projectName = InputValidator.validateProjectName(this.projectName);
9386-
this.rerunAttempt = InputValidator.validateRerunAttempt(this.rerunAttempt);
9387-
this.runId = InputValidator.validateRunId(this.runId);
9388-
this.repository = InputValidator.validateRepository(this.repository);
93899383
this.githubToken = InputValidator.validateGithubToken(this.githubToken);
93909384
this.githubApp = InputValidator.validateGithubAppName(this.githubApp);
93919385
}
@@ -9410,11 +9404,6 @@ class ActionInput {
94109404
core.info(`${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable set as: ${this.buildName}`);
94119405
core.info(`Use ${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable for your build name capability in your tests\n`);
94129406

9413-
const runIdDirect = process.env.GITHUB_RUN_ID;
9414-
const rerunAttemptDirect = process.env.GITHUB_RUN_ATTEMPT;
9415-
const repositoryDirect = `${github.context.repo.owner}/${github.context.repo.repo}`;
9416-
core.info(`Direct values are - runIdDirect: ${runIdDirect}, rerunAttemptDirect: ${rerunAttemptDirect}, repositoryDirect: ${repositoryDirect}`);
9417-
94189407
core.info(`Values of Bstack creds are: username - ${this.username}, accessKey - ${this.accessKey}`);
94199408
core.info(`Values of extractable vars are: rerunAttempt - ${this.rerunAttempt}, runId - ${this.runId}, repository - ${this.repository}`);
94209409
core.info(`Values of mandatory parms are: github_token - ${this.githubToken}, githubApp - ${this.githubApp}`);
@@ -9476,7 +9465,7 @@ class ActionInput {
94769465
const variables = bsApiResponse.data?.variables;
94779466
if (variables && typeof variables === 'object') {
94789467
// Iterate over all keys in variables and set them as environment variables
9479-
Object.keys(variables).forEach(key => {
9468+
Object.keys(variables).forEach((key) => {
94809469
core.exportVariable(key, variables[key]);
94819470
});
94829471
}
@@ -9611,44 +9600,6 @@ class InputValidator {
96119600
return inputProjectName;
96129601
}
96139602

9614-
/**
9615-
* Validates the rerun-attempt to ensure it is a valid number or 'none'.
9616-
* If the input is 'none' or not provided, it returns -1.
9617-
* @param {string} rerunAttempt Input for 'rerun-attempt'
9618-
* @returns {number} The validated rerun-attempt as a number, or -1 if 'none' or invalid
9619-
* @throws {Error} If the input is not a valid positive number or 'none'
9620-
*/
9621-
static validateRerunAttempt(rerunAttempt) {
9622-
if (rerunAttempt && rerunAttempt.toLowerCase() !== 'none') {
9623-
const parsedAttempt = Number(rerunAttempt);
9624-
if (!Number.isNaN(parsedAttempt) && parsedAttempt >= 0) {
9625-
return parsedAttempt;
9626-
}
9627-
throw new Error("Invalid input for 'rerun-attempt'. Must be a positive number or 'none'.");
9628-
}
9629-
9630-
return -1;
9631-
}
9632-
9633-
/**
9634-
* Validates the run-id to ensure it is a valid number or 'none'.
9635-
* If the input is 'none' or not provided, it returns -1.
9636-
* @param {string} runId Input for 'run-id'
9637-
* @returns {number} The validated run-id as a number, or -1 if 'none' or invalid
9638-
* @throws {Error} If the input is not a valid positive number or 'none'
9639-
*/
9640-
static validateRunId(runId) {
9641-
if (runId && runId.toLowerCase() !== 'none') {
9642-
const parsedRunId = Number(runId);
9643-
if (!Number.isNaN(parsedRunId) && parsedRunId >= 0) {
9644-
return parsedRunId;
9645-
}
9646-
throw new Error("Invalid input for 'run-id'. Must be a positive number or 'none'.");
9647-
}
9648-
9649-
return -1;
9650-
}
9651-
96529603
/**
96539604
* Validates the GitHub token input to ensure it is a valid non-empty string.
96549605
* If the input is 'none' or not provided, it returns 'none'.
@@ -9666,23 +9617,6 @@ class InputValidator {
96669617
return 'none';
96679618
}
96689619

9669-
/**
9670-
* Validates the repository input to ensure it is a valid non-empty string.
9671-
* If the input is 'none' or not provided, it returns 'none'.
9672-
* @param {string} repository Input for 'repository'
9673-
* @returns {string} Validated repository name, or 'none' if input is 'none' or invalid
9674-
* @throws {Error} If the input is not a valid non-empty string
9675-
*/
9676-
static validateRepository(repository) {
9677-
if (repository && repository.toLowerCase() !== 'none') {
9678-
if (typeof repository === 'string' && repository.trim().length > 0) {
9679-
return repository;
9680-
}
9681-
throw new Error("Invalid input for 'repository'. Must be a valid string.");
9682-
}
9683-
return 'none';
9684-
}
9685-
96869620
/**
96879621
* Validates the app name input to ensure it is a valid non-empty string.
96889622
* If the input is 'none' or not provided, it returns 'none'.

setup-env/src/actionInput/index.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const axios = require('axios');
33
const github = require('@actions/github');
44
const InputValidator = require('./inputValidator');
55
const constants = require('../../config/constants');
6-
const { BROWSERSTACK_TEMPLATE} = require("../../config/constants");
6+
const { BROWSERSTACK_TEMPLATE } = require("../../config/constants");
77

88
const {
99
INPUT,
@@ -34,11 +34,11 @@ class ActionInput {
3434
this.buildName = core.getInput(INPUT.BUILD_NAME);
3535
this.projectName = core.getInput(INPUT.PROJECT_NAME);
3636

37-
this.rerunAttempt = core.getInput(INPUT.RERUN_ATTEMPT);
38-
this.repository = core.getInput(INPUT.REPOSITORY);
39-
this.runId = core.getInput(INPUT.RUN_ID);
4037
this.githubToken = core.getInput(INPUT.GITHUB_TOKEN);
4138
this.githubApp = core.getInput(INPUT.GITHUB_APP);
39+
this.rerunAttempt = process?.env?.GITHUB_RUN_ATTEMPT;
40+
this.runId = process?.env?.GITHUB_RUN_ID;
41+
this.repository = `${github?.context?.repo?.owner}/${github?.context?.repo?.repo}`;
4242
} catch (e) {
4343
throw Error(`Action input failed for reason: ${e.message}`);
4444
}
@@ -51,9 +51,6 @@ class ActionInput {
5151
this.username = InputValidator.updateUsername(this.username);
5252
this.buildName = InputValidator.validateBuildName(this.buildName);
5353
this.projectName = InputValidator.validateProjectName(this.projectName);
54-
this.rerunAttempt = InputValidator.validateRerunAttempt(this.rerunAttempt);
55-
this.runId = InputValidator.validateRunId(this.runId);
56-
this.repository = InputValidator.validateRepository(this.repository);
5754
this.githubToken = InputValidator.validateGithubToken(this.githubToken);
5855
this.githubApp = InputValidator.validateGithubAppName(this.githubApp);
5956
}
@@ -78,11 +75,6 @@ class ActionInput {
7875
core.info(`${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable set as: ${this.buildName}`);
7976
core.info(`Use ${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable for your build name capability in your tests\n`);
8077

81-
const runIdDirect = process.env.GITHUB_RUN_ID;
82-
const rerunAttemptDirect = process.env.GITHUB_RUN_ATTEMPT;
83-
const repositoryDirect = `${github.context.repo.owner}/${github.context.repo.repo}`;
84-
core.info(`Direct values are - runIdDirect: ${runIdDirect}, rerunAttemptDirect: ${rerunAttemptDirect}, repositoryDirect: ${repositoryDirect}`);
85-
8678
core.info(`Values of Bstack creds are: username - ${this.username}, accessKey - ${this.accessKey}`);
8779
core.info(`Values of extractable vars are: rerunAttempt - ${this.rerunAttempt}, runId - ${this.runId}, repository - ${this.repository}`);
8880
core.info(`Values of mandatory parms are: github_token - ${this.githubToken}, githubApp - ${this.githubApp}`);
@@ -144,7 +136,7 @@ class ActionInput {
144136
const variables = bsApiResponse.data?.variables;
145137
if (variables && typeof variables === 'object') {
146138
// Iterate over all keys in variables and set them as environment variables
147-
Object.keys(variables).forEach(key => {
139+
Object.keys(variables).forEach((key) => {
148140
core.exportVariable(key, variables[key]);
149141
});
150142
}

setup-env/src/actionInput/inputValidator.js

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -115,44 +115,6 @@ class InputValidator {
115115
return inputProjectName;
116116
}
117117

118-
/**
119-
* Validates the rerun-attempt to ensure it is a valid number or 'none'.
120-
* If the input is 'none' or not provided, it returns -1.
121-
* @param {string} rerunAttempt Input for 'rerun-attempt'
122-
* @returns {number} The validated rerun-attempt as a number, or -1 if 'none' or invalid
123-
* @throws {Error} If the input is not a valid positive number or 'none'
124-
*/
125-
static validateRerunAttempt(rerunAttempt) {
126-
if (rerunAttempt && rerunAttempt.toLowerCase() !== 'none') {
127-
const parsedAttempt = Number(rerunAttempt);
128-
if (!Number.isNaN(parsedAttempt) && parsedAttempt >= 0) {
129-
return parsedAttempt;
130-
}
131-
throw new Error("Invalid input for 'rerun-attempt'. Must be a positive number or 'none'.");
132-
}
133-
134-
return -1;
135-
}
136-
137-
/**
138-
* Validates the run-id to ensure it is a valid number or 'none'.
139-
* If the input is 'none' or not provided, it returns -1.
140-
* @param {string} runId Input for 'run-id'
141-
* @returns {number} The validated run-id as a number, or -1 if 'none' or invalid
142-
* @throws {Error} If the input is not a valid positive number or 'none'
143-
*/
144-
static validateRunId(runId) {
145-
if (runId && runId.toLowerCase() !== 'none') {
146-
const parsedRunId = Number(runId);
147-
if (!Number.isNaN(parsedRunId) && parsedRunId >= 0) {
148-
return parsedRunId;
149-
}
150-
throw new Error("Invalid input for 'run-id'. Must be a positive number or 'none'.");
151-
}
152-
153-
return -1;
154-
}
155-
156118
/**
157119
* Validates the GitHub token input to ensure it is a valid non-empty string.
158120
* If the input is 'none' or not provided, it returns 'none'.
@@ -170,23 +132,6 @@ class InputValidator {
170132
return 'none';
171133
}
172134

173-
/**
174-
* Validates the repository input to ensure it is a valid non-empty string.
175-
* If the input is 'none' or not provided, it returns 'none'.
176-
* @param {string} repository Input for 'repository'
177-
* @returns {string} Validated repository name, or 'none' if input is 'none' or invalid
178-
* @throws {Error} If the input is not a valid non-empty string
179-
*/
180-
static validateRepository(repository) {
181-
if (repository && repository.toLowerCase() !== 'none') {
182-
if (typeof repository === 'string' && repository.trim().length > 0) {
183-
return repository;
184-
}
185-
throw new Error("Invalid input for 'repository'. Must be a valid string.");
186-
}
187-
return 'none';
188-
}
189-
190135
/**
191136
* Validates the app name input to ensure it is a valid non-empty string.
192137
* If the input is 'none' or not provided, it returns 'none'.

setup-env/test/actionInput/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('Action Input operations for fetching all inputs, triggering validation
1919
sinon.stub(InputValidator, 'updateUsername').returns('validatedUsername');
2020
sinon.stub(InputValidator, 'validateBuildName').returns('validatedBuildName');
2121
sinon.stub(InputValidator, 'validateProjectName').returns('validatedProjectName');
22+
process.env.GITHUB_REPOSITORY = 'browserstack/github-actions';
2223
});
2324

2425
afterEach(() => {

0 commit comments

Comments
 (0)