chore(build): migrate monorepo orchestration from nx to turborepo #1556
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: Bundle Size | |
| on: | |
| pull_request: | |
| branches: [main] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: bundle-size-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| jobs: | |
| measure: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout PR | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| cache-dependency-path: '**/pnpm-lock.yaml' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Restore Turborepo cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| .turbo | |
| **/.turbo | |
| key: ${{ runner.os }}-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.ref_name }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-turbo-${{ github.workflow }}-${{ github.job }}-${{ github.ref_name }}- | |
| ${{ runner.os }}-turbo-${{ github.workflow }}-${{ github.job }}- | |
| ${{ runner.os }}-turbo- | |
| - name: Build packages (current) | |
| run: pnpm run build:packages | |
| - name: Measure bundle sizes (current) | |
| run: node scripts/bundle-size-report.mjs --output current.json | |
| - name: Prepare base worktree | |
| run: | | |
| BASE_REF=${CI_LOCAL_BASE_REF:-origin/main} | |
| BASE_PATH=".ci-local-base-${RANDOM}-${RANDOM}" | |
| LOCAL_BASE_REF="${BASE_REF#origin/}" | |
| echo "BASE_REF=$BASE_REF" >> "$GITHUB_ENV" | |
| echo "BASE_PATH=$BASE_PATH" >> "$GITHUB_ENV" | |
| echo "LOCAL_BASE_REF=$LOCAL_BASE_REF" >> "$GITHUB_ENV" | |
| git worktree add "$BASE_PATH" "$BASE_REF" | |
| git -C "$BASE_PATH" branch -f "$LOCAL_BASE_REF" "$BASE_REF" || true | |
| - name: Restore Turborepo cache (base worktree) | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ env.BASE_PATH }}/.turbo | |
| key: ${{ runner.os }}-turbo-base-${{ github.workflow }}-${{ github.job }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-turbo-base-${{ github.workflow }}-${{ github.job }}- | |
| ${{ runner.os }}-turbo-base-${{ github.workflow }}- | |
| ${{ runner.os }}-turbo-base- | |
| - name: Install dependencies (base) | |
| run: pnpm install --frozen-lockfile | |
| working-directory: ${{ env.BASE_PATH }} | |
| - name: Build packages (base) | |
| run: | | |
| if pnpm run build:packages; then | |
| echo "Built base packages with root build:packages script." | |
| elif [ -f turbo.json ]; then | |
| echo "Falling back to Turbo package build on base worktree." | |
| pnpm exec turbo run build --filter=./packages/** --concurrency=10 | |
| else | |
| echo "Unable to build base packages: missing build:packages script and turbo.json" >&2 | |
| exit 1 | |
| fi | |
| working-directory: ${{ env.BASE_PATH }} | |
| - name: Measure bundle sizes (base) | |
| run: node scripts/bundle-size-report.mjs --output base.json --packages-dir "${{ env.BASE_PATH }}/packages" | |
| - name: Compare bundle sizes | |
| run: node scripts/bundle-size-report.mjs --compare base.json --current current.json --output stats.txt | |
| - name: Upload bundle size stats artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bundle-size-stats | |
| path: stats.txt | |
| - name: Cleanup base worktree | |
| if: always() | |
| run: | | |
| if [ -n "${BASE_PATH:-}" ] && [ -d "${BASE_PATH}" ]; then | |
| git worktree remove --force "${BASE_PATH}" | |
| fi |