Skip to content

Strengthen typing of Runtimes+Langauges and their support timelines.#6866

Merged
inlined merged 11 commits intomasterfrom
inlined.runtime-deprecations
Mar 27, 2024
Merged

Strengthen typing of Runtimes+Langauges and their support timelines.#6866
inlined merged 11 commits intomasterfrom
inlined.runtime-deprecations

Conversation

@inlined
Copy link
Copy Markdown
Member

@inlined inlined commented Mar 10, 2024

  • 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.
inlined added 2 commits March 10, 2024 15:58
- 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-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 10, 2024

Codecov Report

Attention: Patch coverage is 64.42308% with 37 lines in your changes are missing coverage. Please review.

Project coverage is 54.27%. Comparing base (27088cd) to head (bca4ff7).

Files Patch % Lines
src/deploy/functions/prepare.ts 11.11% 8 Missing ⚠️
src/deploy/functions/runtimes/python/index.ts 45.45% 6 Missing ⚠️
src/deploy/functions/runtimes/supported.ts 86.48% 2 Missing and 3 partials ⚠️
src/emulator/controller.ts 16.66% 5 Missing ⚠️
src/deploy/functions/runtimes/index.ts 20.00% 4 Missing ⚠️
src/gcp/cloudfunctions.ts 25.00% 1 Missing and 2 partials ⚠️
src/emulator/functionsEmulator.ts 0.00% 2 Missing ⚠️
src/gcp/cloudfunctionsv2.ts 33.33% 0 Missing and 2 partials ⚠️
src/deploy/functions/runtimes/node/index.ts 80.00% 1 Missing ⚠️
src/functional.ts 50.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Member

@joehan joehan left a 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!

runtime: codebaseConfig.runtime || "",
};
const firebaseJsonRuntime = codebaseConfig.runtime;
if (firebaseJsonRuntime) {
Copy link
Copy Markdown
Member

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

Suggested change
if (firebaseJsonRuntime) {
if (firebaseJsonRuntime && !supported.isRuntime(firebaseJsonRuntime as string)) {
import * as supported from "../supported";

// have to require this because no @types/cjson available
// eslint-disable-next-line @typescript-eslint/no-var-requires
Copy link
Copy Markdown
Member

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");
Copy link
Copy Markdown
Member

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

region: "us-west1",
project: projectNumber,
runtime: "nodejs14",
runtime: "nodejs14" as const,
Copy link
Copy Markdown
Member

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!

Copy link
Copy Markdown
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants