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

add hook *before:step-functions-offline:start* #313

Merged
merged 9 commits into from Feb 27, 2018

Conversation

Projects
None yet
4 participants
@vkkis93
Copy link
Contributor

vkkis93 commented Jan 25, 2018

What did you implement:

Integration serverless-step-functions-offline with serverless-webpack

How did you implement it:

Just add hook 'before:step-functions-offline:start'

How can we verify it:

Run serverless-step-functions-offline plugin in serverless project where serverless-webpack will be first runned

plugins:
   - serverless-webpack
   ...
   - serverless-step-functions-offline

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Jan 25, 2018

Hey @vkkis93 , nice addition 👍 Will be part of the next release.

Are there any caveats if using step-functions offline together with serverless-offline, or is that not possible?

index.js Outdated
@@ -153,6 +153,9 @@ class ServerlessWebpack {
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:step-functions-offline:start': () => BbPromise.bind(this)
.then(this.validate)
.then(this.compile)

This comment has been minimized.

@HyperBrain

HyperBrain Jan 25, 2018

Member

Watch will automatically watch for source changes. Both functionalities (offline watch and invoke local watch) set the base directory for the execution properly, e.g. for serverless-offline the location parameter is set correctly.

If there is something similar for the step-functions that needs to be done, we had to add a different "watch" or "prepare" function for step (e.g. stepWatch).

This comment has been minimized.

@vkkis93

vkkis93 Jan 25, 2018

Author Contributor

Instead of using .then(this.validate).then(this.compile) need to create separate function for plugin ?

This comment has been minimized.

@HyperBrain

HyperBrain Jan 25, 2018

Member

Only if we want to support watch mode and if step-offline needs to know the compiled directory, then you can do:

.then(this.validate)
.then(this.prepareStepOffline)   <<<--- see here
.then(this.wpwatch)

The new prepareStepOffline function should then do something similar as https://github.com/serverless-heaven/serverless-webpack/blob/master/lib/prepareOfflineInvoke.js, only that it prepares the root folder for the step-offline plugin.

Otherwise the step-offline will just run on the uncompiled code.

This comment has been minimized.

@vkkis93

vkkis93 Jan 25, 2018

Author Contributor

Need only compile code once, run step-offline and stop process.
I don't need to have watch mode
About compiled directory, user will indicate the path to directory by himself in plugin settings.

Referring to my requirements - need to change something or this code makes sense?

This comment has been minimized.

@HyperBrain

HyperBrain Jan 25, 2018

Member

Makes sense with the compile, yes.

However:

About compiled directory, user will indicate the path to directory by himself.

That will not really work out, if you set package: individually. Then the compiled code will then be distributed. I think you need a "prepare" function because for the offline, it has to be set to service packaging (then the output directory is ".webpack/service") like in the prepareOffline.

With individual packaging it is ".webpack/" which is not predictable.

This comment has been minimized.

@HyperBrain

HyperBrain Jan 25, 2018

Member

Can you give me the link to your plugin. Maybe I have some time over the weekend to have a look, if we can combine this in an easy and compatible way there.

This comment has been minimized.

@vkkis93

vkkis93 Jan 25, 2018

Author Contributor

@HyperBrain but looks like your approach very good.
Makes sense to rewrite it.
Only one question, serverless-webpack compiles all functions which described in section functions in serverless.yml ?

This comment has been minimized.

@HyperBrain

This comment has been minimized.

@vkkis93

vkkis93 Jan 25, 2018

Author Contributor

Great,
I update this pull request to Is this ready for review?: NO at this moment.
When I will rewrite code, I will notify you

This comment has been minimized.

@HyperBrain

HyperBrain Jan 25, 2018

Member

Good idea. I'm already excited 😄

vkkis93 added some commits Feb 10, 2018

@vkkis93

This comment has been minimized.

Copy link
Contributor Author

vkkis93 commented Feb 20, 2018

Hi @HyperBrain .
I have changed my code and now PR is ready for review.
The only one problem I see it's coveralls.
Need to write some tests on my new file ?

@HyperBrain
Copy link
Member

HyperBrain left a comment

Hi @vkkis93 , happy to see this done now ;-)

Please add a unit test (similar to the one for serverless-offline prepare) to have the coverage up again.

index.js Outdated
@@ -153,6 +155,10 @@ class ServerlessWebpack {
.then(this.prepareOfflineInvoke)
.then(this.wpwatch),

'before:step-functions-offline:start': () => BbPromise.bind(this)
.then(this.validate)

This comment has been minimized.

@HyperBrain

HyperBrain Feb 21, 2018

Member

You already spawn the webpack:validate in the prepareStepOfflineInvoke function, so you can remove the line here.

This comment has been minimized.

@vkkis93

vkkis93 Feb 21, 2018

Author Contributor

ahh, you're right.
I missed that

@vkkis93

This comment has been minimized.

Copy link
Contributor Author

vkkis93 commented Feb 21, 2018

@HyperBrain can you show the example of unit tests for serverless-offline ?

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Feb 21, 2018

Oops. Just saw that these unit test are also missing.

I will add the prepare unit tests for StepOffline to this PR, so you don't have to take care of them 😄

@vkkis93

This comment has been minimized.

Copy link
Contributor Author

vkkis93 commented Feb 21, 2018

@HyperBrain great news ☺️

@vkkis93

This comment has been minimized.

Copy link
Contributor Author

vkkis93 commented Feb 26, 2018

Hi @HyperBrain .
What should be done in order to close this PR?

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Feb 26, 2018

I'll finish it tomorrow and merge it. Sorry for the delay, was busy over the weekend ;-)

const path = require('path');

/**
* Special settings for use with serverless-offline.

This comment has been minimized.

@j0k3r

j0k3r Feb 26, 2018

This should be step-functions-offline instead of serverless-offline.

This comment has been minimized.

@vkkis93

vkkis93 Feb 27, 2018

Author Contributor

Changed
Should be serverless-step-functions-offline (it's name of plugin)

@j0k3r

j0k3r approved these changes Feb 27, 2018

@vkkis93

This comment has been minimized.

Copy link
Contributor Author

vkkis93 commented Feb 27, 2018

Thanks a lot

@HyperBrain HyperBrain added this to the 4.4.0 milestone Feb 27, 2018

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Feb 27, 2018

The new implementation is now covered 100%. The decrease is because a different unrelated file is not correctly tested. I will merge this PR now and fix the other unit test in a separate PR.
@vkkis93 Thanks again for the PR 👍

@HyperBrain HyperBrain merged commit d38a385 into serverless-heaven:master Feb 27, 2018

2 of 3 checks passed

coverage/coveralls Coverage decreased (-1.3%) to 95.498%
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@j0k3r

This comment has been minimized.

Copy link

j0k3r commented Feb 27, 2018

@vkkis93 Good job!

@stephanschubert

This comment has been minimized.

Copy link

stephanschubert commented Feb 27, 2018

👍 Looking forward to 4.4.0

@HyperBrain

This comment has been minimized.

Copy link
Member

HyperBrain commented Mar 2, 2018

Released with 4.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment