DEV Community

Will Ceolin
Will Ceolin

Posted on • Edited on

2

Caching the Firebase Emulator on GitHub Actions

When testing your Firebase application, you need to download the Firebase Emulator. Fortunately, firebase-tools does that automatically for you.

However, when running your tests on a continuous integration environment such as GitHub Actions, you'll see the following warning:

It appears you are running in a CI environment. You can avoid downloading the Pub/Sub Emulator repeatedly by caching the /home/runner/.cache/firebase/emulators directory.
Enter fullscreen mode Exit fullscreen mode

This means, firebase-tools is downloading the Emulator binary every time you run your CI pipeline. You can avoid this by caching the emulator instead:

jobs:
  test:
    runs-on: ubuntu-latest
    env: FIREBASE_EMULATORS_PATH: ${{ github.workspace }}/emulator-cache

    steps:
      - name: Cache firebase emulators
        uses: actions/cache@v2
        with:
          path: ${{ env.FIREBASE_EMULATORS_PATH }}
          key:
            ${{ runner.os }}-firebase-emulators-${{
            hashFiles('emulator-cache/**') }}
        continue-on-error: true
Enter fullscreen mode Exit fullscreen mode

The step above will cache the emulator on GitHub Actions. The next time you run your tests, Firebase won't download the emulator again (unless the binary changed).


Follow me on Twitter

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay