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

feat(build): add support for release config to build #1272

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/sfpowerscripts-cli/messages/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"executorCountFlagDescription": "Number of parallel package task schedulors",
"branchFlagDescription": "The git branch that this build is triggered on, Useful for metrics and general identification purposes",
"tagFlagDescription": "Tag the build with a label, useful to identify in metrics",
"logsGroupSymbolFlagDescription": "Symbol used by CICD platform to group/collapse logs in the console. Provide an opening group, and an optional closing group symbol."
"logsGroupSymbolFlagDescription": "Symbol used by CICD platform to group/collapse logs in the console. Provide an opening group, and an optional closing group symbol.",
"releaseConfigFileFlagDescription":"Path to the release config file which determines what packages should be built"
}
3 changes: 2 additions & 1 deletion packages/sfpowerscripts-cli/messages/quickbuild.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"executorCountFlagDescription": "Number of parallel package task schedulors",
"branchFlagDescription": "The git branch that this build is triggered on, Useful for metrics and general identification purposes",
"tagFlagDescription": "Tag the build with a label, useful to identify in metrics",
"logsGroupSymbolFlagDescription": "Symbol used by CICD platform to group/collapse logs in the console. Provide an opening group, and an optional closing group symbol."
"logsGroupSymbolFlagDescription": "Symbol used by CICD platform to group/collapse logs in the console. Provide an opening group, and an optional closing group symbol.",
"releaseConfigFileFlagDescription":"Path to the release config file which determines what packages should be built"
}
41 changes: 38 additions & 3 deletions packages/sfpowerscripts-cli/src/BuildBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import SfpowerscriptsCommand from './SfpowerscriptsCommand';
import { Messages } from '@salesforce/core';
import fs = require('fs');
import SFPStatsSender from '@dxatscale/sfpowerscripts.core/lib/stats/SFPStatsSender';
import BuildImpl from './impl/parallelBuilder/BuildImpl';
import BuildImpl, { BuildProps } from './impl/parallelBuilder/BuildImpl';
import ProjectConfig from '@dxatscale/sfpowerscripts.core/lib/project/ProjectConfig';
import { Stage } from './impl/Stage';
import SFPLogger, {
Expand All @@ -16,9 +16,15 @@ import SFPLogger, {
COLOR_TIME,
COLOR_SUCCESS,
COLOR_KEY_MESSAGE,
Logger,
ConsoleLogger,
LoggerLevel,
COLOR_KEY_VALUE,
} from '@dxatscale/sfp-logger';
import getFormattedTime from '@dxatscale/sfpowerscripts.core/lib/utils/GetFormattedTime';
import SfpPackage from '@dxatscale/sfpowerscripts.core/lib/package/SfpPackage';
import ReleaseConfig from './impl/release/ReleaseConfig';


// Initialize Messages with the current plugin directory
Messages.importMessagesDirectory(__dirname);
Expand Down Expand Up @@ -86,6 +92,9 @@ export default abstract class BuildBase extends SfpowerscriptsCommand {
char: 'g',
description: messages.getMessage('logsGroupSymbolFlagDescription'),
}),
releaseconfig: flags.string({
description: messages.getMessage('releaseConfigFileFlagDescription'),
}),
loglevel: flags.enum({
description: 'logging level for this command invocation',
default: 'info',
Expand Down Expand Up @@ -149,9 +158,15 @@ export default abstract class BuildBase extends SfpowerscriptsCommand {
tags['tag'] = this.flags.tag;
}



SFPStatsSender.logCount('build.scheduled', tags);

buildExecResult = await this.getBuildImplementer().exec();
let buildProps = this.getBuildProps();

//Filter Build Props by ReleaseConfig
buildProps = this.includeOnlyPackagesAsPerReleaseConfig(this.flags.releaseconfig, buildProps, new ConsoleLogger());
buildExecResult = await this.getBuildImplementer(buildProps).exec();

if (
diffcheck &&
Expand Down Expand Up @@ -258,9 +273,29 @@ export default abstract class BuildBase extends SfpowerscriptsCommand {
}
}

private includeOnlyPackagesAsPerReleaseConfig(releaseConfigFilePath:string,buildProps: BuildProps,logger?:Logger): BuildProps {
if (releaseConfigFilePath) {
let releaseConfig:ReleaseConfig = new ReleaseConfig(logger, releaseConfigFilePath);
buildProps.includeOnlyPackages = releaseConfig.getPackagesAsPerReleaseConfig();
printIncludeOnlyPackages(buildProps.includeOnlyPackages);
}
return buildProps;


function printIncludeOnlyPackages(includeOnlyPackages: string[]) {
SFPLogger.log(
COLOR_KEY_MESSAGE(`Build will include the below packages as per inclusive filter`),
LoggerLevel.INFO
);
SFPLogger.log(COLOR_KEY_VALUE(`${includeOnlyPackages.toString()}`), LoggerLevel.INFO);
}
}

abstract getBuildProps(): BuildProps;

abstract getStage(): Stage;

abstract getBuildImplementer(): BuildImpl;
abstract getBuildImplementer(buildProps:BuildProps): BuildImpl;
}

interface BuildResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class Build extends BuildBase {
return Stage.BUILD;
}

getBuildImplementer(): BuildImpl {
getBuildProps(): BuildProps {
let buildProps: BuildProps = {
configFilePath: this.flags.configfilepath,
devhubAlias: this.flags.devhubalias,
Expand All @@ -31,11 +31,14 @@ export default class Build extends BuildBase {
currentStage: Stage.BUILD,
isBuildAllAsSourcePackages: false,
diffOptions: {
useLatestGitTags:true,
skipPackageDescriptorChange:false
}
useLatestGitTags: true,
skipPackageDescriptorChange: false,
},
};
return buildProps;
}

getBuildImplementer(buildProps: BuildProps): BuildImpl {
let buildImpl = new BuildImpl(buildProps);
return buildImpl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class QuickBuild extends BuildBase {
return Stage.QUICKBUILD;
}

getBuildImplementer(): BuildImpl {
getBuildProps(): BuildProps {
let buildProps: BuildProps = {
configFilePath: this.flags.configfilepath,
devhubAlias: this.flags.devhubalias,
Expand All @@ -31,11 +31,13 @@ export default class QuickBuild extends BuildBase {
currentStage: Stage.QUICKBUILD,
isBuildAllAsSourcePackages: false,
diffOptions: {
useLatestGitTags:true,
skipPackageDescriptorChange:false
}
useLatestGitTags: true,
skipPackageDescriptorChange: false,
},
};

return buildProps;
}
getBuildImplementer(buildProps: BuildProps): BuildImpl {
let buildImpl = new BuildImpl(buildProps);
return buildImpl;
}
Expand Down