mirror of
https://github.com/project-zot/zot.git
synced 2026-06-15 11:37:56 +08:00
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>
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"emulators": {
|
||||
"storage": {
|
||||
"host": "0.0.0.0",
|
||||
"port": 9199
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user