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

Add input for custom command in firebase emulators:exec #81

Merged
merged 8 commits into from
Sep 16, 2024

Conversation

nriedman
Copy link
Contributor

@nriedman nriedman commented Sep 3, 2024

Add option to run custom command right before fastlane in emulator execution.

♻️ Current situation & Problem

In the ENGAGE-HF project, when we seed the emulator using the npm run serve:seeded command, the following command executes under the hood: firebase emulators:exec --only auth,firestore,functions,storage --ui "npm run serve:seed && read -rd \"\"". This spins up an emulator instance for the duration of the execution of the "npm run serve:seed && read -rd \"\"" calls. npm run serve:seed executes the required functions to seed the emulator, and the read -rd \"\" then causes the emulator to continue running until the user cancels the operation.

However, when integrating the seeding functionality into the CI for ENGAGE, we need to be able to have a seeded instance of the emulator for the duration of the fastlane testing call. The read -rd \"\" won't work for the self-hosted runner, as there is no way to cancel the emulator without canceling the workflow. Instead, we can introduce an input to the build-and-test workflow that allows us to pass a custom command to execute right before the fastlane test call. This custom command will then stay in effect throughout the lifespan of the emulator, which will shut down after the fastlane process finishes.

⚙️ Release Notes

  • Added an input for the custom command called customfirebaseemulatorcommand
  • Modified the execution of the fastlane command for the case where the fastlanelane argument is not empty, the setupfirebaseemulator argument is true, and the firebaseemulatorimport is empty.

Currently, the workflow executes the following command to run the fastlane tests if there is no firebase import provided:

firebase emulators:exec 'fastlane ${{ inputs.fastlanelane }}'

Instead, we replace this with the following:

if [ -n "${{ inputs.customfirebaseemulatorcommand }}" ]; then
    firebase emulators:exec '${{ inputs.customfirebaseemulatorcommand }} && fastlane ${{ inputs.fastlanelane }}'
else
    firebase emulators:exec 'fastlane ${{ inputs.fastlanelane }}'

This allows the following emulator command to be run:

firebase emulators:exec 'npm run serve:seed && fastlane test'

📚 Documentation

See description of customfirebaseemulatorcommand in xcodebuild-or-fastland.yml.

✅ Testing

NA

Code of Conduct & Contributing Guidelines

By submitting creating this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

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

Very cool, thanks for the work here @nriedman! Let's see if we can try to work with the existing infrastructure as discussed on Slack and it not merge this with minimal changes, thanks for taking a look at all of this!

Copy link
Member

@PSchmiedmayer PSchmiedmayer left a comment

Choose a reason for hiding this comment

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

Looks good; thank you @nriedman!

@PSchmiedmayer PSchmiedmayer merged commit 6544a6c into main Sep 16, 2024
3 checks passed
@PSchmiedmayer PSchmiedmayer deleted the input/customfirebaseemulatorcommand branch September 16, 2024 16:44
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