|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize, reopened] |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +defaults: |
| 15 | + run: |
| 16 | + shell: bash |
| 17 | + |
| 18 | +jobs: |
| 19 | + test: |
| 20 | + # Why Mac and Windows? |
| 21 | + # I can't run electron playwright on ubuntu-latest and |
| 22 | + # Linux support for Dyad is experimental so not as important |
| 23 | + # as Mac + Windows |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + os: [ |
| 28 | + # npm install is very slow |
| 29 | + # { name: "windows-arm", image: "windows-11-arm" }, |
| 30 | + { name: "windows", image: "windows-latest" }, |
| 31 | + { name: "macos", image: "macos-latest" }, |
| 32 | + ] |
| 33 | + shard: [1, 2, 3, 4] |
| 34 | + shardTotal: [4] |
| 35 | + runs-on: ${{ matrix.os.image }} |
| 36 | + steps: |
| 37 | + - name: Checkout code |
| 38 | + uses: actions/checkout@v4 |
| 39 | + - name: Initialize environment |
| 40 | + uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version-file: package.json |
| 43 | + cache: npm |
| 44 | + cache-dependency-path: package-lock.json |
| 45 | + - name: Install node modules |
| 46 | + run: npm ci --no-audit --no-fund --progress=false |
| 47 | + - name: Presubmit check (e.g. lint, format) |
| 48 | + # do not run this on Windows (it fails and not necessary) |
| 49 | + # Only run on shard 1 to avoid redundant execution |
| 50 | + if: contains(matrix.os.name, 'macos') && matrix.shard == 1 |
| 51 | + run: npm run presubmit |
| 52 | + - name: Type-checking |
| 53 | + # do not run this on windows (it's redunant) |
| 54 | + # Only run on shard 1 to avoid redundant execution |
| 55 | + if: contains(matrix.os.name, 'macos') && matrix.shard == 1 |
| 56 | + run: npm run ts |
| 57 | + - name: Unit tests |
| 58 | + # do not run this on windows (it's redunant) |
| 59 | + # Only run on shard 1 to avoid redundant execution |
| 60 | + if: contains(matrix.os.name, 'macos') && matrix.shard == 1 |
| 61 | + run: npm run test |
| 62 | + - name: Setup pnpm |
| 63 | + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 |
| 64 | + with: |
| 65 | + version: latest |
| 66 | + - name: Clone nextjs-template |
| 67 | + run: git clone --depth 1 https://github.com/SFARPak/nextjs-template.git nextjs-template |
| 68 | + - name: Get pnpm store directory |
| 69 | + id: pnpm-cache |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT |
| 73 | + - name: Setup pnpm cache |
| 74 | + uses: actions/cache@v4 |
| 75 | + with: |
| 76 | + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} |
| 77 | + key: ${{ matrix.os.name }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 78 | + restore-keys: | |
| 79 | + ${{ matrix.os.name }}-pnpm-store- |
| 80 | + # Not strictly needed but makes the e2e tests faster (and less flaky) |
| 81 | + - name: Install scaffold dependencies |
| 82 | + run: cd scaffold && pnpm install |
| 83 | + - name: Install nextjs-template dependencies |
| 84 | + run: cd nextjs-template && pnpm install |
| 85 | + - name: Install Chromium browser for Playwright |
| 86 | + run: npx playwright install chromium --with-deps |
| 87 | + - name: Build |
| 88 | + env: |
| 89 | + NODE_OPTIONS: "--max-old-space-size=4096" |
| 90 | + run: npm run pre:e2e |
| 91 | + - name: Prep test server |
| 92 | + run: cd testing/fake-llm-server && npm install && npm run build && cd - |
| 93 | + - name: E2E tests (Shard ${{ matrix.shard }}/4) |
| 94 | + # You can add debug logging to make it easier to see what's failing |
| 95 | + # by adding "DEBUG=pw:browser" in front. |
| 96 | + # Use blob reporter for sharding and merge capabilities |
| 97 | + run: DEBUG=pw:browser npx playwright test --shard=${{ matrix.shard }}/${{ matrix.shardTotal }} |
| 98 | + - name: Upload shard results |
| 99 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 100 | + if: ${{ !cancelled() }} |
| 101 | + with: |
| 102 | + name: blob-report-${{ matrix.os.name }}-shard-${{ matrix.shard }} |
| 103 | + path: blob-report |
| 104 | + retention-days: 1 |
| 105 | + |
| 106 | + merge-reports: |
| 107 | + # Merge reports after playwright-tests, even if some shards have failed |
| 108 | + if: ${{ !cancelled() }} |
| 109 | + needs: [test] |
| 110 | + |
| 111 | + runs-on: ubuntu-latest |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v4 |
| 114 | + - uses: actions/setup-node@v4 |
| 115 | + with: |
| 116 | + node-version: lts/* |
| 117 | + - name: Install dependencies |
| 118 | + run: npm ci --no-audit --no-fund --progress=false |
| 119 | + |
| 120 | + - name: Download blob reports from GitHub Actions Artifacts |
| 121 | + uses: actions/download-artifact@v4 |
| 122 | + with: |
| 123 | + path: all-blob-reports |
| 124 | + pattern: blob-report-* |
| 125 | + merge-multiple: true |
| 126 | + |
| 127 | + - name: Debug - List downloaded blob reports |
| 128 | + run: | |
| 129 | + echo "Contents of all-blob-reports directory:" |
| 130 | + ls -la all-blob-reports/ |
| 131 | + echo "File sizes and details:" |
| 132 | + find all-blob-reports/ -type f -exec ls -lh {} \; || echo "No files found" |
| 133 | +
|
| 134 | + - name: Merge into HTML Report |
| 135 | + run: PLAYWRIGHT_HTML_OUTPUT_DIR=playwright-report npx playwright merge-reports --config=merge.config.ts ./all-blob-reports |
| 136 | + |
| 137 | + - name: Debug - List playwright-report contents |
| 138 | + run: | |
| 139 | + echo "Contents of playwright-report directory:" |
| 140 | + ls -la playwright-report/ || echo "playwright-report directory does not exist" |
| 141 | + echo "Current directory contents:" |
| 142 | + ls -la |
| 143 | +
|
| 144 | + - name: Upload HTML report |
| 145 | + uses: actions/upload-artifact@v4 |
| 146 | + with: |
| 147 | + name: html-report--attempt-${{ github.run_attempt }} |
| 148 | + path: playwright-report |
| 149 | + retention-days: 3 |
0 commit comments