Repository navigation
fix(AWS Deploy): Ensure that we only read/hash local artifact files exactly once when checking for changes. - #8351
Conversation
…cking for changes.
Codecov Report
@@ Coverage Diff @@
## master #8351 +/- ##
=======================================
Coverage 88.01% 88.02%
=======================================
Files 249 249
Lines 9307 9278 -29
=======================================
- Hits 8192 8167 -25
+ Misses 1115 1111 -4
Continue to review full report at Codecov.
|
medikoo
left a comment
There was a problem hiding this comment.
@ryan-roemer thanks for that! Fix looks good to me. I have posted just one suggestion towards testing, as we move away from the way tests were written in older times.
|
@ryan-roemer from what I inspect the test behavior is right. Note that when you create a service as in fixture, and run Maybe after all Framework doesn't support artifacts prepared in |
|
@medikoo -- So the full lifecycle is that that I'm going to try just adding |
|
@ryan-roemer And here it appears that placing artifacts in a I'd remove here |
|
It's also what uncovered the existing bug in servlerless code about globbing .serverless. Ultimately, I don't care what test I need to write, or if any test at all -- can you advise on how you'd test this one line change in PR? |
|
Update -- I now have a simple, custom plugin like other plugins in fixtures to write to S3: {
// **Note**: We need`headObject` here to return different HEAD values for
// - compiled-cloudformation-template.json
// - my-own.zip
headObject: {
Metadata: { filesha256: 'NEEDS_TO_BE_DIFFERENT_FOR_SUBSEQUENT_CALLS' }
},
listObjectsV2: {
Contents: [
{
Key:
'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/compiled-cloudformation-template.json',
LastModified: new Date(),
ETag: '"5102a4cf710cae6497dba9e61b85d0a4"',
Size: 356,
StorageClass: 'STANDARD',
},
{
Key:
'serverless/test-package-artifact/dev/1589988704359-2020-05-20T15:31:44.359Z/my-own.zip',
LastModified: new Date(),
ETag: '"5102a4cf710cae6497dba9e61b85d0a4"',
Size: 356,
StorageClass: 'STANDARD',
},
],
},
},Any ideas? I'm trying to come up with something, but I'm in a very awkward place now as the return sinon.stub(provider, 'request').callsFake(
(service, method) =>
new Promise((resolve, reject) => {
if (!config[service] || !config[service][method]) {
reject(new Error(`Missing AWS request stub configuration for ${service}.${method}`));
return;
}
// REPLACE
// resolve(config[service][method]);
// WITH...
const meth = config[service][method];
resolve(typeof meth === 'function' ? meth() : meth);
})
);which would then allow me to do: return runServerless({
// ...
S3: {
headObject: sandbox.stub()
.onCall(0).returns({
Metadata: { filesha256: 'FIRST_VALUE' }
})
.onCall(1).returns({
Metadata: { filesha256: 'SECOND_VALUE' }
}),
// ...and give me different values. Unfortunately, that would mean that I'm now depending on yet another upstream PR to close a one line bug here 😢 But, my original bigger fix for not requiring AWS authentication for (My WIP new test + fixtures is pushed up to: master...FormidableLabs:bug-zip-hash-check-new-tests) |
|
To make the above change |
|
OK, assuming I can get https://github.com/serverless/test/pull/54 merged and released, then I'll update |
|
@ryan-roemer I didn't clearly realize that we deal here with a non natural Anyway it's impressive you've prepared a valid test case for this scenario. I've just reviewed serverless/test#54 |
|
@medikoo -- I've merged in my branch of branch and assuming everything passes CI I think we're all ready to go! I didn't squash my commits, but please do let me know if you'd like me to rebase and force push. Thanks for all your guidance along the way! |
medikoo
left a comment
There was a problem hiding this comment.
That test case is really special. Thank you!
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8351 +/- ##
=======================================
Coverage 88.01% 88.02%
=======================================
Files 249 249
Lines 9307 9278 -29
=======================================
- Hits 8192 8167 -25
+ Misses 1115 1111 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
As plugins/out-of-band processes can place artifacts in
.serverless/NAME.zip, ensure that we only read unique file paths once when generating hashes incheckForChanges.jsto decide whether or not to deploy.Closes: #8350