简体   繁体   中英

Running Firebase Emulator on GitLab CI

I'm trying to test Firestore's security rules on my GitLab CI pipeline. I need to run Firebase's emulator to accomplish that.

However, the Firebase emulator basically starts serving a "fake backend". 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. Therefore, it never finishes.

You should not use 2 stages. 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. So if you want to try if everything works, create a shell script and execute it.

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. In this case I'm adding the test yarn test --exit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM