Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add input for custom command in firebase emulators:exec (#81)
# 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: ```shell firebase emulators:exec 'fastlane ${{ inputs.fastlanelane }}' ``` Instead, we replace this with the following: ```shell 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: ```shell 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](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md): - [X] I agree to follow the [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
- Loading branch information