简体   繁体   English

在 GitLab CI 上运行 Firebase 模拟器

[英]Running Firebase Emulator on GitLab CI

I'm trying to test Firestore's security rules on my GitLab CI pipeline.我正在尝试在我的 GitLab CI 管道上测试 Firestore 的安全规则。 I need to run Firebase's emulator to accomplish that.我需要运行 Firebase 的模拟器来实现这一点。

However, the Firebase emulator basically starts serving a "fake backend".但是,Firebase 模拟器基本上开始提供“假后端”服务。 So, how can I run that job in parallel to other jobs?那么,我如何才能与其他作业并行运行该作业?

For example:例如:

stages:
  - emulator
  - test

emulator:
  - stage: emulator
  script:
    - firebase serve --only firestore

test:
  - stage: test
  script:
    - yarn test

The test stage is never reached as GitLab is serving the emulator stage.由于 GitLab 为emulator阶段提供服务,因此永远不会到达test阶段。 Therefore, it never finishes.因此,它永远不会结束。

You should not use 2 stages.你不应该使用 2 个阶段。 Keep in mind, each stage is a completely independent "computer" started somewhere.请记住,每个阶段都是从某处开始的完全独立的“计算机”。 So one stage can per default not interact with another.所以一个阶段可以默认不与另一个交互。 The script part of a stage is practically a shell script.阶段的script部分实际上是一个 shell 脚本。 So if you want to try if everything works, create a shell script and execute it.因此,如果您想尝试是否一切正常,请创建一个 shell 脚本并执行它。

Here is what I did.这是我所做的。 Keep in mind it's I didn't test it with your particular setup请记住,我没有使用您的特定设置对其进行测试

stages:
  - test


test:
  - stage: test
  script:
     - yarn compile
     - yarn firebase setup:emulators:firestore
     - yarn firebase emulators:exec -P dev1 --only firestore "yarn test --exit"

To use the emulator with tests on a CI system it's best you add a "start" script.要在CI系统上使用模拟器进行测试,最好添加一个“启动”脚本。 In this case I'm adding the test yarn test --exit在这种情况下,我添加了 test yarn test --exit

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firestore/Firebase 模拟器未运行 - Firestore/Firebase Emulator Not Running 使用 GitLab CI 时无法识别 Firebase - Firebase not recognized while using GitLab CI 运行依赖于 firestore 模拟器的 CI 测试 - Running CI tests that rely on firestore emulator 将夹具导入运行firebase仿真器 - Import fixtures into running firebase emulator 有没有办法向正在运行的 firebase 仿真器添加/修改功能? - Is there a way to add/modify functions to a running firebase emulator? 尝试在 Gitlab CI 管道上运行 Firestore 模拟器会出现“未安装 java”错误 - Trying to run Firestore emulator on Gitlab CI pipeline gives "java is not installed" error 使用 Firebase 模拟器运行 Firebase Admin 时是否需要凭据? - Is credential necessary when running Firebase Admin with Firebase Emulator? 在 azure CI 环境中运行构建时,DSYM 文件未上传到 firebase - DSYM file is not uploaded to firebase while running build in azure CI Environment Firebase Auth 给出 ViewPostIme 指针 1 在物理设备上运行但在 Android 模拟器上工作(Firebase 仅在模拟器上工作) - Firebase Auth gives ViewPostIme pointer 1 While running on a physical device but work on Android Emulator ( Firebase works only on emulator ) 如何修复错误解析触发器:在 Gitlab CI 上部署 Firebase 函数时找不到模块'../../ - How to fix Error parsing triggers: Cannot find module '../../ when deploying Firebase Functions on Gitlab CI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM