-
Notifications
You must be signed in to change notification settings - Fork 368
228 lines (202 loc) · 8.5 KB
/
Copy pathts_tests.yml
File metadata and controls
228 lines (202 loc) · 8.5 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
name: TS tests
on:
push:
branches: ['main']
paths-ignore:
- 'website/**'
- '**/README.md'
- 'integration-tests/**'
pull_request:
paths-ignore:
- 'website/**'
- '**/README.md'
- 'integration-tests/**'
permissions:
contents: read
packages: read
jobs:
detect_affected_workspaces:
name: Detect affected TS workspaces
runs-on: blacksmith-2vcpu-ubuntu-2404
outputs:
package_directories: ${{ steps.detect.outputs.package_directories }}
packages_with_shared_sync_service: ${{ steps.detect.outputs.packages_with_shared_sync_service }}
packages_without_shared_sync_service: ${{ steps.detect.outputs.packages_without_shared_sync_service }}
example_directories: ${{ steps.detect.outputs.example_directories }}
has_packages: ${{ steps.detect.outputs.has_packages }}
has_shared_sync_service_packages: ${{ steps.detect.outputs.has_shared_sync_service_packages }}
has_non_shared_sync_service_packages: ${{ steps.detect.outputs.has_non_shared_sync_service_packages }}
has_examples: ${{ steps.detect.outputs.has_examples }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
- name: Detect affected workspaces
id: detect
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
run: node scripts/ci/affected-workspaces.mjs
typecheck_packages:
name: Build and typecheck ${{ matrix.package_dir }}
needs: [detect_affected_workspaces]
if: ${{ needs.detect_affected_workspaces.outputs.has_packages == 'true' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
strategy:
fail-fast: false
matrix:
package_dir: ${{ fromJson(needs.detect_affected_workspaces.outputs.package_directories) }}
defaults:
run:
working-directory: ${{ matrix.package_dir }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
cache: 'pnpm'
- run: pnpm --filter "$(jq -r .name package.json)..." install --frozen-lockfile
- run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build
- run: pnpm run typecheck
- name: Run shape stream static analysis
if: ${{ matrix.package_dir == 'packages/typescript-client' }}
run: pnpm run analyze:shape-stream -- --fail-on-findings
ensure_sync_service_image:
needs: [detect_affected_workspaces]
if: ${{ needs.detect_affected_workspaces.outputs.has_shared_sync_service_packages == 'true' }}
# Reusable workflow pushes to GHCR; scope packages: write here since it can't
# exceed the caller token (top-level stays read, see #4450).
permissions:
contents: read
packages: write
uses: ./.github/workflows/ensure_sync_service_image.yml
build_and_test_packages_with_shared_sync_service:
name: 'Test ${{ matrix.package_dir }} w/ sync-service'
needs: [detect_affected_workspaces, ensure_sync_service_image]
if: ${{ needs.detect_affected_workspaces.outputs.has_shared_sync_service_packages == 'true' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
package_dir: ${{ fromJson(needs.detect_affected_workspaces.outputs.packages_with_shared_sync_service) }}
defaults:
run:
working-directory: ${{ matrix.package_dir }}
env:
ELECTRIC_IMAGE: ${{ needs.ensure_sync_service_image.outputs.image }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
cache: pnpm
- name: Install Node dependencies
run: pnpm --filter "$(jq -r .name package.json)..." install --frozen-lockfile
- name: Build Node dependencies, if any
run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build
- name: Run Postgres, Electric and nginx for the subsequent test suite
working-directory: packages/sync-service/dev
run: |
docker compose -f docker-compose.yml -f docker-compose-electric.yml up --wait postgres electric nginx
- name: Run tests with coverage
run: pnpm run coverage --run
- name: Upload coverage reports to CodeCov
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: typescript,unit-tests,${{ matrix.package_dir }}
- name: Upload test results to CodeCov
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706
if: ${{ !cancelled() }}
env:
DUMMY_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}-dummy
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: typescript,unit-tests,${{ matrix.package_dir }}
files: ./junit/test-report.junit.xml
build_and_test_packages_without_shared_sync_service:
name: 'Test ${{ matrix.package_dir }}'
needs: [detect_affected_workspaces]
if: ${{ needs.detect_affected_workspaces.outputs.has_non_shared_sync_service_packages == 'true' }}
runs-on: blacksmith-4vcpu-ubuntu-2404
# agents-runtime integration tests boot and migrate an isolated Electric Agents
# backend, then run with V8 coverage enabled. On CI this can exceed 10m.
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
package_dir: ${{ fromJson(needs.detect_affected_workspaces.outputs.packages_without_shared_sync_service) }}
defaults:
run:
working-directory: ${{ matrix.package_dir }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
cache: pnpm
- name: Install Node dependencies
run: |
package_name="$(jq -r .name package.json)"
if [ "$package_name" = "@electric-ax/agents-runtime" ]; then
pnpm --filter "$package_name..." --filter "@electric-ax/agents-server..." install --frozen-lockfile
else
pnpm --filter "$package_name..." install --frozen-lockfile
fi
- name: Build Node dependencies, if any
run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build
- name: Run tests with coverage
run: pnpm run coverage --run
- name: Upload coverage reports to CodeCov
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: typescript,unit-tests,${{ matrix.package_dir }}
- name: Upload test results to CodeCov
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706
if: ${{ !cancelled() }}
env:
DUMMY_COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}-dummy
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
flags: typescript,unit-tests,${{ matrix.package_dir }}
files: ./junit/test-report.junit.xml
check_and_build_examples:
name: Check and build ${{ matrix.example_folder }}
needs:
[
detect_affected_workspaces,
build_and_test_packages_with_shared_sync_service,
build_and_test_packages_without_shared_sync_service,
]
if: ${{ always() && needs.detect_affected_workspaces.outputs.has_examples == 'true' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
runs-on: blacksmith-2vcpu-ubuntu-2404
strategy:
fail-fast: false
matrix:
example_folder: ${{ fromJson(needs.detect_affected_workspaces.outputs.example_directories) }}
defaults:
run:
working-directory: ${{ matrix.example_folder }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version-file: '.tool-versions'
cache: pnpm
- run: pnpm --filter "$(jq -r .name package.json)..." --filter @electric-examples/shared install --frozen-lockfile
- run: pnpm -r --filter "$(jq '.name' -r package.json)^..." build
- run: pnpm --if-present run prepare
- run: pnpm --if-present run typecheck
- run: pnpm --if-present run build
- run: pnpm --if-present run test --run