-
Notifications
You must be signed in to change notification settings - Fork 950
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
Strengthen typing of Runtimes+Langauges and their support timelines. #6866
Conversation
inlined
commented
Mar 10, 2024
•
edited
Loading
edited
- Factors out Runtimes into a new file so that they can be imported into firebaseConfig.ts and have a single source of truth and prevent the error encountered in Functions Python version conflict 3.12 and 3.11 #6774 (comment)
- Adds a formal concept of languages and the ability to discriminate runtimes per language
- Makes all information about a runtime table driven so there can never be a runtime without all necessary metadata
- Adds the ability to dynamically fetch the latest runtime for a language
- Adds support timelines for all runtimes
- Unifies runtime support checks across all runtimes/languages. There are now separate warnings for when deprecation is upcoming (90d), when a runtime is deprecated, and when a runtime is decommissioned.
- Factors out Runtimes into a new file so that they can be imported into firebaseConfig.ts and have a single source of truth and prevent the error encountered in #6774 (comment) - Adds a formal concept of languages and the ability to discriminate runtimes per language - Makes all information about a runtime table driven so there can never be a runtime without all necessary metadata - Adds the ability to dynamically fetch the latest runtime for a language - Adds support timelines for all runtimes - Unifies runtime support checks across all runtimes/languages. There are now separate warnings for when deprecation is upcoming (90d), when a runtime is deprecated, and when a runtime is decommissioned.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6866 +/- ##
==========================================
+ Coverage 54.26% 54.27% +0.01%
==========================================
Files 352 353 +1
Lines 24536 24573 +37
Branches 5083 5090 +7
==========================================
+ Hits 13315 13338 +23
- Misses 10007 10022 +15
+ Partials 1214 1213 -1 ☔ View full report in Codecov by Sentry. |
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.
MInor nits, but lgtm!
src/deploy/functions/prepare.ts
Outdated
}; | ||
const firebaseJsonRuntime = codebaseConfig.runtime; | ||
if (firebaseJsonRuntime) { |
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.
Optional - prefer this as a single if statement
if (firebaseJsonRuntime) { | |
if (firebaseJsonRuntime && !supported.isRuntime(firebaseJsonRuntime as string)) { |
|
||
import { FirebaseError } from "../../../../error"; | ||
import * as runtimes from "../../runtimes"; | ||
import * as supported from "../supported"; | ||
|
||
// have to require this because no @types/cjson available | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires |
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.
Optional, unrelated to this PR: Looks like there are types now! https://www.npmjs.com/package/@types/cjson
const runtime = context.runtime ? context.runtime : LATEST_VERSION; | ||
if (!runtimes.isValidRuntime(runtime)) { | ||
throw new FirebaseError(`Runtime ${runtime} is not a valid Python runtime`); | ||
const runtime = context.runtime ? context.runtime : supported.latest("python"); |
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.
Nit: context.runtime ?? supported.latest("python")
is probably cleaner than a ternary
@@ -21,7 +21,7 @@ const BINDING = { | |||
const SPEC = { | |||
region: "us-west1", | |||
project: projectNumber, | |||
runtime: "nodejs14", | |||
runtime: "nodejs14" as const, |
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.
TIL that as const
satisfies enums without having to import them - good to know!
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.
yes, "as const" will make a string literal type rather than just a string type.