Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request fixes an issue where firebase deploy incorrectly skips functions as unchanged when only their runtime configuration is modified in firebase.json. It introduces a runtimeChanged helper function to detect runtime mismatches and updates both the deployment skipping logic and the release planner to prevent skipping these functions. Unit tests have been added to verify this behavior. Feedback on the PR suggests updating the runtimeChanged function to use explicit strict null checks for undefined instead of implicit falsy checks with !!, in accordance with the repository's style guide.
IzaakGough
left a comment
There was a problem hiding this comment.
@Ultranmus Thanks for the contribution! This looks good generally, I've left a few comments.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11599 +/- ##
=======================================
Coverage ? 61.34%
=======================================
Files ? 870
Lines ? 51060
Branches ? 10301
=======================================
Hits ? 31322
Misses ? 18598
Partials ? 1140 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Without a runtime in firebase.json, Python and Dart default to the latest supported version, so comparing runtimes would redeploy (and re-upload) every unchanged function after a CLI release moves that default. - backend.isUnchanged() holds the skip condition (ACTIVE, matching hash, and the runtime when compareRuntime is set), used by both shouldUploadBeSkipped and calculateChangesets - release and deploy set compareRuntime from firebase.json through projectConfig.hasConfiguredRuntime() - tests for a defaulted runtime that changed, and for an unknown deployed runtime in shouldUploadBeSkipped
|
@IzaakGough thanks for the review and for trying it on a real project. I pushed 4648eae with all four changes:
|
Covers the call site in deploy(): an unchanged function whose defaulted runtime moved is not uploaded, and one whose runtime set in firebase.json changed is.
Description
Fixes #11597.
firebase deploy --only functionsskips a function when its hash matches the deployed one. The hash (getEndpointHashinsrc/deploy/functions/cache/hash.ts) covers the source archive, env vars and secret versions, but not the runtime.runtimeset infirebase.jsonis not part of the source archive, so changing only the runtime (for examplenodejs22tonodejs24, orpython311topython313) leaves the hash unchanged, and the function is reported asSkipped (No changes detected)while it keeps running on the old runtime.This adds
backend.runtimeChanged(want, have), which is true when both endpoints have a runtime and they differ. It is checked in:calculateChangesets(release/planner.ts), so the function is updated instead of skippedshouldUploadBeSkipped(deploy.ts), so the source is uploaded for the updateI kept the hash itself unchanged on purpose. Adding the runtime to the hash would change every function's hash, so every project would redeploy all of its functions once after upgrading the CLI. The deployed runtime is already read from
buildConfig.runtime(gcfv2) andruntime(gcfv1). When it is missing, for example for a deprecated runtime, the existing skip behavior is kept, so this does not cause extra deploys.Scenarios Tested
release/planner.spec.ts: a function with a matching hash but a different runtime is updated, not skipped; a function whose deployed runtime is unknown is still skipped.deploy.spec.ts:shouldUploadBeSkippedreturns false when a runtime changed.planner.tsanddeploy.ts, the two "runtime changed" tests fail; with it, all 58 tests in both files pass.npm run mocha: 6143 passing. The 2 failures (should return expected tsc path,should output the date in the correct format) also fail onmainon my machine; the Auth Emulator email link tests failed once and passed on rerun.tsc --noEmit, eslint and prettier pass.I have not run a real deploy against a project; the tests use the same
runtimevalues that are read fromfirebase.jsonand from the deployed function.Sample Commands
No command or flag changes. Reproduction from the issue: deploy with
"runtime": "nodejs22"infirebase.json, change only the runtime to"nodejs24", and runfirebase deploy --only functionsagain. The function is now updated instead of skipped.