Skip to content
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

Chore/fix up firebase emulator #3598

Merged
merged 29 commits into from
Jun 13, 2024

Conversation

pizzaisdavid
Copy link
Collaborator

@pizzaisdavid pizzaisdavid commented May 26, 2024

PR Checklist

PR Type

  • chore

Description

Make the emulator stuff work for the backend. 😅

Demo video:

demo video

raw link - https://www.youtube.com/watch?v=qLfQgMpWguE

I recommend starting by pulling the branch locally and following the updated documentation https://github.com/pizzaisdavid/community-platform/blob/51ed0187aa155337a7d8130895739c08767d9f8e/packages/documentation/docs/Backend%20Development/firebase-emulator.md

Everything in functions/data/emulator can be ignored, as that is data that is loaded into the emulator so there is initial data.

This removes packages/emulators-docker in favor of placing the emulator stuff in the functions folder.

@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch 4 times, most recently from deeab7f to fc95a08 Compare May 26, 2024 19:58
Copy link

codecov bot commented May 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.83%. Comparing base (df53a15) to head (737991c).

Current head 737991c differs from pull request most recent head c9828c0

Please upload reports for the commit c9828c0 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3598      +/-   ##
==========================================
- Coverage   74.87%   67.83%   -7.04%     
==========================================
  Files          39      411     +372     
  Lines        1214    12795   +11581     
  Branches      247     2249    +2002     
==========================================
+ Hits          909     8680    +7771     
- Misses        285     4093    +3808     
- Partials       20       22       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch 5 times, most recently from 083c45d to e658765 Compare May 26, 2024 22:31
Copy link
Contributor

@mariojsnunes mariojsnunes left a comment

Choose a reason for hiding this comment

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

great work!

is the storage_export folder suposed to be included on git?

CONTRIBUTING.md Outdated Show resolved Hide resolved
functions/Dockerfile.emulator Outdated Show resolved Hide resolved
@pizzaisdavid
Copy link
Collaborator Author

Something to note: for me, the e2e tests don't run. So actually, the functions e2e job may fail because I edited the firebase.json file.

Currently, the only way to check that is if a maintainer pushes the code or presses the merge button.

@pizzaisdavid
Copy link
Collaborator Author

pizzaisdavid commented May 27, 2024

@mariojsnunes

great work!

is the storage_export folder suposed to be included on git?

Thanks!

Yep, on master you can also see a version of this is already committed similar in other seed data. Hidden in zips or compressed files. If you unzip functions/data/seed/seed-default.zip you'll see it there too.

Everything in the emulator folder is just the data exported from the emulator with emulators:export https://firebase.google.com/docs/emulator-suite/install_and_configure#export_and_import_emulator_data

So I guess not including it would make there be no images in the seed data.

@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch from c616993 to 1df026d Compare May 27, 2024 15:09
@pizzaisdavid
Copy link
Collaborator Author

@mariojsnunes feedback addressed. I assume the CI e2e will fail again

@pizzaisdavid pizzaisdavid requested a review from mariojsnunes May 27, 2024 15:27
@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch 2 times, most recently from b42e343 to 941bb14 Compare May 28, 2024 17:43
@pizzaisdavid
Copy link
Collaborator Author

pizzaisdavid commented May 31, 2024

@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch from 508b591 to eee9328 Compare May 31, 2024 15:58
Copy link

cypress bot commented Jun 3, 2024

Passing run #5744 ↗︎

0 77 1 0 Flakiness 0

Details:

Merge branch 'master' into chore/fix-up-firebase-emulator
Project: onearmy-community-platform Commit: 1aff705bd0
Status: Passed Duration: 04:29 💡
Started: Jun 5, 2024 1:51 PM Ended: Jun 5, 2024 1:55 PM

Review all test suite changes for PR #3598 ↗︎

@pizzaisdavid pizzaisdavid mentioned this pull request Jun 3, 2024
2 tasks
@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch from 55bb451 to 6490c22 Compare June 4, 2024 19:11
Copy link
Member

@benfurber benfurber left a comment

Choose a reason for hiding this comment

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

@pizzaisdavid! Amazing! Thank you.

Ran it locally on my mac 14.4.1 and did the basics.

Followed the docs on packages/documentation/docs/Backend Development/firebase-emulator.md the command yarn run backend:emulator:watch isn't working for me but docker run -v ./functions:/app/functions -p 4001-4008:4001-4008 -it emulator on functions/Dockerfile.emulator worked fine. Log below.

benfurber@Benjamins-Laptop community-platform % yarn run backend:emulator:watch
[1] time="2024-06-05T15:30:13+01:00" level=warning msg="/Users/benfurber/projects/community-platform/docker-compose.yml: `version` is obsolete"
[1] #0 building with "desktop-linux" instance using docker driver
[1]
[1] #1 [emulator internal] load build definition from Dockerfile.emulator
[1] #1 transferring dockerfile: 3.19kB done
[1] #1 DONE 0.0s
[1]
[1] #2 [emulator internal] load metadata for docker.io/library/node:20.9.0-bullseye-slim
[1] #2 DONE 1.2s
[1]
[1] #3 [emulator internal] load .dockerignore
[1] #3 transferring context: 2B done
[1] #3 DONE 0.0s
[1]
[1] #4 [emulator  1/11] FROM docker.io/library/node:20.9.0-bullseye-slim@sha256:330fa0342b6ad2cbdab30ac44195660af5a1f298cc499d8cbdf7496b02ea17d8
[1] #4 DONE 0.0s
[1]
[1] #5 [emulator internal] load build context
[1] #5 transferring context: 155B done
[1] #5 DONE 0.0s
[1]
[1] #6 [emulator 10/11] RUN   echo "#!/bin/bash\n" >> ./export.sh &&   echo "firebase emulators:export --project demo-community-platform-emulated --force ./dump\n" >> ./export.sh &&   chmod +x ./export.sh
[1] #6 CACHED
[1]
[1] #7 [emulator  7/11] COPY ./firebase.storage.rules      ./firebase.storage.rules
[1] #7 CACHED
[1]
[1] #8 [emulator  6/11] COPY ./firebase.json               ./firebase.json
[1] #8 CACHED
[1]
[1] #9 [emulator  9/11] COPY ./firestore.rules             ./firestore.rules
[1] #9 CACHED
[1]
[1] #10 [emulator  3/11] RUN   apt-get update &&   apt-get -y install openjdk-11-jre-headless &&   apt-get -y install nano &&   apt-get clean
[1] #10 CACHED
[1]
[1] #11 [emulator  4/11] RUN npm install -g firebase-tools
[1] #11 CACHED
[1]
[1] #12 [emulator  5/11] RUN   firebase setup:emulators:ui &&   firebase setup:emulators:firestore &&   firebase setup:emulators:database &&   firebase setup:emulators:storage &&   firebase setup:emulators:pubsub
[1] #12 CACHED
[1]
[1] #13 [emulator  2/11] WORKDIR /app
[1] #13 CACHED
[1]
[1] #14 [emulator  8/11] COPY ./firestore.indexes.json      ./firestore.indexes.json
[1] #14 CACHED
[1]
[1] #15 [emulator 11/11] RUN mkdir ./seed
[1] #15 CACHED
[1]
[1] #16 [emulator] exporting to image
[1] #16 exporting layers done
[1] #16 writing image sha256:7342849822d024d537b4826b68bf2ea7661de4c2eb048d80ac19cf7f9ee1f355 done
[1] #16 naming to docker.io/library/community-platform-emulator done
[1] #16 DONE 0.0s
[1]  Container community-platform-emulator-1  Recreate
[1]  Container community-platform-emulator-1  Recreated
[1] Attaching to emulator-1
[1] emulator-1  | ⚠  emulators: You are not currently authenticated so some features may not work correctly. Please run firebase login to authenticate the CLI.
[1] emulator-1  | i  emulators: Starting emulators: auth, functions, firestore, database, hosting, pubsub, storage
[1] emulator-1  | i  emulators: Detected demo project ID "demo-community-platform-emulated", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.
[1] emulator-1  | ⚠  functions: You are not signed in to the Firebase CLI. If you have authorized this machine using gcloud application-default credentials those may be discovered and used to access production services.
[1] emulator-1  | i  firestore: Importing data from /app/seed/firestore_export/firestore_export.overall_export_metadata
[1] emulator-1  | i  firestore: Firestore Emulator logging to firestore-debug.log
[1] emulator-1  | ✔  firestore: Firestore Emulator UI websocket is running on 9150.
[1] emulator-1  | ⚠  database: Did not find a Realtime Database rules file specified in a firebase.json config file. The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.
[1] emulator-1  | i  database: Database Emulator logging to database-debug.log
[1] emulator-1  | i  emulators: Shutting down emulators.
[1] emulator-1  | i  functions: Stopping Functions Emulator
[1] emulator-1  | i  database: Stopping Database Emulator
[1] emulator-1  | i  firestore: Stopping Firestore Emulator
[1] emulator-1  | i  eventarc: Stopping Eventarc Emulator
[1] emulator-1  | i  hub: Stopping emulator hub
[1] emulator-1  |
[1] emulator-1  | Error: An unexpected error has occurred.
emulator-1 exited with code 2
[1] docker-compose up --force-recreate --build emulator exited with code 0
--> Sending SIGTERM to other processes..
[0] yarn workspace functions watch exited with code 129```

@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch 2 times, most recently from b746b82 to a920477 Compare June 12, 2024 17:24
@pizzaisdavid pizzaisdavid force-pushed the chore/fix-up-firebase-emulator branch from a920477 to c9828c0 Compare June 12, 2024 17:35
@pizzaisdavid
Copy link
Collaborator Author

rebased (whoop)

@benfurber benfurber merged commit 6715a8d into ONEARMY:master Jun 13, 2024
11 checks passed
@onearmy-bot
Copy link
Collaborator

🎉 This PR is included in version 1.189.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pizzaisdavid pizzaisdavid deleted the chore/fix-up-firebase-emulator branch June 14, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants