Repository navigation
234 lines (227 loc) · 9.36 KB
/
Copy pathplatform-ci.yml
File metadata and controls
234 lines (227 loc) · 9.36 KB
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
name: Platform CI
on:
pull_request:
branches: [main]
paths:
- 'platform/**'
- 'packages/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
- 'vite.config.ts'
- '.github/workflows/platform-*.yml'
- '.github/scripts/production-baseline.ts'
- '.github/scripts/schema-fixture.mjs'
- '.github/scripts/schema-compat-tests.ts'
- '.github/scripts/postgres-concurrency-tests.ts'
workflow_call:
inputs:
require-schema-compat:
description: Run the production schema-compatibility guard. The production deploy sets this for every trigger.
type: boolean
default: false
permissions: {}
jobs:
build-api-container:
if: github.event_name == 'pull_request'
runs-on: ${{ github.repository == 'voidzero-dev/void' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build API build container
run: docker build --pull --tag void-api-build-container:ci --file platform/packages/api/container/Dockerfile .
lint-build-check:
runs-on: ${{ github.repository == 'voidzero-dev/void' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: voidzero-dev/setup-vp@1b32467adbe183473499fd9d5d372c3ed9641754 # v1.18.0
with:
cache: true
node-version-file: .node-version
- run: vp fmt --check
- run: vp lint
- run: vp run build
- run: vp run --filter './platform/packages/**' build
# After the builds: the type-aware platform lint reads the dashboard's generated
# `.void/tsconfig.json`, which only exists once the dashboard has been built.
- run: vp run lint:platform
# Platform packages only. The framework and the playgrounds are typechecked by ci.yml, and
# the playground typechecks need the playground builds, which this job does not run.
- run: vp run check:platform
# SDK packages too: the deploy workflows run only this job, the dashboard and the
# workers bundle the SDK, and `vp pack` does not typecheck.
- run: vp run check:sdk
test:
runs-on: ${{ github.repository == 'voidzero-dev/void' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
project: [platform-unit, platform-api-integration]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: voidzero-dev/setup-vp@1b32467adbe183473499fd9d5d372c3ed9641754 # v1.18.0
with:
cache: true
node-version-file: .node-version
- name: Install Chromium for native API forms
if: ${{ startsWith(matrix.project, 'platform-api-integration') && github.repository == 'voidzero-dev/void' }}
run: vp exec playwright install chromium
- name: Install Chromium and system dependencies for native API forms
if: ${{ startsWith(matrix.project, 'platform-api-integration') && github.repository != 'voidzero-dev/void' }}
run: vp exec playwright install --with-deps chromium
- run: vp run build
- run: vp run --filter './platform/packages/**' build
- run: vp test run --project '${{ matrix.project }}*'
postgres-concurrency:
runs-on: ${{ github.repository == 'voidzero-dev/void' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 10
permissions:
contents: read
env:
POSTGRES_USER: void_ci
POSTGRES_PASSWORD: void_ci_pass
POSTGRES_DB: void_schema_compat
COMPAT_DATABASE_URL: postgresql://void_ci:void_ci_pass@localhost:5432/void_schema_compat
TZ: UTC
services:
postgres:
image: postgres:18
env:
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.POSTGRES_DB }}
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U $POSTGRES_USER"
--health-interval=5s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: voidzero-dev/setup-vp@1b32467adbe183473499fd9d5d372c3ed9641754 # v1.18.0
with:
cache: true
node-version-file: .node-version
- run: vp run build
- run: vp run --filter './platform/packages/**' build
- name: Create the candidate PostgreSQL schema
run: vp run --filter @voidcloud/api migrate
env:
DATABASE_URL: ${{ env.COMPAT_DATABASE_URL }}
- name: Run candidate PostgreSQL concurrency tests
run: node .github/scripts/postgres-concurrency-tests.ts
# Upgrade a populated previous schema, then run that immutable runtime's tests.
# The prod branch can already be the candidate, so never use it as the baseline.
schema-compat:
if: >-
${{ inputs.require-schema-compat || (github.event_name == 'pull_request'
&& (github.repository == 'voidzero-dev/void' || vars.VOID_PLATFORM_PRODUCTION_REF != '')) }}
runs-on: ${{ github.repository == 'voidzero-dev/void' && 'blacksmith-4vcpu-ubuntu-2404' || 'ubuntu-latest' }}
timeout-minutes: 20
permissions:
contents: read
deployments: read
env:
PRODUCTION_REF: ${{ vars.VOID_PLATFORM_PRODUCTION_REF }}
PRODUCTION_ENVIRONMENT: ${{ vars.VOID_PLATFORM_PRODUCTION_ENV || 'Prod' }}
POSTGRES_USER: void_ci
POSTGRES_PASSWORD: void_ci_pass
POSTGRES_DB: void_schema_compat
COMPAT_DATABASE_URL: postgresql://void_ci:void_ci_pass@localhost:5432/void_schema_compat
TZ: UTC
services:
postgres:
image: postgres:18
env:
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.POSTGRES_DB }}
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U $POSTGRES_USER"
--health-interval=5s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: voidzero-dev/setup-vp@1b32467adbe183473499fd9d5d372c3ed9641754 # v1.18.0
with:
cache: true
node-version-file: .node-version
- name: Resolve the immutable deployed runtime
id: baseline
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
node .github/scripts/production-baseline.ts
cp .github/scripts/schema-fixture.mjs "$RUNNER_TEMP/void-schema-fixture.mjs"
cp .github/scripts/schema-compat-tests.ts "$RUNNER_TEMP/void-schema-compat-tests.ts"
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ steps.baseline.outputs.sha }}
persist-credentials: false
- name: Require platform code in the deployed revision
run: test -d platform/packages/api
- uses: voidzero-dev/setup-vp@1b32467adbe183473499fd9d5d372c3ed9641754 # v1.18.0
with:
cache: true
node-version-file: .node-version
- name: Create and populate the previous schema
run: |
vp run --filter @voidcloud/api migrate
node "$RUNNER_TEMP/void-schema-fixture.mjs" seed
env:
DATABASE_URL: ${{ env.COMPAT_DATABASE_URL }}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: voidzero-dev/setup-vp@1b32467adbe183473499fd9d5d372c3ed9641754 # v1.18.0
with:
cache: true
node-version-file: .node-version
- name: Upgrade the populated database and verify preserved data
run: |
vp run --filter @voidcloud/api migrate
node "$RUNNER_TEMP/void-schema-fixture.mjs" verify
env:
DATABASE_URL: ${{ env.COMPAT_DATABASE_URL }}
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ steps.baseline.outputs.sha }}
persist-credentials: false
- uses: voidzero-dev/setup-vp@1b32467adbe183473499fd9d5d372c3ed9641754 # v1.18.0
with:
cache: true
node-version-file: .node-version
- name: Install Chromium for deployed runtime API forms
if: ${{ github.repository == 'voidzero-dev/void' }}
run: vp exec playwright install chromium
- name: Install Chromium and system dependencies for deployed runtime API forms
if: ${{ github.repository != 'voidzero-dev/void' }}
run: vp exec playwright install --with-deps chromium
- name: Run the deployed runtime against the upgraded schema
run: |
vp run build
vp run --filter './platform/packages/**' build
node "$RUNNER_TEMP/void-schema-compat-tests.ts"
env:
COMPAT_DATABASE_URL: ${{ env.COMPAT_DATABASE_URL }}