Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在GitLab CI上运行Firebase Emulator_Firebase_Google Cloud Firestore_Continuous Integration_Gitlab_Firebase Tools - Fatal编程技术网

在GitLab CI上运行Firebase Emulator

在GitLab CI上运行Firebase Emulator,firebase,google-cloud-firestore,continuous-integration,gitlab,firebase-tools,Firebase,Google Cloud Firestore,Continuous Integration,Gitlab,Firebase Tools,我正在尝试在我的GitLab CI管道上测试Firestore的安全规则。我需要运行Firebase的emulator来实现这一点 然而,Firebase emulator基本上开始提供“假后端”。那么,我怎样才能将该作业与其他作业并行运行呢 例如: stages: - emulator - test emulator: - stage: emulator script: - firebase serve --only firestore test: - stag

我正在尝试在我的GitLab CI管道上测试Firestore的安全规则。我需要运行Firebase的emulator来实现这一点

然而,Firebase emulator基本上开始提供“假后端”。那么,我怎样才能将该作业与其他作业并行运行呢

例如:

stages:
  - emulator
  - test

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

test:
  - stage: test
  script:
    - yarn test

由于GitLab正在为
emulator
阶段提供服务,因此永远不会到达
测试阶段。因此,它永远不会结束。

您不应该使用两个阶段。请记住,每个阶段都是从某个地方开始的一台完全独立的“计算机”。因此,默认情况下,一个阶段不能与另一个阶段交互。 舞台的
脚本
部分实际上是一个shell脚本。因此,如果您想尝试一下,如果一切正常,请创建一个shell脚本并执行它

这就是我所做的。请记住,我没有用您的特定设置测试它

stages:
  - test


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


要在
CI
系统上使用模拟器进行测试,最好添加一个“开始”脚本。在本例中,我添加了测试
纱线测试--exit

[Firebaser here]这是正确的答案,这正是
模拟器:exec
的目的。仅供参考,您不再需要运行
setup:emulators:firestore
,我们会在最新版本的Firebase CLI中自动下载缺少的模拟器。