fix firebase emulators caching #36
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file was auto-generated by the Firebase CLI | |
# https://github.com/firebase/firebase-tools | |
name: CI/CD | |
on: push | |
# Cancel any previous CI runs for this branch or PR | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: corepack enable | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: "pnpm" | |
check-latest: true | |
- name: Output debugging info | |
run: node -v && npm -v && pnpm -v | |
- name: Install | |
run: pnpm install && pnpm --dir functions install | |
- name: Lint | |
run: pnpm run lint | |
- name: Build | |
run: pnpm run build:all | |
- name: Integration tests | |
run: pnpm run coverage | |
# env: | |
# VITEST_MAX_THREADS: 1 | |
# VITEST_MIN_THREADS: 1 | |
- uses: codecov/codecov-action@v4 | |
with: | |
# fail_ci_if_error: true # optional (default = false) | |
files: ./coverage/lcov.info # optional | |
# flags: unittests # optional | |
# name: codecov-umbrella # optional | |
token: ${{ secrets.CODECOV_TOKEN }} # required | |
verbose: true # optional (default = false) | |
deploy: | |
if: github.ref_name == 'main' || github.ref_name == 'production' | |
environment: ${{ github.ref_name == 'main' && 'staging' || github.ref_name == 'production' && 'production' }} | |
needs: [build_and_test, e2e_test] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: corepack enable | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: "pnpm" | |
check-latest: true | |
- name: Output debugging info | |
run: node -v && npm -v && pnpm -v | |
- name: Install | |
run: pnpm install && pnpm --dir functions install | |
# Note: no linting or testing, since it was done in the previous job | |
- name: Build | |
run: pnpm run build:all | |
env: | |
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} | |
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }} | |
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }} | |
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }} | |
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }} | |
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }} | |
- name: Create SA key | |
run: echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' > $HOME/gcloud.json | |
- name: Deploy | |
# This requires a lot of pesky permissions in GCP, inspired from: https://davelms.medium.com/deploy-firebase-functions-using-github-actions-7dbafbd4df77 | |
run: GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcloud.json pnpm run deploy --project ${{ secrets.VITE_FIREBASE_PROJECT_ID }} | |
e2e_test: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: corepack enable | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: "pnpm" | |
check-latest: true | |
- name: Output debugging info | |
run: node -v && npm -v && pnpm -v | |
- name: Install dependencies | |
run: pnpm install | |
- name: Install Playwright Browsers | |
run: pnpm exec playwright install --with-deps chromium | |
- name: Setup emulator cache | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/firebase/emulators | |
key: emulators-${{ runner.os }} | |
- name: Run Playwright tests | |
run: pnpm run test:e2e:coverage | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 30 | |
- uses: codecov/codecov-action@v4 | |
with: | |
# fail_ci_if_error: true # optional (default = false) | |
files: ./coverage/lcov.info # optional | |
# flags: unittests # optional | |
# name: codecov-umbrella # optional | |
token: ${{ secrets.CODECOV_TOKEN }} # required | |
verbose: true # optional (default = false) | |