0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GitHub ActionsでFirebaseエミュレータをキャッシュする

Posted at

GitHub ActionsでFirebaseエミュレータを使用したテストを実行すると以下のように怒られたので対応しました。

⚠  It appears you are running in a CI environment.
You can avoid downloading the Firestore Emulator repeatedly
by caching the /home/runner/.cache/firebase/emulators directory.

対応

インストールされるエミュレータのバージョンは firebase-tools のバージョンに依存するらしいので、

- name: Install firebase-tools
  run: |
    yarn global add firebase-tools
    echo "FIREBASE_VIRSION=$(firebase --version)" >> $GITHUB_ENV

で環境変数に firebase-tools のバージョンを保存し、それをkeyにしてキャッシュする以下のstepを追加しました。

- name: Cache firebase emulators
  uses: actions/cache@v3
  with:
    path: ~/.cache/firebase/emulators
    key: ${{ runner.os }}-firebase-emulators-${{ env.FIREBASE_VIRSION }}

ワークフロー全体

ワークフロー全体は以下のようになります。

.github/workflows/test.yml
name: Test

on: push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: "14"
          cache: "yarn"

      - name: Install dependences
        run: |
          yarn install

      - name: Install firebase-tools
        run: |
          yarn global add firebase-tools
          echo "FIREBASE_VIRSION=$(firebase --version)" >> $GITHUB_ENV

      - name: Cache firebase emulators
        uses: actions/cache@v3
        with:
          path: ~/.cache/firebase/emulators
          key: ${{ runner.os }}-firebase-emulators-${{ env.FIREBASE_VIRSION }}

      - name: Run test
        run: |
          firebase use dev
          firebase emulators:exec --only firestore 'jest firestore'
        env:
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?