-
Notifications
You must be signed in to change notification settings - Fork 907
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
hosting pre/postdeploy hooks now obey targeting #1842
hosting pre/postdeploy hooks now obey targeting #1842
Conversation
Thanks for the PR! @Memeriaj will have to take a look at this. There also should be an entry added to |
Thank you for jumping in and fixing this. From my own testing this will still run the pre- and post-deploy hooks when running |
Thanks guys, will take a look at the individual functions @Memeriaj, I think something is likely amiss in my testing! |
So I think that the easiest thing would be to short circuit functions specifically. Some like this on line 142 (although I haven't tried this myself quite yet):
|
I was looking into short-circuiting configs without targets this morning: return targetConfigs.filter(function(config) {
return !config.target || _.includes(onlyTargets, config.target);
}); It allows functions hooks to trigger if not targeted, and hosting can do targeted deploys, but my only concern is for hosting, where if However, a nice side effect is it allows users with targeted functions/hosting to specify items without targets as a "global" wrapper for hosting or functions e.g. ...
"functions": [{
"predeploy": [
"echo \"RUNNING PREDEPLOY HOOKS FOR ALL FUNCTIONS\"" // runs *once* for all functions
],
"source": "functions"
},{
"target": "api",
"predeploy": [
"echo \"RUNNING PREDEPLOY HOOKS API FUNCTIONS\"", // runs only for target:api function
"npm --prefix ./functions run lint",
"npm --prefix ./functions run build"
],
"source": "functions"
}], Changing the order/index of the global function also allows it to be run before or after everything else, or even between specific targets if required. The only way I could "break" it was to specify a non-existing target ( Which throws an unknown error that can probably be handled/made clearer by adding some validation to check if targets exist in the config before attempting to deploy them. Additionally, when specifying a non-existing target and config options without @Memeriaj I'm not sure if this is changing intended functionality though, so I'm happy to just short-circuit functions as you suggested if you think that fits better with the overall flow of things 😄 Edit: spelling |
That seems pretty reasonable to me. Give me a little bit of time to reverse engineer any other crazy ways that people might break it (and also ask a couple other knowledgeable people in the office if they have weird usecases). |
Alright I think that your short-circuit is probably the best way of going about it. The only issues with using it that I could come up with are not usecases that we really want to support (I'll get into that further down). So switch over to that and update the chagelog so this will get captured in the release rollup and we should be good to go. (Mainly for folks that happen upon this thread later for whatever reason) Which is basically just a long way of saying that all of the crazy cases that would break your proposed solution are things that people should not be doing. |
Is there anything else that you wanted to add to this? Otherwise I'll go ahead and squash and merge this into the master branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If @Memeriaj is okay with this, so am I 🙂
Hey, no I think we are good, this has been delightful! Cheers chaps. |
Perfect, this should go out in the next release (which will probably be next week at the latest, not completely sure since we usually wait for a couple of things group up). |
Description
Fixes #1160 - pre/postdeploy hooks now obey targeting.
Scenarios Tested
Ran multiple targeted deploys
firebase deploy
)firebase deploy --only hosting
)firebase deploy --only functions
)firebase deploy --only hosting:x,hosting:y
)firebase deploy --only hosting:x,hosting:y,hosting:z
)firebase deploy --only functions:x,functions:y
)firebase deploy --only functions:x,functions,y,functions:z
)