Skip to content

Commit

Permalink
feat(gha): staging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
akshit9738 committed Sep 24, 2024
1 parent b914490 commit b537898
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup-env/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ module.exports = {
},

BROWSERSTACK_INTEGRATIONS: {
DETAILS_API_URL: 'https://integrate.browserstack.com/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
DETAILS_API_URL: 'https://integrate.bsstag.com/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
},
};
11 changes: 6 additions & 5 deletions setup-env/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
},

BROWSERSTACK_INTEGRATIONS: {
DETAILS_API_URL: 'https://integrate.browserstack.com/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
DETAILS_API_URL: 'https://integrate.bsstag.com/api/ci-tools/v1/builds/{runId}/rebuild/details?tool=github-actions&as_bot=true',
},
};

Expand Down Expand Up @@ -9597,18 +9597,19 @@ class InputValidator {

/**
* Validates the app name input to ensure it is a valid non-empty string.
* If the input is 'none' or not provided, it returns 'browserstack[bot]'.
* If the input is 'none' or not provided, it returns 'bstack-integrations-staging[bot]'.
* @param {string} githubAppName Input for 'github-app'
* @returns {string} Validated app name, or 'browserstack[bot]' if input is 'none' or invalid
* @returns {string} Validated app name, or 'bstack-integrations-staging[bot]'
* if input is 'none' or invalid
* @throws {Error} If the input is not a valid non-empty string
*/
static validateGithubAppName(githubAppName) {
if (typeof githubAppName !== 'string') {
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
}

if (githubAppName.toLowerCase() === 'browserstack[bot]') {
return 'browserstack[bot]';
if (githubAppName.toLowerCase() === 'bstack-integrations-staging[bot]') {
return 'bstack-integrations-staging[bot]';
}

if (githubAppName.trim().length > 0) {
Expand Down
9 changes: 5 additions & 4 deletions setup-env/src/actionInput/inputValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,19 @@ class InputValidator {

/**
* Validates the app name input to ensure it is a valid non-empty string.
* If the input is 'none' or not provided, it returns 'browserstack[bot]'.
* If the input is 'none' or not provided, it returns 'bstack-integrations-staging[bot]'.
* @param {string} githubAppName Input for 'github-app'
* @returns {string} Validated app name, or 'browserstack[bot]' if input is 'none' or invalid
* @returns {string} Validated app name, or 'bstack-integrations-staging[bot]'
* if input is 'none' or invalid
* @throws {Error} If the input is not a valid non-empty string
*/
static validateGithubAppName(githubAppName) {
if (typeof githubAppName !== 'string') {
throw new Error("Invalid input for 'github-app'. Must be a valid string.");
}

if (githubAppName.toLowerCase() === 'browserstack[bot]') {
return 'browserstack[bot]';
if (githubAppName.toLowerCase() === 'bstack-integrations-staging[bot]') {
return 'bstack-integrations-staging[bot]';
}

if (githubAppName.trim().length > 0) {
Expand Down
8 changes: 4 additions & 4 deletions setup-env/test/actionInput/inputValidator.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ describe('InputValidator class to validate individual fields of the action input
});

context('Validates GitHub App Name', () => {
it("Returns 'browserstack[bot]' if the app name is not provided", () => {
it("Returns 'bstack-integrations-staging[bot]' if the app name is not provided", () => {
expect(() => InputValidator.validateGithubAppName()).to.throw("Invalid input for 'github-app'. Must be a valid string.");
});

it("Returns 'browserstack[bot]' if the app name is 'browserstack[bot]' (case insensitive)", () => {
expect(InputValidator.validateGithubAppName('BrowserStack[BOT]')).to.eq('browserstack[bot]');
it("Returns 'bstack-integrations-staging[bot]' if the app name is 'bstack-integrations-staging[bot]' (case insensitive)", () => {
expect(InputValidator.validateGithubAppName('Bstack-integrations-staging[BOT]')).to.eq('bstack-integrations-staging[bot]');
});

it('Throws an error if the app name is an empty string', () => {
Expand All @@ -170,7 +170,7 @@ describe('InputValidator class to validate individual fields of the action input
expect(() => InputValidator.validateGithubAppName(123)).to.throw("Invalid input for 'github-app'. Must be a valid string.");
});

it('Returns the app name if it is a valid non-empty string and not "browserstack[bot]"', () => {
it('Returns the app name if it is a valid non-empty string and not "bstack-integrations-staging[bot]"', () => {
const validAppName = 'someValidAppName';
expect(InputValidator.validateGithubAppName(validAppName)).to.eq(validAppName);
});
Expand Down

0 comments on commit b537898

Please sign in to comment.