Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Commit

Permalink
Fail creation of unlocked package when test coverage is below 75% (#457)
Browse files Browse the repository at this point in the history
* Fix Incorrectly reported metrics

* Fail Create unlocked Package command when the coverage is low

* Change condition to isCoverageEnabled
  • Loading branch information
azlam-abdulsalam authored Mar 22, 2021
1 parent c7bd65a commit f24d321
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ export default class CreateUnlockedPackageImpl {
if(packageTypeInfo==null)
{
SFPLogger.log("Unable to find a package info for this particular package, Are you sure you created this package?");
SFPLogger.log("Unable to find a package info for this particular package, Are you sure you created this package?");

}


Expand Down Expand Up @@ -165,6 +163,13 @@ export default class CreateUnlockedPackageImpl {
//Get the full details on the package
await this.getPackageInfo();


//Break if coverage is low
if (this.isCoverageEnabled) {
if(!this.packageArtifactMetadata.has_passed_coverage_check)
throw new Error("This package has not meet the minimum coverage requirement of 75%");
}

//Generate Source Artifact
let mdapiPackageArtifactDir = SourcePackageGenerator.generateSourcePackageArtifact(
this.project_directory,
Expand Down Expand Up @@ -333,7 +338,7 @@ export default class CreateUnlockedPackageImpl {
}

private buildExecCommand(): string {
let command = `npx sfdx force:package:version:create -p ${this.sfdx_package} -w ${this.wait_time} --definitionfile ${this.config_file_path} --json`;
let command = `sfdx force:package:version:create -p ${this.sfdx_package} -w ${this.wait_time} --definitionfile ${this.config_file_path} --json`;

if (!isNullOrUndefined(this.version_number))
command += ` --versionnumber ${this.version_number}`;
Expand Down
6 changes: 5 additions & 1 deletion packages/sfpowerscripts-cli/src/BuildBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export default abstract class BuildBase extends SfpowerscriptsCommand {

let executionStartTime = Date.now();



buildExecResult = await this.getBuildImplementer().exec();

if (
Expand Down Expand Up @@ -137,7 +139,9 @@ export default abstract class BuildBase extends SfpowerscriptsCommand {
tags["tag"] = this.flags.tag;
}

console.log("Sending Metrics if enabled..", tags);
SFPStatsSender.logCount("build.scheduled", tags);


SFPStatsSender.logGauge(
"build.duration",
Date.now() - executionStartTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,34 +147,23 @@ export default class Deploy extends SfpowerscriptsCommand {
if (this.flags.logsgroupsymbol?.[1])
console.log(this.flags.logsgroupsymbol[1]);

SFPStatsSender.logCount("deploy.scheduled",tags);

SFPStatsSender.logGauge(
"deploy.duration",
totalElapsedTime,
tags
);

SFPStatsSender.logCount(
"deploy.succeeded",
tags
);

SFPStatsSender.logGauge(
"deploy.succeeded.packages",
deploymentResult.deployed.length,
tags
);



if (deploymentResult.failed.length > 0) {
SFPStatsSender.logCount(
"deploy.failed",
tags
);

SFPStatsSender.logGauge(
"deploy.failed.packages",
deploymentResult.failed.length,
}
else
{
SFPStatsSender.logCount(
"deploy.succeeded",
tags
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/sfpowerscripts-cli/src/impl/deploy/DeployImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class DeployImpl {
this.checkIfPackagesPromoted(queue, packagesToPackageInfo);
}

SFPStatsSender.logCount("deploy.scheduled",this.props.tags);

SFPStatsSender.logGauge(
"deploy.scheduled.packages",
queue.length,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ export default class BuildImpl {
this.props.projectDirectory
);

SFPStatsSender.logCount("build.scheduled", {
isDiffCheckEnabled: this.props.isDiffCheckEnabled ? "true" : "false",
prMode: this.props.isBuildAllAsSourcePackages ? "true" : "false",
});

//Do a diff Impl
if (this.props.isDiffCheckEnabled) {
Expand Down

0 comments on commit f24d321

Please sign in to comment.