运行 GitLab 上的 Firebase 模拟器 CI
Running Firebase Emulator on GitLab CI
我正在尝试在我的 GitLab CI 管道上测试 Firestore 的安全规则。我需要 运行 Firebase 的模拟器来完成它。
但是,Firebase 模拟器基本上开始服务 "fake backend"。那么,我如何才能 运行 该工作与其他工作并行进行?
例如:
stages:
- emulator
- test
emulator:
- stage: emulator
script:
- firebase serve --only firestore
test:
- stage: test
script:
- yarn test
test
阶段从未达到,因为 GitLab 正在为 emulator
阶段服务。因此,它永远不会结束。
您不应该使用 2 个阶段。请记住,每个阶段都是完全独立的 "computer" 从某处开始。因此,默认情况下,一个阶段不能与另一个阶段交互。
阶段的 script
部分实际上是一个 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
系统上使用模拟器进行测试,最好添加一个 "start" 脚本。在这种情况下,我要添加测试 yarn test --exit
我正在尝试在我的 GitLab CI 管道上测试 Firestore 的安全规则。我需要 运行 Firebase 的模拟器来完成它。
但是,Firebase 模拟器基本上开始服务 "fake backend"。那么,我如何才能 运行 该工作与其他工作并行进行?
例如:
stages:
- emulator
- test
emulator:
- stage: emulator
script:
- firebase serve --only firestore
test:
- stage: test
script:
- yarn test
test
阶段从未达到,因为 GitLab 正在为 emulator
阶段服务。因此,它永远不会结束。
您不应该使用 2 个阶段。请记住,每个阶段都是完全独立的 "computer" 从某处开始。因此,默认情况下,一个阶段不能与另一个阶段交互。
阶段的 script
部分实际上是一个 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
系统上使用模拟器进行测试,最好添加一个 "start" 脚本。在这种情况下,我要添加测试 yarn test --exit