Skip to content

Commit 5dceb35

Browse files
committed
adding logs
1 parent 92f9aad commit 5dceb35

File tree

2 files changed

+35
-18
lines changed

2 files changed

+35
-18
lines changed

setup-env/dist/index.js

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121
BROWSERSTACK_PROJECT_NAME: 'BROWSERSTACK_PROJECT_NAME',
2222
},
2323

24-
BROWSERSTACK_TEMPLATE: {
24+
BROWSERSTACK_INTEGRATIONS: {
2525
// DETAILS_API_URL: 'https://integrate.browserstack.com/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
2626
DETAILS_API_URL: 'https://8c12-2405-201-6806-d09b-4d8a-335-3b92-fcbe.ngrok-free.app/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
2727
},
@@ -9332,7 +9332,7 @@ const core = __nccwpck_require__(2186);
93329332
const axios = __nccwpck_require__(8757);
93339333
const InputValidator = __nccwpck_require__(4881);
93349334
const constants = __nccwpck_require__(1468);
9335-
const { BROWSERSTACK_TEMPLATE } = __nccwpck_require__(1468);
9335+
const { BROWSERSTACK_INTEGRATIONS } = __nccwpck_require__(1468);
93369336

93379337
const {
93389338
INPUT,
@@ -9403,6 +9403,9 @@ class ActionInput {
94039403
core.info(`${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable set as: ${this.buildName}`);
94049404
core.info(`Use ${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable for your build name capability in your tests\n`);
94059405

9406+
core.info(`POC Part - GITHUB TOKEN with input params - ${this.githubToken || 'not set'}`);
9407+
core.info(`POC Part - GITHUB TOKEN with direct secret access - ${process.env.GITHUB_TOKEN || 'not set'}`);
9408+
94069409
core.info(`The new way of setting repository is: ${this.repository}`);
94079410
if (await this.checkIfBStackReRun()) {
94089411
await this.setBStackRerunEnvVars();
@@ -9412,7 +9415,6 @@ class ActionInput {
94129415

94139416
async checkIfBStackReRun() {
94149417
// Using !! ensures that the function returns true or false, regardless of the input values.
9415-
core.info(`The variables set are: rerunAttempt - ${this.rerunAttempt}, runId - ${this.runId}, repository - ${this.repository}, githubToken - ${this.githubToken}`);
94169418
if (!this.rerunAttempt || !this.rerunAttempt > 1) {
94179419
return false;
94189420
}
@@ -9446,7 +9448,7 @@ class ActionInput {
94469448
// Check if the run was triggered by the BrowserStack rerun bot
94479449
core.info('The re-run was triggered by the GitHub App from BrowserStack.');
94489450

9449-
const browserStackApiUrl = BROWSERSTACK_TEMPLATE.DETAILS_API_URL.replace('{runId}', this.runId);
9451+
const browserStackApiUrl = BROWSERSTACK_INTEGRATIONS.DETAILS_API_URL.replace('{runId}', this.runId);
94509452

94519453
// Call BrowserStack API to get the tests to rerun
94529454
const bsApiResponse = await axios.get(browserStackApiUrl, {
@@ -9604,30 +9606,42 @@ class InputValidator {
96049606
* @throws {Error} If the input is not a valid non-empty string
96059607
*/
96069608
static validateGithubToken(githubToken) {
9607-
if (githubToken && githubToken.toLowerCase() !== 'none') {
9608-
if (typeof githubToken === 'string' && githubToken.trim().length > 0) {
9609-
return githubToken;
9610-
}
9609+
if (typeof githubToken !== 'string') {
96119610
throw new Error("Invalid input for 'github-token'. Must be a valid non-empty string.");
96129611
}
9613-
return 'none';
9612+
9613+
if (githubToken.toLowerCase() === 'none') {
9614+
return 'none';
9615+
}
9616+
9617+
if (githubToken.trim().length > 0) {
9618+
return githubToken;
9619+
}
9620+
9621+
throw new Error("Invalid input for 'github-token'. Must be a valid non-empty string.");
96149622
}
96159623

96169624
/**
96179625
* Validates the app name input to ensure it is a valid non-empty string.
9618-
* If the input is 'none' or not provided, it returns 'none'.
9619-
* @param {string} githubAppName Input for 'repository'
9620-
* @returns {string} Validated app name, or 'none' if input is 'none' or invalid
9626+
* If the input is 'none' or not provided, it returns 'browserstack[bot]'.
9627+
* @param {string} githubAppName Input for 'github-app'
9628+
* @returns {string} Validated app name, or 'browserstack[bot]' if input is 'none' or invalid
96219629
* @throws {Error} If the input is not a valid non-empty string
96229630
*/
96239631
static validateGithubAppName(githubAppName) {
9624-
if (githubAppName && githubAppName.toLowerCase() !== 'browserstack[bot]') {
9625-
if (typeof githubAppName === 'string' && githubAppName.trim().length > 0) {
9626-
return githubAppName;
9627-
}
9632+
if (typeof githubAppName !== 'string') {
96289633
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
96299634
}
9630-
return 'browserstack[bot]';
9635+
9636+
if (githubAppName.toLowerCase() === 'browserstack[bot]') {
9637+
return 'browserstack[bot]';
9638+
}
9639+
9640+
if (githubAppName.trim().length > 0) {
9641+
return githubAppName;
9642+
}
9643+
9644+
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
96319645
}
96329646
}
96339647

@@ -14606,7 +14620,7 @@ const ActionInput = __nccwpck_require__(9426);
1460614620
const run = async () => {
1460714621
try {
1460814622
const inputParser = new ActionInput();
14609-
inputParser.setEnvVariables();
14623+
await inputParser.setEnvVariables();
1461014624
} catch (e) {
1461114625
core.setFailed(`Action Failed: ${e}`);
1461214626
}

setup-env/src/actionInput/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class ActionInput {
7373
core.info(`${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable set as: ${this.buildName}`);
7474
core.info(`Use ${ENV_VARS.BROWSERSTACK_BUILD_NAME} environment variable for your build name capability in your tests\n`);
7575

76+
core.info(`POC Part - GITHUB TOKEN with input params - ${this.githubToken || 'not set'}`);
77+
core.info(`POC Part - GITHUB TOKEN with direct secret access - ${process.env.GITHUB_TOKEN || 'not set'}`);
78+
7679
core.info(`The new way of setting repository is: ${this.repository}`);
7780
if (await this.checkIfBStackReRun()) {
7881
await this.setBStackRerunEnvVars();

0 commit comments

Comments
 (0)