Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

O11Y QA PR Base #642

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion bin/helpers/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,11 @@ exports.getBuildDetails = (bsConfig, isO11y = false) => {
exports.setBrowserstackCypressCliDependency = (bsConfig) => {
const runSettings = bsConfig.run_settings;
if (runSettings.npm_dependencies !== undefined &&
Object.keys(runSettings.npm_dependencies).length !== 0 &&
typeof runSettings.npm_dependencies === 'object') {
if (!("browserstack-cypress-cli" in runSettings.npm_dependencies)) {
logger.warn("Missing browserstack-cypress-cli not found in npm_dependencies");
runSettings.npm_dependencies['browserstack-cypress-cli'] = this.getAgentVersion() || "latest";
runSettings.npm_dependencies['browserstack-cypress-cli'] = path.resolve(__dirname, '..', '..', '..', 'browserstack-cypress-cli', `browserstack-cypress-cli-${exports.getAgentVersion()}.tgz`);
logger.warn(`Adding browserstack-cypress-cli version ${runSettings.npm_dependencies['browserstack-cypress-cli']} in npm_dependencies`);
}
}
Expand Down
9 changes: 8 additions & 1 deletion bin/helpers/packageInstaller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
utils = require('./utils'),
{ get_version } = require('./usageReporting'),
process = require('process'),
{ spawn } = require('child_process'),
{ spawn, execSync } = require('child_process'),
util = require('util');

let nodeProcess;
Expand Down Expand Up @@ -80,6 +80,13 @@ const packageInstall = (packageDir) => {
const npm_major_version = utils.getMajorVersion(npm_version);
logger.debug(`Fetched npm version: ${npm_version} and its major version: ${npm_major_version}`);

try {
logger.info(`Running npm pack command : ${path.resolve(__dirname, '..', '..', '..', 'browserstack-cypress-cli')}`);
execSync(`${/^win/.test(process.platform) ? 'npm.cmd' : 'npm'} pack`, {cwd: path.resolve(__dirname, '..', '..', '..', 'browserstack-cypress-cli')}, function(err, stdout, stderr) {});
} catch(e) {
logger.info(`Error running npm pack command`);
}

// add --legacy-peer-deps flag while installing dependencies for npm v7+
// For more info please read "Peer Dependencies" section here -> https://github.blog/2021-02-02-npm-7-is-now-generally-available/
if (parseInt(npm_major_version) >= 7) {
Expand Down
34 changes: 34 additions & 0 deletions bin/testObservability/helper/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,40 @@ exports.setEventListeners = (bsConfig) => {
}
}

const getBuildDetails = (bsConfig) => {
const isTestObservabilityOptionsPresent = !utils.isUndefined(bsConfig["testObservabilityOptions"]);
let buildName = '',
projectName = '',
buildDescription = '',
buildTags = [];

/* Pick from environment variables */
buildName = process.env.BROWSERSTACK_BUILD_NAME || buildName;
projectName = process.env.BROWSERSTACK_PROJECT_NAME || projectName;

/* Pick from testObservabilityOptions */
if(isTestObservabilityOptionsPresent) {
buildName = buildName || bsConfig["testObservabilityOptions"]["buildName"];
projectName = projectName || bsConfig["testObservabilityOptions"]["projectName"];
if(!utils.isUndefined(bsConfig["testObservabilityOptions"]["buildTag"])) buildTags = [...buildTags, ...bsConfig["testObservabilityOptions"]["buildTag"]];
buildDescription = buildDescription || bsConfig["testObservabilityOptions"]["buildDescription"];
}

/* Pick from run settings */
buildName = buildName || bsConfig["run_settings"]["build_name"];
projectName = projectName || bsConfig["run_settings"]["project_name"];
if(!utils.isUndefined(bsConfig["run_settings"]["build_tag"])) buildTags = [...buildTags, bsConfig["run_settings"]["build_tag"]];

buildName = buildName || path.basename(path.resolve(process.cwd()));

return {
buildName,
projectName,
buildDescription,
buildTags
};
}

const getCypressConfigFileContent = (bsConfig, cypressConfigPath) => {
try {
const cypressConfigFile = require(path.resolve(bsConfig ? bsConfig.run_settings.cypress_config_file : cypressConfigPath));
Expand Down
Loading