add env variable to specify which downloadable emulator version to use#9960
add env variable to specify which downloadable emulator version to use#9960
Conversation
Summary of ChangesHello @aalej, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Firebase Emulators experience by allowing users to explicitly define which version of a downloadable emulator to use via environment variables. This change provides crucial flexibility, enabling developers to bypass issues with the latest emulator releases without needing to downgrade their entire Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable feature allowing developers to override specific downloadable emulator versions using environment variables. This provides a flexible workaround for potential issues with newer emulator versions. The implementation is well-structured, utilizing a dedicated map for environment variable names and correctly handling the skipChecksumAndSize flag when an override is applied. The addition of a comprehensive test case ensures the new functionality works as expected. Overall, this is a well-executed and beneficial change.
| const replaceVersion = (s: string) => s.split(oldVersion).join(overrideVersion); | ||
|
|
||
| details.version = overrideVersion; | ||
| details.downloadPath = replaceVersion(details.downloadPath); |
There was a problem hiding this comment.
I'd love to have extra error handling for the case where the user sets a version number that doesn't exist in our bucket. Might require some more piping, but ideally, it should print an error message like:
<OVERRIDE_ENV_VAR> set to 99.99.99, but no such version of <emulator name> was found. Please double check the version number, or unset this environment variable to use the latest default.
| const EMULATOR_INSTANCE_KILL_TIMEOUT = 4000; /* ms */ | ||
|
|
||
| const EMULATOR_VERSION_OVERRIDE_ENV_MAP: { [key: string]: string } = { | ||
| database: "FIREBASE_TOOLS_DATABASE_EMULATOR_VERSION", |
There was a problem hiding this comment.
We have a similar concept we use for testing <emulatorName>_EMULATOR_BINARY_PATH - I'd use a similar name here and go with <emulatorName>_EMULATOR_VERSION.
Also, as a nit, we can make this code slightly cleaner as a function like:
function emulatorVersionOverride(emulator: DownloadableEmulators) {
return process.env[`${emulator.toUpperCase()}_EMULATOR_BINARY_PATH`];
}
joehan
left a comment
There was a problem hiding this comment.
This looks 90% of the way there - thanks for making this change!
|
Thanks for reviewing! Changes applied
When user sets an invalid version like |
Description
Adds
FIREBASE_TOOLS_*_EMULATOR_VERSIONwhich can be used to specify which version of the downloadable emulator to use.Developers who encounter issues with the latest version of a downloadable emulator will often need to use an older version of firebase tools. For example:
If version 1.2.3 has a bug, developers would need to downgrade to firebase-tools 15.5.0 to use emulator X version 1.2.0. They will need to use an older version of firebase-tools until the bug in emulator X is fixed. This env config should give a viable workaround by setting
FIREBASE_TOOLS_X_EMULATOR_VERSION=1.2.0Scenarios Tested
The warning message
Env variable override detected. Using custom pubsub emulator version 0.8.17.will only appear on the initial download of the emulator. Succeedingemulators:startwill no longer show this if the same version is used.Sample Commands
Notes
the env variable
FIREBASE_TOOLS_*_EMULATOR_VERSIONmay not be the best env variable name? we can change it to something like*_EMULATOR_VERSIONif preferred, but I'm not sure if this will conflict with some other envs(ones use by other tools)?