[英]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.