-
Notifications
You must be signed in to change notification settings - Fork 13
350 lines (328 loc) · 11.8 KB
/
tests.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
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- ready_for_review
env:
GHJK_VERSION: "7f63fb7"
PYTHON_VERSION: "3.8"
DENO_VERSION: "1.39.0"
RUST_BACKTRACE: "full"
RUST_LOG: "info,swc_ecma_codegen=off,tracing::span=off"
jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
website:
- '.github/workflows/tests.yml'
- 'website/**'
meta-cli:
- '.github/workflows/tests.yml'
- 'libs/**'
- 'meta-cli/**'
- 'Cargo.lock'
typegate:
- '.github/workflows/tests.yml'
- 'libs/**'
- 'typegate/**'
- 'meta-cli/**'
- 'Cargo.lock'
full:
- '.github/workflows/tests.yml'
- 'libs/**'
- 'typegate/**'
- 'typegraph/**'
- 'meta-cli/**'
- 'Cargo.lock'
rust:
- '.github/workflows/tests.yml'
- 'libs/**'
- 'Cargo.lock'
outputs:
website: ${{ steps.filter.outputs.website }}
meta-cli: ${{ steps.filter.outputs.meta-cli }}
typegate: ${{ steps.filter.outputs.typegate }}
full: ${{ steps.filter.outputs.full }}
rust: ${{ steps.filter.outputs.rust }}
test-pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
# use custom shared key to share cache across jobs
# default prefix includes job-id otherwise
shared-key: ${{ runner.os }}-rust-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- uses: metatypedev/setup-ghjk@55eb03992e3c1c268b8784046b1c09f01f90c0f0
- shell: bash
run: |
cd website
pnpm install --frozen-lockfile
cd ..
cd dev-tools/vscode-metatype-support
pnpm install --frozen-lockfile
cd ../..
deno cache --import-map typegate/import_map.json typegate/src/main.ts typegate/tests/utils/mod.ts
- uses: pre-commit/action@v3.0.0
test-website:
needs: changes
if: ${{ needs.changes.outputs.website == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Cache deno dir
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
key: deno-mac-${{ hashFiles('**/deno.lock') }}
- uses: metatypedev/setup-ghjk@55eb03992e3c1c268b8784046b1c09f01f90c0f0
- name: Cache .venv dir
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- run: |
python3 -m venv .venv
source .venv/bin/activate
poetry install --no-root
cd website
pnpm install --frozen-lockfile
pnpm lint
pnpm build
test-meta-cli-compat:
needs: changes
if: ${{ needs.changes.outputs.meta-cli == 'true' }}
runs-on: "${{ matrix.os }}"
strategy:
matrix:
include:
- os: macos-latest
activate: "source .venv/bin/activate"
#- os: windows-latest
# activate: '.venv\Scripts\activate.bat'
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Cache deno dir
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
key: deno-mac-${{ hashFiles('**/deno.lock') }}
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-rust-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache .venv dir
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- uses: metatypedev/setup-ghjk@55eb03992e3c1c268b8784046b1c09f01f90c0f0
- shell: bash
env:
WASM_FILE: target/debug/typegraph_core.wasm
run: |
python3 -m venv .venv
${{ matrix.activate }}
cd typegraph/python
poetry install --no-root
cd ../..
poetry install --no-root
deno cache --import-map typegate/import_map.json typegate/src/main.ts typegate/tests/utils/mod.ts
cargo build -p typegraph_core --target wasm32-unknown-unknown --target-dir target/wasm
mkdir -p $(dirname $WASM_FILE)
wasm-opt -Oz target/wasm/wasm32-unknown-unknown/debug/typegraph_core.wasm -o $WASM_FILE.opt
wasm-tools component new $WASM_FILE.opt -o $WASM_FILE
rm -rf typegraph/python/typegraph/gen
poetry run python -m wasmtime.bindgen $WASM_FILE --out-dir typegraph/python/typegraph/gen
cargo run --locked --package meta-cli -- --help
cargo test --locked --package meta-cli
test-docker:
needs: changes
if: ${{ needs.changes.outputs.typegate == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: scherermichael-oss/action-has-permission@master
id: check
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
if: steps.check.outputs.has-permission
with:
registry: docker.io
username: zifeo
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build with cache (internal)
uses: docker/build-push-action@v5
if: steps.check.outputs.has-permission
with:
file: dev/Dockerfile
platforms: linux/amd64
push: false
cache-from: type=registry,ref=docker.io/zifeo/metatype-cache:ci
cache-to: type=registry,ref=docker.io/zifeo/metatype-cache:ci,mode=max
- name: Build without cache (external)
uses: docker/build-push-action@v5
if: "! steps.check.outputs.has-permission"
with:
file: dev/Dockerfile
platforms: linux/amd64
push: false
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/typegate:latest
test-full:
needs: changes
if: ${{ needs.changes.outputs.full == 'true' }}
runs-on:
- self-hosted # https://check-jsonschema.readthedocs.io/en/latest/faq.html#using-self-hosted-runners
- custom-ubuntu-large
timeout-minutes: 60
services:
redis:
image: bitnami/redis:7.0
env:
REDIS_PASSWORD: password
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: postgres:15
env:
POSTGRES_DB: db
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
minio:
image: bitnami/minio:2022
env:
MINIO_REGION_NAME: local
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: password
MINIO_DEFAULT_BUCKETS: "bucket:none"
ports:
- "9000:9000"
- "9001:9001"
env:
DENO_DIR: deno-dir
steps:
- uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1
- uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ runner.os }}-rust-${{ hashFiles('**/rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Cache deno dir
uses: actions/cache@v3
with:
path: ${{ env.DENO_DIR }}
key: deno-${{ hashFiles('**/deno.lock') }}
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache .venv dir
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/poetry.lock') }}
- uses: metatypedev/setup-ghjk@55eb03992e3c1c268b8784046b1c09f01f90c0f0
- shell: bash
env:
WASM_FILE: target/debug/typegraph_core.wasm
run: |
sudo apt update
sudo apt install -y --no-install-recommends gcc-multilib pkg-config libssl-dev libclang-dev perl make
python3 -m venv .venv
source .venv/bin/activate
poetry install --no-root
deno cache --import-map typegate/import_map.json typegate/src/main.ts typegate/tests/utils/mod.ts
cargo build -p typegraph_core --target wasm32-unknown-unknown --target-dir target/wasm
mkdir -p $(dirname $WASM_FILE)
wasm-opt -Oz target/wasm/wasm32-unknown-unknown/debug/typegraph_core.wasm -o $WASM_FILE.opt
wasm-tools component new $WASM_FILE.opt -o $WASM_FILE
rm -rf typegraph/deno/src/gen
jco transpile $WASM_FILE -o typegraph/deno/src/gen
deno run -A typegraph/deno/dev/fix-declarations.ts
rm -rf typegraph/python/typegraph/gen
poetry run python -m wasmtime.bindgen $WASM_FILE --out-dir typegraph/python/typegraph/gen
# from old test-typegraph-core
# test in native rust, not in wasm for a future rust SDK
# without --tests, the --doc is causing a link error "syntax error in VERSION script"
cargo test --locked --package typegraph_core --tests
# from old test-meta-cli
cargo run --locked --package meta-cli -- --help
cargo test --locked --package meta-cli
# from old test-libs
cargo test --locked --exclude meta-cli --exclude typegate --exclude typegraph_engine --exclude typegraph_core --workspace
deno run -A dev/update.ts --cache-only || deno run -A dev/update.ts --cache-only
cargo build -p meta-cli
cargo build -p xtask # xtask and meta-cli are used by the test suite
deno run -A dev/test.ts --threads 1 -- --coverage=coverage
deno --unstable coverage ./coverage --lcov > coverage.lcov
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.lcov
fail_ci_if_error: true
test-lsp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- uses: metatypedev/setup-ghjk@55eb03992e3c1c268b8784046b1c09f01f90c0f0
- shell: bash
run: |
cd dev-tools/ts-language-server
deno run -A dev/generate-grammar-wasm.ts
deno test -A --coverage=coverage
deno --unstable coverage ./coverage --lcov > coverage.lcov
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./dev-tools/ts-language-server/coverage.lcov
fail_ci_if_error: true