From e51bec6cad7b1e7f7215a70bb1c30fe3aab93bf6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Feb 2026 06:53:13 +0000 Subject: [PATCH] feat: add Firebase Storage Emulator setup and teardown actions - Create firebase.json configuration for Storage Emulator on port 9199 - Add setup-firebase-emulator action to install and start Firebase CLI emulator - Add teardown-firebase-emulator action to stop emulator using saved PID - Use proper PID-based process management instead of pkill/killall Co-authored-by: rchincha <45800463+rchincha@users.noreply.github.com> --- .../setup-firebase-emulator/action.yaml | 38 +++++++++++++++++++ .../teardown-firebase-emulator/action.yaml | 23 +++++++++++ firebase.json | 8 ++++ 3 files changed, 69 insertions(+) create mode 100644 .github/actions/setup-firebase-emulator/action.yaml create mode 100644 .github/actions/teardown-firebase-emulator/action.yaml create mode 100644 firebase.json diff --git a/.github/actions/setup-firebase-emulator/action.yaml b/.github/actions/setup-firebase-emulator/action.yaml new file mode 100644 index 00000000..eb12725f --- /dev/null +++ b/.github/actions/setup-firebase-emulator/action.yaml @@ -0,0 +1,38 @@ +name: 'Setup Firebase Storage Emulator' +description: 'Install and run Firebase Storage Emulator for GCS testing' +runs: + using: "composite" + steps: + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install Firebase CLI + shell: bash + run: | + npm install -g firebase-tools + + - name: Start Firebase Storage Emulator + shell: bash + run: | + cd ${{ github.workspace }} + # Start emulator in the background and save PID + firebase emulators:start --only storage --project demo-test > /tmp/firebase-emulator.log 2>&1 & + FIREBASE_PID=$! + echo $FIREBASE_PID > ${{ github.workspace }}/.firebase-emulator.pid + echo "Firebase emulator started with PID: $FIREBASE_PID" + + # Wait for emulator to be ready + echo "Waiting for Firebase Storage Emulator to be ready..." + for i in {1..30}; do + if curl -s http://localhost:9199 > /dev/null 2>&1; then + echo "Firebase Storage Emulator is ready" + exit 0 + fi + sleep 1 + done + + echo "Firebase Storage Emulator failed to start within 30 seconds" + cat /tmp/firebase-emulator.log + exit 1 diff --git a/.github/actions/teardown-firebase-emulator/action.yaml b/.github/actions/teardown-firebase-emulator/action.yaml new file mode 100644 index 00000000..5af167fe --- /dev/null +++ b/.github/actions/teardown-firebase-emulator/action.yaml @@ -0,0 +1,23 @@ +name: 'Teardown Firebase Storage Emulator' +description: 'Stop Firebase Storage Emulator' +runs: + using: "composite" + steps: + - if: always() + shell: bash + run: | + # Save the PID file location + PID_FILE="${{ github.workspace }}/.firebase-emulator.pid" + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then + kill "$PID" || true + # Wait a bit for graceful shutdown + sleep 2 + # Force kill if still running + if kill -0 "$PID" 2>/dev/null; then + kill -9 "$PID" || true + fi + fi + rm -f "$PID_FILE" + fi diff --git a/firebase.json b/firebase.json new file mode 100644 index 00000000..7c57286e --- /dev/null +++ b/firebase.json @@ -0,0 +1,8 @@ +{ + "emulators": { + "storage": { + "host": "0.0.0.0", + "port": 9199 + } + } +}