Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions .github/workflows/test-react-firebase-v12.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,36 @@ on:
pull_request:
branches: [main]
paths:
- 'packages/react/**'
- 'dataconnect-sdk/**'
- '.github/workflows/test-react-firebase-v12.yml'
- "packages/react/**"
- "dataconnect-sdk/**"
- ".github/workflows/test-react-firebase-v12.yml"

jobs:
test-react-v12:
name: React Package - Firebase v12
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: "20"

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: pnpm install

- name: Install Java
run: |
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk
java -version
# IMPROVED: Use actions/setup-java instead of apt-get
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"

- name: Install Firebase CLI
uses: nick-invision/retry@v3
Expand All @@ -49,7 +50,7 @@ jobs:
run: |
# Update root devDependencies to Firebase v12
pnpm add -Dw firebase@^12.1.0

- name: Update Data Connect SDK for Firebase v12
run: |
# Manually update the generated SDK to support Firebase v12
Expand All @@ -58,7 +59,7 @@ jobs:
# Update the peer dependency to include v12
npm pkg set 'peerDependencies.firebase=^12.1.0'
cd ../../..

- name: Reinstall dependencies with v12
run: |
# Install with no-frozen-lockfile to allow dependency changes
Expand All @@ -72,7 +73,7 @@ jobs:
run: |
cd packages/react
pnpm ls firebase | grep -E "firebase.*12\." || (echo "Firebase v12 not found!" && exit 1)

- name: Build React package
run: |
cd packages/react
Expand All @@ -84,4 +85,3 @@ jobs:
firebase emulators:exec --project test-project "cd packages/react && pnpm test:ci"
env:
CI: true

104 changes: 59 additions & 45 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ name: Tests

on:
push:
branches:
- main
branches: [main]
pull_request:
branches:
- main
branches: [main]

# Cancel in-progress runs when a new run is queued on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand All @@ -20,17 +17,23 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

# Make pnpm available before setup-node uses cache: 'pnpm'
- name: Enable Corepack (pnpm)
run: |
corepack enable
corepack prepare pnpm@9.12.2 --activate

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Enable Corepack
run: corepack enable
cache: "pnpm"

- name: Install dependencies
run: pnpm install
run: pnpm install --frozen-lockfile

- name: Run format check
run: pnpm format
Expand All @@ -42,63 +45,74 @@ jobs:
strategy:
matrix:
node-version: [20, 22]

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

# Make pnpm available before setup-node uses cache: 'pnpm'
- name: Enable Corepack (pnpm)
run: |
corepack enable
corepack prepare pnpm@9.12.2 --activate

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: pnpm install
cache: "pnpm"

- name: Install Java
run: |
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk
java -version
# Fast Java (no apt-get)
- name: Setup Java (JDK 17)
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"

# Cache Firebase emulators (JARs) once
- name: Cache Firebase emulators
if: matrix.node-version == '20'
uses: actions/cache@v4
with:
path: ~/.cache/firebase/emulators
key: ${{ runner.os }}-firebase-emulators-${{ hashFiles('.github/workflows/tests.yaml') }}
path: |
~/.cache/firebase/emulators
~/.cache/firebase/runtime
key: ${{ runner.os }}-firebase-emulators-${{ hashFiles('firebase.json', '.firebaserc', 'package.json', 'pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-firebase-emulators-

- name: Install Firebase CLI
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
retry_wait_seconds: 60
max_attempts: 3
command: npm i -g firebase-tools@latest

# Determine which packages have changed
- name: Determine changed packages
id: changes
uses: dorny/paths-filter@v2
# Ensure pnpm has a global bin dir on Linux runners (fixes ERR_PNPM_NO_GLOBAL_BIN_DIR)
- name: Configure PNPM global bin
if: matrix.node-version == '20'
run: |
echo "PNPM_HOME=$HOME/.local/share/pnpm" >> $GITHUB_ENV
mkdir -p "$HOME/.local/share/pnpm"
echo "$HOME/.local/share/pnpm" >> $GITHUB_PATH

# Install Firebase CLI globally so pnpm test:emulator works
- name: Install Firebase CLI (global, fast)
if: matrix.node-version == '20'
run: pnpm add -g firebase-tools@14

# Optional turbo cache
- name: Cache turbo build metadata
uses: actions/cache@v4
with:
filters: |
react:
- 'packages/react/**'
angular:
- 'packages/angular/**'
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- name: Install dependencies
run: pnpm install --frozen-lockfile

# Build packages before testing
- name: Build packages
run: pnpm turbo build

# Verify build outputs
- name: Verify build outputs
run: |
# Check all packages for dist directories
MISSING_BUILDS=""
for PKG_DIR in packages/*; do
if [ -d "$PKG_DIR" ] && [ -f "$PKG_DIR/package.json" ]; then
Expand All @@ -108,13 +122,13 @@ jobs:
fi
fi
done

if [ -n "$MISSING_BUILDS" ]; then
echo "❌ Build outputs not found for: $MISSING_BUILDS"
exit 1
fi
echo "✅ All build outputs verified"

# Run tests with all emulators (auth, firestore, and data-connect)
# Run emulator tests only once (Node 20)
- name: Run tests with emulator
if: matrix.node-version == '20'
run: pnpm test:emulator