-
Notifications
You must be signed in to change notification settings - Fork 219
291 lines (251 loc) · 8.6 KB
/
build_and_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
name: Build and test PGlite packages
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
pull-requests: write
issues: write
contents: read
on:
workflow_dispatch:
inputs:
message:
description: 'Build PGLite packages'
push:
branches: ['main']
pull_request:
jobs:
stylecheck:
name: Stylecheck
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Stylecheck packages
run: pnpm -r stylecheck
build-and-test-pglite-dependencies:
name: Build and Test PGLite dependencies
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm --filter "pglite^..." build
- name: Typecheck packages
run: pnpm --filter "pglite^..." typecheck
- name: Test packages
run: pnpm --filter "pglite^..." test
build-wasm-postgres:
name: Build PGlite WASM dependencies
uses: ./.github/workflows/build_wasm_postgres.yml
secrets: inherit
build-and-test-pglite:
name: Build and Test PGLite
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./packages/pglite
needs: [build-wasm-postgres, build-and-test-pglite-dependencies]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- name: Download PGlite WASM build artifacts
uses: actions/download-artifact@v4
with:
name: pglite-interim-build-files
path: ./packages/pglite/release
- name: Install dependencies
run: |
pnpm install --frozen-lockfile
pnpm exec playwright install --with-deps
- name: Build dependencies
run: pnpm --filter "pglite^..." build
- name: Typecheck
run: pnpm typecheck
- name: Build
run: pnpm build
- name: Test
run: pnpm test
- name: Test web integrations
# retry on failure as web tests can be flaky
run: pnpm test:web || pnpm test:web || pnpm test:web
- name: Test Deno
run: pnpm test:deno
- name: Pack for distribution
run: pnpm pack
- name: Upload PGlite distribution artifact
id: upload-pglite-dist
uses: actions/upload-artifact@v4
with:
name: pglite-dist
path: ./packages/pglite/dist/*
- name: Upload PGlite package artifact
id: upload-pglite-package
uses: actions/upload-artifact@v4
with:
name: pglite-package
path: ./packages/pglite/electric-sql-pglite-*.tgz
retention-days: 60
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
if: github.event_name == 'pull_request'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Built bundles
- name: Create or update build outputs comment
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
continue-on-error: true
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
- PGlite: ${{ steps.upload-pglite-package.outputs.artifact-url }}
edit-mode: append
build-and-test-pglite-dependents:
name: Build and Test packages dependent on PGlite
runs-on: ubuntu-22.04
needs: [build-and-test-pglite]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Download PGlite build artifacts
uses: actions/download-artifact@v4
with:
name: pglite-dist
path: ./packages/pglite/dist/
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build packages
run: pnpm --filter="...^pglite" build
- name: Typecheck packages
run: pnpm --filter="...^pglite" typecheck
- name: Test packages
run: pnpm --filter="...^pglite" test
publish-website-with-demos:
name: Publish website with demos
runs-on: ubuntu-22.04
needs: [build-and-test-pglite, build-and-test-pglite-dependents]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Download PGlite build artifacts
uses: actions/download-artifact@v4
with:
name: pglite-dist
path: ./packages/pglite/dist/
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build REPL and benchmark packages needed for examples
run: pnpm --filter "@electric-sql/pglite-react" --filter "@electric-sql/pglite-repl" --filter "benchmark" build
- name: Download PGlite web build artifacts
uses: actions/download-artifact@v4
with:
name: pglite-web-build-files
path: /tmp/web
- name: Build demo site
run: |
bash ./cibuild/demo-site.sh
- name: Build docs
working-directory: ./docs
run: |
pnpm run docs:build
cp -r ./.vitepress/dist/* /tmp/web/
- name: Upload Demos to Github artifacts
id: upload-demos
uses: actions/upload-artifact@v4
with:
name: pglite-demos
path: /tmp/web/**
retention-days: 60
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
if: github.event_name == 'pull_request'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Built bundles
- name: Create or update build outputs comment
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
continue-on-error: true
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
- Demos: ${{ steps.upload-demos.outputs.artifact-url }}
edit-mode: append
- name: Deploy website to Netlify
uses: nwtgck/[email protected]
with:
publish-dir: '/tmp/web'
production-branch: master
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: 'Deploy PR${{ github.event.pull_request.id }}: ${{ github.event.pull_request.title }}'
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
timeout-minutes: 1
changesets-release:
if: github.event_name == 'push'
permissions:
contents: write # to create release (changesets/action)
issues: write # to post issue comments (changesets/action)
pull-requests: write # to create pull request (changesets/action)
name: Make a PR or publish
runs-on: ubuntu-latest
needs: [build-wasm-postgres]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
- name: Download PGlite WASM build artifacts
uses: actions/download-artifact@v4
with:
name: pglite-interim-build-files
path: ./packages/pglite/release
- run: pnpm install --frozen-lockfile
- run: pnpm --filter "./packages/**" build
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v1
with:
version: pnpm ci:version
publish: pnpm ci:publish
title: 'chore: publish new package versions'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}