Repository navigation
Bring back include configuration for an easier packaging control - #2681
Conversation
f4c5bbf to
a78b3c4
Compare
|
@eahefnawy @flomotlik any update on this one? Can we merge it? |
So that files and directories are considered during exclude / include. Furthermore the test directory structure is updated so that it’s easier to extend and understand.
This makes it possible that everything (even the .serverless dir) can be included again.
5283edc to
f816879
Compare
|
I checked this branch out and had a play with it - the service-level includes/excludes work, but the function-level includes/excludes didn't seem to work; I haven't had a chance to investigate why that is yet. Can you confirm using function-level includes/excludes works for you @pmuens? I'm just trying to work out if it's my setup (all the tests pass for me). |
|
|
||
| # you can add packaging information here | ||
| package: | ||
| # include: |
There was a problem hiding this comment.
Since we are using artifact here I would recommend to remove include/exclude completely. Even if you comment it out it's ignored.
| # exclude: | ||
| # - exclude-me.js | ||
| # - exclude-me-dir/** | ||
| # artifact: my-service-code.zip |
There was a problem hiding this comment.
Since include/exclude is ignored once you start using artifact I recommend to remove it from this example. To me it was so confusing that I needed a call with flo to explain it that it's either this or that.
| # exclude: | ||
| # - exclude-me.py | ||
| # - exclude-me-dir/** | ||
| # artifact: my-service-code.zip |
There was a problem hiding this comment.
Since include/exclude is ignored once you start using artifact I recommend to remove it from this example. To me it was so confusing that I needed a call with flo to explain it that it's either this or that.
|
|
||
| # you can add packaging information here | ||
| package: | ||
| # include: |
There was a problem hiding this comment.
Since we are using artifact here I would recommend to remove include/exclude completely. Even if you comment it out it's ignored.
|
|
||
| # you can add packaging information here | ||
| package: | ||
| # include: |
There was a problem hiding this comment.
Since we are using artifact here I would recommend to remove include/exclude completely. Even if you comment it out it's ignored.
| ## Artifact | ||
|
|
||
| For complete control over the packaging process you can specify your own zip file for your service. Serverless won't zip your service if this is configured so `exclude` will be ignored. | ||
| For complete control over the packaging process you can specify your own zip file for your service. Serverless won't zip your service if this is configured so `exclude` and `include` will be ignored. |
There was a problem hiding this comment.
At first I didn't get this part. I would recommend to make it very explicit that artifact and include/exclude should not be combined. What about:
For complete control over the packaging process you can specify your own artifact zip file. Serverless won't zip your service if this is configured and therefor `exclude` and `include` will be ignored. Either you use artifact or include/exclude.
The artifact option is especially useful in case your development environment allows you to generate a deployable artifact like Maven does for Java.
|
@rowanu i just tried. It works on a function level if you deploy just a function What kind of behaviour did you expect? |
|
|
||
| Then for every function you can use the same `exclude / artifact` config options as you can service wide. The `exclude` option will be merged with the service wide options to create one `exclude` config per function during packaging. | ||
| Then for every function you can use the same `exclude`, `include` or `artifact` config options as you can service wide. The `exclude` and `include` option will be merged with the service wide options to create one `exclude` and `include` config per function during packaging. | ||
|
|
There was a problem hiding this comment.
Not sure if this is a bug or not that a single function deploy will always take package of a function into account.
If this is intended please add something along these lines:
Independently if you enable the package:individually option for your whole service the package option for a function will always be taking into account if you deploy via serverless deploy function --function functionName.
There was a problem hiding this comment.
@flomotlik Just discussed it with @pmuens. We are both not sure if this is a feature or a bug. Leadership needed 🚓 🚨
There was a problem hiding this comment.
if package: individually is enabled it should only use include/exclude of that one function. If its not set it should use the service wide config. If behaviour differs this is a bug, please open an issue in that case.
| }); | ||
|
|
||
| // exclude the whole .serverless directory | ||
| patterns.push('!.serverless/**'); |
There was a problem hiding this comment.
You have .serverless in the defaultExcludes
. Is there a reason why explicitly add it here again? What if someone explicitly want's to add it?There was a problem hiding this comment.
He can re-add id via include as the include globs are pushed at the end of the array after the exclude. But I agree. I think we can remove it! Nice catch!
| expect(getServiceArtifactNameStub.calledOnce).to.be.equal(true); | ||
|
|
||
| expect(zipDirectoryStub.calledOnce).to.be.equal(true); | ||
| expect(zipDirectoryStub.args[0][0]).to.be.equal(servicePath); |
There was a problem hiding this comment.
Instead of matching arguments like this I personally find it way more expressive to use sinon's calledWithExactly
https://github.com/serverless/serverless/blob/master/lib/plugins/aws/deploy/tests/cleanupS3Bucket.js#L207
|
@pmuens This is really really awesome work! The ZipService test are nice and I'm super excited about the whole |
This exclude is already done in the packageService.js file.
|
To your inline comment @nikgraf, I think it's a feature! The problem I was having earlier was because I was missing I also expect packaging to be exactly the same, regardless of if I run |
|
Hey @rowanu thanks for the update about this! 👍 Could not exactly reproduce the case that packaging differs when I run it for a service wide packaging and a per-function packaging. Maybe @nikgraf could open up an issue to describe how this can be reproduced. I think we should fix this in a separate PR as this one targets the |
|
Agreed, all that can be tackled elsewhere. Hope we can get this merged before the next release. |
|
@rowanu Yes, we're about to release this in the next couple of hrs. I just rethought the removal of Or am I missing something? |
|
@pmuens just to talk to your last comment, I was expecting Just a note that these expectations weren't based on reading the docs or anything - it was late when I was testing this and I probably should've just gone to bed! That being said, they still make sense to me now (that is, inferring |
|
I understand. Thanks @rowanu for the clarification! 👍 |
|
The main reason why we didn’t make it automatic was that packaging On 16 November 2016 at 21:47:04, rowan ([email protected]) wrote: @pmuens https://github.com/pmuens just to talk to your last comment, I Just a note that these expectations weren't based on reading the docs or — |
What did you implement:
Closes #2460
Brings back the
includeconfiguration on a per-service and per-function level.How did you implement it:
Added the include configuration and updated the zipping and packaging configuration so that the
includedefinitions (globs) are appended to theexcludearray. This wayglobs.syncwill re-add the files (see https://github.com/jpillora/node-glob-all#usage).How can we verify it:
Create the following directory structure:
With this
serverless.ymlComment out the stuff you want to test and run
serverless deploy --noDeploy. After that inspect the.zipfile.Todos:
Is this ready for review?: YES