|
5 | 5 | types: [created] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - build-and-publish: |
| 8 | + build-and-unit: |
| 9 | + name: Build & Unit Tests |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: read |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v4 |
| 16 | + with: |
| 17 | + fetch-depth: 0 |
| 18 | + |
| 19 | + - name: Setup Node.js |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: 20 |
| 23 | + cache: "npm" |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: npm install |
| 27 | + |
| 28 | + - name: Run unit tests |
| 29 | + run: npm run test:min |
| 30 | + |
| 31 | + - name: Build (prod) |
| 32 | + run: npm run build:all:prod |
| 33 | + |
| 34 | + - name: Upload build artifacts |
| 35 | + uses: actions/upload-artifact@v4 |
| 36 | + with: |
| 37 | + name: build-output |
| 38 | + path: dist/ |
| 39 | + retention-days: 1 |
| 40 | + |
| 41 | + integration-tests: |
| 42 | + name: Integration (${{ matrix.browser }}, Shard ${{ matrix.shard }}/4) |
| 43 | + needs: build-and-unit |
| 44 | + runs-on: ubuntu-latest |
| 45 | + strategy: |
| 46 | + fail-fast: false |
| 47 | + matrix: |
| 48 | + browser: [chromium, firefox] |
| 49 | + shard: [1, 2, 3, 4] |
| 50 | + steps: |
| 51 | + - name: Checkout code |
| 52 | + uses: actions/checkout@v4 |
| 53 | + |
| 54 | + - name: Setup Node.js |
| 55 | + uses: actions/setup-node@v4 |
| 56 | + with: |
| 57 | + node-version: 20 |
| 58 | + cache: "npm" |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: npm install |
| 62 | + |
| 63 | + - name: Download build artifacts |
| 64 | + uses: actions/download-artifact@v4 |
| 65 | + with: |
| 66 | + name: build-output |
| 67 | + path: dist/ |
| 68 | + |
| 69 | + - name: Cache Playwright browsers |
| 70 | + uses: actions/cache@v4 |
| 71 | + id: playwright-cache |
| 72 | + with: |
| 73 | + path: ~/.cache/ms-playwright |
| 74 | + key: playwright-${{ runner.os }}-${{ matrix.browser }}-${{ hashFiles('package-lock.json') }} |
| 75 | + |
| 76 | + - name: Install Playwright browser |
| 77 | + if: steps.playwright-cache.outputs.cache-hit != 'true' |
| 78 | + run: npx playwright install --with-deps ${{ matrix.browser }} |
| 79 | + |
| 80 | + - name: Install Playwright deps only |
| 81 | + if: steps.playwright-cache.outputs.cache-hit == 'true' |
| 82 | + run: npx playwright install-deps ${{ matrix.browser }} |
| 83 | + |
| 84 | + - name: Run integration tests (${{ matrix.browser }}, shard ${{ matrix.shard }}/4) |
| 85 | + run: npx playwright test --project=${{ matrix.browser }} --shard=${{ matrix.shard }}/4 --reporter=list |
| 86 | + |
| 87 | + - name: Upload test results |
| 88 | + if: always() |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: playwright-results-${{ matrix.browser }}-shard-${{ matrix.shard }} |
| 92 | + path: test-results/ |
| 93 | + retention-days: 7 |
| 94 | + if-no-files-found: ignore |
| 95 | + |
| 96 | + publish: |
| 97 | + name: Publish to npm |
| 98 | + needs: [build-and-unit, integration-tests] |
9 | 99 | runs-on: ubuntu-latest |
10 | 100 | permissions: |
11 | 101 | contents: write |
12 | 102 | id-token: write |
13 | 103 | steps: |
14 | | - # Checkout repository |
15 | 104 | - name: Checkout code |
16 | 105 | uses: actions/checkout@v4 |
17 | 106 | with: |
18 | 107 | fetch-depth: 0 |
19 | 108 | token: ${{ secrets.GITHUB_TOKEN }} |
20 | 109 |
|
21 | | - # Set up Node.js with OIDC |
22 | 110 | - name: Setup Node.js |
23 | 111 | uses: actions/setup-node@v4 |
24 | 112 | with: |
25 | 113 | node-version: 20 |
26 | 114 | registry-url: 'https://registry.npmjs.org' |
27 | 115 | cache: "npm" |
28 | 116 |
|
29 | | - # Ensure latest npm for OIDC support |
30 | 117 | - name: Update npm |
31 | 118 | run: npm install -g npm@latest |
32 | 119 |
|
33 | | - # Install dependencies |
34 | 120 | - name: Install dependencies |
35 | 121 | run: npm install |
36 | 122 |
|
37 | | - # Build once (prod) to reuse for integration tests |
38 | | - - name: Build (prod) |
39 | | - run: npm run build:all:prod |
40 | | - |
41 | | - # Install Playwright browsers |
42 | | - - name: Install Playwright browsers |
43 | | - run: npx playwright install --with-deps chromium |
44 | | - |
45 | | - # Run tests |
46 | | - - name: Run tests |
47 | | - run: | |
48 | | - npm run test:min |
49 | | - npx playwright test --reporter=list |
| 123 | + - name: Download build artifacts |
| 124 | + uses: actions/download-artifact@v4 |
| 125 | + with: |
| 126 | + name: build-output |
| 127 | + path: dist/ |
50 | 128 |
|
51 | 129 | # Determine npm tag based on version |
52 | 130 | - name: Determine npm tag |
|
0 commit comments