Skip to content

Add firebase deploy --only run for remote Cloud Build source deploys - #11205

Open
falahat wants to merge 79 commits into
mainfrom
bapi_deploy_run
Open

falahat wants to merge 79 commits into
mainfrom
bapi_deploy_run

Conversation

@falahat

@falahat falahat commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds firebase deploy --only run, behind the directcloudrun experiment. For each Cloud Run service in firebase.json, it builds the local source on Cloud Build, then creates the service or rolls out a new revision.

firebase init run now deploys the service it sets up.

  • prepare.ts: picks the services, reads them from Cloud Run, and keeps their base image.
  • deploy.ts: uploads the source, builds it, then creates the service or rolls out a new revision. revisionTemplate keeps the live revision's settings.
  • release.ts: logs each service's URL.
  • util.ts: handles --only run, run:<serviceId>, and run:<serviceId>:<region>.

run:services:update (#11206), local builds (#11207), and SDK auto-init (#11208) come in follow-up PRs.

Scenarios Tested

  • Unit tests.
  • On a test project: redeployed a service with -m, and used --only with the same service ID in two regions.

Sample Commands

firebase deploy --only run
firebase deploy --only run:my-service:us-central1

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for deploying Cloud Run services directly via the Firebase CLI under the 'direct_cloud_run' experiment, adding the 'run' deploy target, integration with 'firebase init', and comprehensive tests. The review feedback suggests several key improvements: handling expected user-facing errors by importing and throwing 'FirebaseError', avoiding non-null assertions on the main container template to prevent runtime errors, ensuring temporary local archives are cleaned up in a 'finally' block to avoid disk leaks, parallelizing service preparation using 'Promise.all' for better performance, and adding defensive checks for potentially undefined configuration properties.

Comment thread src/deploy/run/deploy.ts
Comment thread src/deploy/run/deploy.ts Outdated
Comment thread src/deploy/run/deploy.ts Outdated
Comment thread src/deploy/run/prepare.ts
Comment thread src/deploy/run/util.ts Outdated
Comment thread src/deploy/run/util.ts Outdated
@falahat

falahat commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@falahat
falahat added this pull request to stack #11209 September 30, 2026 04:19

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for deploying Cloud Run services directly from local source using the Firebase CLI. It adds the new run deploy target, implements its prepare, deploy, and release phases, integrates it into the initialization flow, and adds comprehensive unit and end-to-end tests. The review feedback highlights several key improvements: adhering to strict null checks by avoiding the non-null assertion operator on the main container, cleaning up temporary local archive files after upload to prevent disk space leaks, verifying the existence of the deployed service URI before logging, and using npx mocha in the test script for better environment robustness.

Comment thread src/deploy/run/deploy.ts Outdated
Comment thread src/deploy/run/deploy.ts Outdated
Comment thread src/deploy/run/deploy.ts
Comment thread src/deploy/run/release.ts
Comment thread scripts/run-deploy-tests/run.sh Outdated
@falahat
falahat removed this pull request from stack #11209 September 30, 2026 21:42
@falahat
falahat added this pull request to stack #11226 October 2, 2026 16:41
falahat added 13 commits October 8, 2026 08:11
Spell out what init changes on an existing service (rootDir and region) instead of merging three spreads. upsertRunConfig now adds the default ignore list itself, so actuate no longer passes it. Behavior is unchanged; added a test for the ignore fallback on existing services.
Spell out what init changes on an existing service (rootDir and region) instead of merging three spreads. upsertRunConfig now adds the default ignore list itself, so actuate no longer passes it. Behavior is unchanged; added a test for the ignore fallback on existing services.
Re-running init on a service that's already in firebase.json filled in the default ignore list when the entry didn't have one. Init doesn't ask about ignore, so it shouldn't change it: an existing entry now only gets the rootDir and region the user just chose. New services still get the default ignore list.
…ce ID and region

Pressing Enter now keeps the root directory saved in firebase.json instead of resetting it to /. Cloud Run service IDs are only unique within a region, so entries now match on both; the same ID in another region gets its own entry.
…gions

Init deploys with --only run:<id>, which matches that ID in every region. Init now also passes the service's region to deploy, which skips services in other regions. firebase deploy and --only run:<id> are unchanged.
…actuate

Init already writes firebase.json after every feature is set up, so the write in actuate only printed "Wrote configuration info to firebase.json" a second time. Leaving the write to init also means a failed init leaves firebase.json untouched.
# Conflicts:
#	src/init/features/run.spec.ts
#	src/init/features/run.ts
Base automatically changed from bapi_init_run to main October 8, 2026 19:10
scripts/run-deploy-tests ran the real CLI against a real project. Nothing ran it automatically (npm test only covers src/, and CI doesn't list it), and each run left Cloud Build images behind in Artifact Registry. The unit tests cover the logic, and live testing is done by hand.
# Conflicts:
#	src/deploy/run/util.spec.ts
#	src/deploy/run/util.ts
#	src/init/features/run.spec.ts
#	src/init/features/run.ts
Comment thread src/deploy/run/index.ts
Service IDs are only unique within a region, so firebase.json can list the
same ID in more than one region.

- run:<serviceId> still deploys that ID in every region it's listed in, and
  now logs which services it matched when there's more than one.
- run:<serviceId>:<region> deploys exactly one service. Init deploys the
  service it set up this way, which replaces the region it used to pass in
  the deploy context.
- Per-service messages (uploading, building, deployed) include the region.
- firebase.json can't list the same service ID and region twice.
- deploy.ts reads as four steps: upload the source, build it, prepare
  the revision, then create the service or roll out a new revision. The
  revision rules are a pure function, revisionTemplate, with one small
  test per rule.
- Helpers that only deploy.ts uses (deployRevision, toAppHostingConfig,
  the rollout timeout) moved there from util.ts. util.ts now only picks
  services from firebase.json and checks whether a service exists.
- Stop deleting the local source zip. It's a tmp file, which firebase
  deploy deletes when it exits; App Hosting relies on the same thing.
- Check every service's region once, up front, and stop --only
  filtering at the first service that isn't in firebase.json.
- Tests use realistic names, check only the fields they're about, and
  drop duplicate coverage. The release test has its own file.
- The help text no longer mentions local builds or run:services:update,
  which later PRs add.
- Clearer docstrings and tests for init run's actuate and
  upsertRunConfig.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants