Skip to content
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
28 changes: 6 additions & 22 deletions deploy/googleDeploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ const BbPromise = require('bluebird');
const validate = require('../shared/validate');
const utils = require('../shared/utils');
const setDeploymentBucketName = require('../shared/setDeploymentBucketName');
const prepareDeployment = require('./lib/prepareDeployment');
const createDeployment = require('./lib/createDeployment');
const monitorDeployment = require('../shared/monitorDeployment');
const generateArtifactDirectoryName = require('./lib/generateArtifactDirectoryName');
const compileFunctions = require('./lib/compileFunctions');
const mergeServiceResources = require('./lib/mergeServiceResources');
const uploadArtifacts = require('./lib/uploadArtifacts');
const updateDeployment = require('./lib/updateDeployment');
const cleanupDeploymentBucket = require('./lib/cleanupDeploymentBucket');
Expand All @@ -26,36 +22,24 @@ class GoogleDeploy {
validate,
utils,
setDeploymentBucketName,
prepareDeployment,
createDeployment,
monitorDeployment,
generateArtifactDirectoryName,
compileFunctions,
mergeServiceResources,
uploadArtifacts,
updateDeployment,
cleanupDeploymentBucket);

this.hooks = {
'before:deploy:initialize': () => BbPromise.bind(this)
'before:deploy:deploy': () => BbPromise.bind(this)
.then(this.validate)
.then(this.setDefaults),

'deploy:initialize': () => BbPromise.bind(this)
.then(this.setDeploymentBucketName)
.then(this.prepareDeployment),

'deploy:setupProviderConfiguration': () => BbPromise.bind(this)
.then(this.createDeployment),

'before:deploy:compileFunctions': () => BbPromise.bind(this)
.then(this.generateArtifactDirectoryName)
.then(this.compileFunctions),

'deploy:deploy': () => BbPromise.bind(this)
.then(this.mergeServiceResources)
.then(this.setDeploymentBucketName)
.then(this.createDeployment)
.then(this.uploadArtifacts)
.then(this.updateDeployment)
.then(this.updateDeployment),

'after:deploy:deploy': () => BbPromise.bind(this)
.then(this.cleanupDeploymentBucket),
};
}
Expand Down
50 changes: 10 additions & 40 deletions deploy/googleDeploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ describe('GoogleDeploy', () => {
let validateStub;
let setDefaultsStub;
let setDeploymentBucketNameStub;
let prepareDeploymentStub;
let createDeploymentStub;
let generateArtifactDirectoryNameStub;
let compileFunctionsStub;
let mergeServiceResourcesStub;
let uploadArtifactsStub;
let updateDeploymentStub;
let cleanupDeploymentBucketStub;
Expand All @@ -55,17 +51,8 @@ describe('GoogleDeploy', () => {
.returns(BbPromise.resolve());
setDeploymentBucketNameStub = sinon.stub(googleDeploy, 'setDeploymentBucketName')
.returns(BbPromise.resolve());
prepareDeploymentStub = sinon.stub(googleDeploy, 'prepareDeployment')
.returns(BbPromise.resolve());
createDeploymentStub = sinon.stub(googleDeploy, 'createDeployment')
.returns(BbPromise.resolve());
generateArtifactDirectoryNameStub = sinon
.stub(googleDeploy, 'generateArtifactDirectoryName')
.returns(BbPromise.resolve());
compileFunctionsStub = sinon.stub(googleDeploy, 'compileFunctions')
.returns(BbPromise.resolve());
mergeServiceResourcesStub = sinon.stub(googleDeploy, 'mergeServiceResources')
.returns(BbPromise.resolve());
uploadArtifactsStub = sinon.stub(googleDeploy, 'uploadArtifacts')
.returns(BbPromise.resolve());
updateDeploymentStub = sinon.stub(googleDeploy, 'updateDeployment')
Expand All @@ -78,46 +65,29 @@ describe('GoogleDeploy', () => {
googleDeploy.validate.restore();
googleDeploy.setDefaults.restore();
googleDeploy.setDeploymentBucketName.restore();
googleDeploy.prepareDeployment.restore();
googleDeploy.createDeployment.restore();
googleDeploy.generateArtifactDirectoryName.restore();
googleDeploy.compileFunctions.restore();
googleDeploy.mergeServiceResources.restore();
googleDeploy.uploadArtifacts.restore();
googleDeploy.updateDeployment.restore();
googleDeploy.cleanupDeploymentBucket.restore();
});

it('should run "before:deploy:initialize" promise chain', () => googleDeploy
.hooks['before:deploy:initialize']().then(() => {
it('should run "before:deploy:deploy" promise chain', () => googleDeploy
.hooks['before:deploy:deploy']().then(() => {
expect(validateStub.calledOnce).toEqual(true);
expect(setDefaultsStub.calledAfter(validateStub)).toEqual(true);
}));

it('should run "deploy:initialize" promise chain', () => googleDeploy
.hooks['deploy:initialize']().then(() => {
expect(setDeploymentBucketNameStub.calledOnce).toEqual(true);
expect(prepareDeploymentStub.calledAfter(setDeploymentBucketNameStub)).toEqual(true);
}));

it('it should run "deploy:setupProviderConfiguration" promise chain', () => googleDeploy
.hooks['deploy:setupProviderConfiguration']().then(() => {
expect(createDeploymentStub.calledOnce).toEqual(true);
}),
);

it('should run "before:deploy:compileFunctions" promise chain', () => googleDeploy
.hooks['before:deploy:compileFunctions']().then(() => {
expect(generateArtifactDirectoryNameStub.calledOnce).toEqual(true);
expect(compileFunctionsStub.calledAfter(generateArtifactDirectoryNameStub)).toEqual(true);
}));

it('should run "deploy:deploy" promise chain', () => googleDeploy
.hooks['deploy:deploy']().then(() => {
expect(mergeServiceResourcesStub.calledOnce).toEqual(true);
expect(uploadArtifactsStub.calledAfter(mergeServiceResourcesStub)).toEqual(true);
expect(setDeploymentBucketNameStub.calledOnce).toEqual(true);
expect(createDeploymentStub.calledAfter(setDeploymentBucketNameStub)).toEqual(true);
expect(uploadArtifactsStub.calledAfter(createDeploymentStub)).toEqual(true);
expect(updateDeploymentStub.calledAfter(uploadArtifactsStub)).toEqual(true);
expect(cleanupDeploymentBucketStub.calledAfter(updateDeploymentStub)).toEqual(true);
}));

it('should run "after:deploy:deploy" promise chain', () => googleDeploy
.hooks['after:deploy:deploy']().then(() => {
expect(cleanupDeploymentBucketStub.calledOnce).toEqual(true);
}));
});
});
Expand Down
120 changes: 0 additions & 120 deletions deploy/lib/compileFunctions.js

This file was deleted.

Loading