functions-differ icon indicating copy to clipboard operation
functions-differ copied to clipboard

Update hashes only on successful deployments

Open haroldadmin opened this issue 4 years ago • 0 comments

Problem

functions-differ writes new hashes to the .differspec.json file even if the detected changes were not deployed to Firebase. This means that if you run functions-differ again after a failed deployment, you get an empty list of changed functions.

Proposed Solutions

The goal is to make functions-differ command invocation idempotent, meaning that multiple invocations of functions-differ should output the same list of changed functions until a successful deployment.

There's no easy solution to this because we can not detect if the deployment was successful. Some possible solutions are:

  • :bulb: Use the source code deployed on GCF to calculate old hashes of the functions, instead of relying on hashes stored in .differspec.json.

    • :heavy_check_mark: Pros:
      • Ensures that old hashes are always calculated from functions that were deployed successfully
    • :stop_sign: Cons:
      • Increases time of invocation significantly, as we would need to download source code of deployed functions.
      • Increases complexity, as we would need to authenticate with GCP to download sources.
      • Calculating hashes from downloaded source code is complicated, as the source code of the function includes all other files in the project as well.
  • :bulb: Execute firebase deploy command as a sub process from functions-differ and only update hashes when the sub process exits successfully

    • :heavy_check_mark: Pros:
      • Ensures that old hashes are always calculated from functions that were deployed successfully
      • Makes the tool more fully-featured, as it provides an out of the box solution for deploying functions.
    • :stop_sign: Cons:
      • Imposes a dependency on the Firebase CLI, and would require changes whenever the CLI interface changes.
      • In case of a partially successful deployment, it is difficult to detect which functions were deployed sucessfully.

haroldadmin avatar May 01 '21 07:05 haroldadmin