簡體   English   中英

在 GitLab CI 上運行 Firebase 模擬器

[英]Running Firebase Emulator on GitLab CI

我正在嘗試在我的 GitLab CI 管道上測試 Firestore 的安全規則。 我需要運行 Firebase 的模擬器來實現這一點。

但是,Firebase 模擬器基本上開始提供“假后端”服務。 那么,我如何才能與其他作業並行運行該作業?

例如:

stages:
  - emulator
  - test

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

test:
  - stage: test
  script:
    - yarn test

由於 GitLab 為emulator階段提供服務,因此永遠不會到達test階段。 因此,它永遠不會結束。

你不應該使用 2 個階段。 請記住,每個階段都是從某處開始的完全獨立的“計算機”。 所以一個階段可以默認不與另一個交互。 階段的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系統上使用模擬器進行測試,最好添加一個“啟動”腳本。 在這種情況下,我添加了 test yarn test --exit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM