@atomist/sample-sdm
Version:
Sample Atomist automation for software delivery
92 lines • 6.57 kB
JavaScript
"use strict";
/*
* Copyright © 2018 Atomist, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const sdm_1 = require("@atomist/sdm");
const EphemeralProgressLog_1 = require("@atomist/sdm/api-helper/log/EphemeralProgressLog");
const build = require("@atomist/sdm/dsl/buildDsl");
const deploy = require("@atomist/sdm/dsl/deployDsl");
const commonGoals_1 = require("@atomist/sdm/goal/common/commonGoals");
const httpServiceGoals_1 = require("@atomist/sdm/goal/common/httpServiceGoals");
const DisplayDeployEnablement_1 = require("@atomist/sdm/handlers/commands/DisplayDeployEnablement");
const SetDeployEnablement_1 = require("@atomist/sdm/handlers/commands/SetDeployEnablement");
const MavenBuilder_1 = require("@atomist/sdm/internal/delivery/build/local/maven/MavenBuilder");
const ManagedDeployments_1 = require("@atomist/sdm/internal/delivery/deploy/local/ManagedDeployments");
const machineFactory_1 = require("@atomist/sdm/machine/machineFactory");
const jvmPushTests_1 = require("@atomist/sdm/mapping/pushtest/jvm/jvmPushTests");
const nodePushTests_1 = require("@atomist/sdm/mapping/pushtest/node/nodePushTests");
const cloudFoundryManifestPushTest_1 = require("@atomist/sdm/mapping/pushtest/pcf/cloudFoundryManifestPushTest");
const deploymentFreeze_1 = require("@atomist/sdm/pack/freeze/deploymentFreeze");
const InMemoryDeploymentStatusManager_1 = require("@atomist/sdm/pack/freeze/InMemoryDeploymentStatusManager");
const lookFor200OnEndpointRootGet_1 = require("@atomist/sdm/util/verify/lookFor200OnEndpointRootGet");
const localSpringBootDeployers_1 = require("../deploy/localSpringBootDeployers");
const cloudReadiness_1 = require("../pack/cloud-readiness/cloudReadiness");
const demoEditors_1 = require("../pack/demo-editors/demoEditors");
const javaSupport_1 = require("../pack/java/javaSupport");
const nodeSupport_1 = require("../pack/node/nodeSupport");
const cloudFoundryDeploy_1 = require("../pack/pcf/cloudFoundryDeploy");
const cloudFoundrySupport_1 = require("../pack/pcf/cloudFoundrySupport");
const sentrySupport_1 = require("../pack/sentry/sentrySupport");
const springPushTests_1 = require("../pack/spring/pushtest/springPushTests");
const springSupport_1 = require("../pack/spring/springSupport");
const teamPolicies_1 = require("./teamPolicies");
const freezeStore = new InMemoryDeploymentStatusManager_1.InMemoryDeploymentStatusManager();
const IsDeploymentFrozen = deploymentFreeze_1.isDeploymentFrozen(freezeStore);
/**
* Variant of cloudFoundryMachine that uses additive, "contributor" style goal setting.
* @return {SoftwareDeliveryMachine}
*/
function additiveCloudFoundryMachine(configuration) {
const sdm = machineFactory_1.createSoftwareDeliveryMachine({
name: "CloudFoundry software delivery machine",
configuration,
},
// Each contributor contributes goals. The infrastructure assembles them into a goal set.
sdm_1.goalContributors(sdm_1.onAnyPush.setGoals(new sdm_1.Goals("Checks", sdm_1.ReviewGoal, sdm_1.PushReactionGoal)), sdm_1.whenPushSatisfies(IsDeploymentFrozen)
.setGoals(deploymentFreeze_1.ExplainDeploymentFreezeGoal), sdm_1.whenPushSatisfies(sdm_1.any(jvmPushTests_1.IsMaven, nodePushTests_1.IsNode))
.setGoals(sdm_1.JustBuildGoal), sdm_1.whenPushSatisfies(springPushTests_1.HasSpringBootApplicationClass, sdm_1.not(sdm_1.ToDefaultBranch))
.setGoals(sdm_1.LocalDeploymentGoal), sdm_1.whenPushSatisfies(cloudFoundryManifestPushTest_1.HasCloudFoundryManifest, sdm_1.ToDefaultBranch)
.setGoals([sdm_1.ArtifactGoal,
sdm_1.StagingDeploymentGoal,
sdm_1.StagingEndpointGoal,
sdm_1.StagingVerifiedGoal]), sdm_1.whenPushSatisfies(cloudFoundryManifestPushTest_1.HasCloudFoundryManifest, sdm_1.not(IsDeploymentFrozen), sdm_1.ToDefaultBranch)
.setGoals([sdm_1.ArtifactGoal,
sdm_1.ProductionDeploymentGoal,
sdm_1.ProductionEndpointGoal])));
sdm.addExtensionPacks(demoEditors_1.DemoEditors, deploymentFreeze_1.deploymentFreeze(freezeStore), springSupport_1.SpringSupport, sentrySupport_1.SentrySupport, cloudReadiness_1.CloudReadinessChecks, javaSupport_1.JavaSupport, nodeSupport_1.NodeSupport, cloudFoundrySupport_1.CloudFoundrySupport);
sdm.addDeployRules(deploy.when(jvmPushTests_1.IsMaven)
.deployTo(sdm_1.StagingDeploymentGoal, sdm_1.StagingEndpointGoal, commonGoals_1.StagingUndeploymentGoal)
.using({
deployer: localSpringBootDeployers_1.LocalExecutableJarDeployer,
targeter: ManagedDeployments_1.ManagedDeploymentTargeter,
}), deploy.when(jvmPushTests_1.IsMaven)
.deployTo(sdm_1.ProductionDeploymentGoal, sdm_1.ProductionEndpointGoal, sdm_1.ProductionUndeploymentGoal)
.using(cloudFoundryDeploy_1.cloudFoundryProductionDeploySpec(configuration.sdm)));
sdm.addDisposalRules(sdm_1.whenPushSatisfies(jvmPushTests_1.IsMaven, springPushTests_1.HasSpringBootApplicationClass, cloudFoundryManifestPushTest_1.HasCloudFoundryManifest)
.itMeans("Java project to undeploy from PCF")
.setGoals(httpServiceGoals_1.UndeployEverywhereGoals), sdm_1.whenPushSatisfies(sdm_1.AnyPush)
.itMeans("We can always delete the repo")
.setGoals(httpServiceGoals_1.RepositoryDeletionGoals))
.addSupportingCommands(SetDeployEnablement_1.enableDeploy, SetDeployEnablement_1.disableDeploy, DisplayDeployEnablement_1.isDeployEnabledCommand)
.addPushReactions(cloudFoundryDeploy_1.EnableDeployOnCloudFoundryManifestAddition)
.addEndpointVerificationListeners(lookFor200OnEndpointRootGet_1.lookFor200OnEndpointRootGet());
teamPolicies_1.addTeamPolicies(sdm);
// sdm.addExtensionPacks(DemoPolicies);
sdm.addBuildRules(build.setDefault(new MavenBuilder_1.MavenBuilder(configuration.sdm.artifactStore, EphemeralProgressLog_1.createEphemeralProgressLog, configuration.sdm.projectLoader)));
return sdm;
}
exports.additiveCloudFoundryMachine = additiveCloudFoundryMachine;
//# sourceMappingURL=additiveCloudFoundryMachine.js.map