ci: improve workflow robustness and performance #359
Workflow file for this run
This file contains hidden or 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
| name: Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| 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 | |
| jobs: | |
| quality: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run format check | |
| # The --unsafe flag is required in CI to bypass interactive prompts | |
| # that would otherwise cause the command to hang in automated environments | |
| run: pnpm format --unsafe | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| needs: quality | |
| strategy: | |
| matrix: | |
| node-version: [18, 20, 22] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - 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: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install | |
| - 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@14 | |
| # Determine which packages have changed | |
| - name: Determine changed packages | |
| id: changes | |
| uses: dorny/paths-filter@v2 | |
| with: | |
| filters: | | |
| react: | |
| - 'packages/react/**' | |
| angular: | |
| - 'packages/angular/**' | |
| # 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 | |
| PKG_NAME=$(basename "$PKG_DIR") | |
| if [ ! -d "$PKG_DIR/dist" ]; then | |
| MISSING_BUILDS="$MISSING_BUILDS $PKG_NAME" | |
| 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 emulator for changed packages | |
| - name: Run tests with emulator | |
| run: pnpm test:emulator |