|
| 1 | +name: Build and test PGlite packages |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + message: |
| 11 | + description: 'Build PGLite packages' |
| 12 | + push: |
| 13 | + branches: ['main'] |
| 14 | + pull_request: |
| 15 | + |
| 16 | +jobs: |
| 17 | + stylecheck: |
| 18 | + name: Stylecheck |
| 19 | + runs-on: ubuntu-22.04 |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + - uses: pnpm/action-setup@v4 |
| 23 | + with: |
| 24 | + version: 8 |
| 25 | + - uses: actions/setup-node@v4 |
| 26 | + with: |
| 27 | + node-version: 20 |
| 28 | + cache: pnpm |
| 29 | + - name: Install dependencies |
| 30 | + run: pnpm install --frozen-lockfile |
| 31 | + - name: Stylecheck packages |
| 32 | + run: pnpm -r stylecheck |
| 33 | + |
| 34 | + build-wasm-postgres: |
| 35 | + name: Build PGlite WASM dependencies |
| 36 | + uses: ./.github/workflows/build_wasm_postgres.yml |
| 37 | + secrets: inherit |
| 38 | + |
| 39 | + build-and-test-pglite: |
| 40 | + name: Build and Test PGLite |
| 41 | + runs-on: ubuntu-22.04 |
| 42 | + defaults: |
| 43 | + run: |
| 44 | + working-directory: ./packages/pglite |
| 45 | + needs: [stylecheck, build-wasm-postgres] |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - uses: pnpm/action-setup@v4 |
| 49 | + with: |
| 50 | + version: 8 |
| 51 | + - uses: actions/setup-node@v4 |
| 52 | + with: |
| 53 | + node-version: 20 |
| 54 | + cache: pnpm |
| 55 | + |
| 56 | + - name: Download PGlite WASM build artifacts |
| 57 | + uses: actions/download-artifact@v4 |
| 58 | + with: |
| 59 | + name: pglite-interim-build-files |
| 60 | + path: ./packages/pglite/release |
| 61 | + |
| 62 | + - name: Install dependencies |
| 63 | + run: | |
| 64 | + pnpm install --frozen-lockfile |
| 65 | + pnpm exec playwright install --with-deps |
| 66 | +
|
| 67 | + - name: Typecheck |
| 68 | + run: pnpm typecheck |
| 69 | + |
| 70 | + - name: Build |
| 71 | + run: pnpm build |
| 72 | + |
| 73 | + - name: Test |
| 74 | + run: pnpm test |
| 75 | + |
| 76 | + - name: Pack for distribution |
| 77 | + run: pnpm pack |
| 78 | + |
| 79 | + - name: Upload PGlite distribution artifact |
| 80 | + id: upload-pglite-dist |
| 81 | + uses: actions/upload-artifact@v4 |
| 82 | + with: |
| 83 | + name: pglite-dist |
| 84 | + path: ./packages/pglite/dist/* |
| 85 | + |
| 86 | + - name: Upload PGlite package artifact |
| 87 | + id: upload-pglite-package |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: pglite-package |
| 91 | + path: ./packages/pglite/electric-sql-pglite-*.tgz |
| 92 | + retention-days: 60 |
| 93 | + |
| 94 | + - name: Find Comment |
| 95 | + uses: peter-evans/find-comment@v3 |
| 96 | + id: fc |
| 97 | + if: github.event_name == 'pull_request' |
| 98 | + with: |
| 99 | + issue-number: ${{ github.event.pull_request.number }} |
| 100 | + comment-author: 'github-actions[bot]' |
| 101 | + body-includes: Built bundles |
| 102 | + |
| 103 | + - name: Create or update build outputs comment |
| 104 | + uses: peter-evans/create-or-update-comment@v4 |
| 105 | + if: github.event_name == 'pull_request' |
| 106 | + with: |
| 107 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 108 | + issue-number: ${{ github.event.pull_request.number }} |
| 109 | + body: | |
| 110 | + - PGlite: ${{ steps.upload-pglite-package.outputs.artifact-url }} |
| 111 | + edit-mode: append |
| 112 | + |
| 113 | + build-and-test-pglite-dependents: |
| 114 | + name: Build and Test packages dependent on PGlite |
| 115 | + runs-on: ubuntu-22.04 |
| 116 | + needs: [stylecheck, build-and-test-pglite] |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v4 |
| 119 | + - uses: pnpm/action-setup@v4 |
| 120 | + with: |
| 121 | + version: 8 |
| 122 | + - uses: actions/setup-node@v4 |
| 123 | + with: |
| 124 | + node-version: 20 |
| 125 | + cache: pnpm |
| 126 | + |
| 127 | + - name: Download PGlite build artifacts |
| 128 | + uses: actions/download-artifact@v4 |
| 129 | + with: |
| 130 | + name: pglite-dist |
| 131 | + path: ./packages/pglite/dist/ |
| 132 | + |
| 133 | + - name: Install dependencies |
| 134 | + run: pnpm install --frozen-lockfile |
| 135 | + |
| 136 | + - name: Build packages |
| 137 | + run: pnpm --filter="...^pglite" build |
| 138 | + |
| 139 | + - name: Typecheck packages |
| 140 | + run: pnpm --filter="...^pglite" typecheck |
| 141 | + |
| 142 | + - name: Test packages |
| 143 | + run: pnpm --filter="...^pglite" test |
| 144 | + |
| 145 | + publish-website-with-demos: |
| 146 | + name: Publish website with demos |
| 147 | + runs-on: ubuntu-22.04 |
| 148 | + needs: [build-and-test-pglite, build-and-test-pglite-dependents] |
| 149 | + steps: |
| 150 | + - uses: actions/checkout@v4 |
| 151 | + - uses: pnpm/action-setup@v4 |
| 152 | + with: |
| 153 | + version: 8 |
| 154 | + - uses: actions/setup-node@v4 |
| 155 | + with: |
| 156 | + node-version: 20 |
| 157 | + cache: pnpm |
| 158 | + |
| 159 | + - name: Download PGlite build artifacts |
| 160 | + uses: actions/download-artifact@v4 |
| 161 | + with: |
| 162 | + name: pglite-dist |
| 163 | + path: ./packages/pglite/dist/ |
| 164 | + |
| 165 | + - name: Install dependencies |
| 166 | + run: pnpm install --frozen-lockfile |
| 167 | + |
| 168 | + - name: Build REPL and benchmark packages needed for examples |
| 169 | + run: pnpm --filter "@electric-sql/pglite-repl" --filter "benchmark" build |
| 170 | + |
| 171 | + - name: Download PGlite web build artifacts |
| 172 | + uses: actions/download-artifact@v4 |
| 173 | + with: |
| 174 | + name: pglite-web-build-files |
| 175 | + path: /tmp/web |
| 176 | + |
| 177 | + - name: Build demo site |
| 178 | + run: | |
| 179 | + bash ./cibuild.sh demo-site |
| 180 | +
|
| 181 | + - name: Build docs |
| 182 | + working-directory: ./docs |
| 183 | + run: | |
| 184 | + pnpm run docs:build |
| 185 | + cp -r ./.vitepress/dist/* /tmp/web/ |
| 186 | +
|
| 187 | + - name: Upload Demos to Github artifacts |
| 188 | + id: upload-demos |
| 189 | + uses: actions/upload-artifact@v4 |
| 190 | + with: |
| 191 | + name: pglite-demos |
| 192 | + path: /tmp/web/** |
| 193 | + retention-days: 60 |
| 194 | + |
| 195 | + - name: Find Comment |
| 196 | + uses: peter-evans/find-comment@v3 |
| 197 | + id: fc |
| 198 | + if: github.event_name == 'pull_request' |
| 199 | + with: |
| 200 | + issue-number: ${{ github.event.pull_request.number }} |
| 201 | + comment-author: 'github-actions[bot]' |
| 202 | + body-includes: Built bundles |
| 203 | + |
| 204 | + - name: Create or update build outputs comment |
| 205 | + uses: peter-evans/create-or-update-comment@v4 |
| 206 | + if: github.event_name == 'pull_request' |
| 207 | + with: |
| 208 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 209 | + issue-number: ${{ github.event.pull_request.number }} |
| 210 | + body: | |
| 211 | + - Demos: ${{ steps.upload-demos.outputs.artifact-url }} |
| 212 | + edit-mode: append |
| 213 | + |
| 214 | + - name: Deploy website to Netlify |
| 215 | + uses: nwtgck/actions-netlify@v3.0 |
| 216 | + with: |
| 217 | + publish-dir: '/tmp/web' |
| 218 | + production-branch: master |
| 219 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 220 | + deploy-message: 'Deploy PR${{ github.event.pull_request.id }}: ${{ github.event.pull_request.title }}' |
| 221 | + env: |
| 222 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 223 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 224 | + timeout-minutes: 1 |
0 commit comments