Repository navigation
112 lines (96 loc) · 3.69 KB
/
Copy pathci.yml
File metadata and controls
112 lines (96 loc) · 3.69 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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
# pnpm version comes from the "packageManager" field in package.json.
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v5
with:
node-version-file: .nvmrc
cache: pnpm
- name: Install
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm lint
# Build first: packages that import another workspace package (e.g.
# @tronbrowser/sdk -> @tronbrowser/browser-core) resolve it via its built
# dist, so typecheck/test need the dist present. pnpm builds in topological
# order, so dependencies compile before their dependents.
- name: Build
run: pnpm build
- name: Typecheck
run: pnpm typecheck
- name: Test
run: pnpm test
# dev2 runs services/api on Bun (see Dockerfile). vitest above stays the gate;
# this job runs the API's portable tests under the runtime prod uses and
# boots the built API on Bun against Postgres. Files using vitest-only APIs
# (vi.stubEnv / vi.stubGlobal / vi.mocked ...) are skipped here.
api-bun:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_HOST_AUTH_METHOD: trust # throwaway CI database, no password
ports: ["5432:5432"]
options: >-
--health-cmd "pg_isready -U postgres" --health-interval 2s
--health-timeout 5s --health-retries 20
env:
DATABASE_URL: postgres://postgres@127.0.0.1:5432/postgres
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v5
with:
node-version-file: .nvmrc
cache: pnpm
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.0 # keep in step with BUN_IMAGE in the Dockerfile
- name: Install + build the API
run: |
pnpm install --frozen-lockfile --filter @tronbrowser/api...
pnpm --filter @tronbrowser/browser-core --filter @tronbrowser/agent-runtime --filter @tronbrowser/sdk --filter @tronbrowser/api build
- name: Portable API tests under bun test
working-directory: services/api
run: |
set -e
for f in $(git ls-files 'src/*.test.ts' 'src/*.test.js' | xargs grep -L -E 'vi\.(stub|unstub|mocked|importActual|hoisted|mock\()'); do
echo "::group::bun test $f"; bun test "./$f"; echo "::endgroup::"
done
- name: Migrate + boot the API on Bun
run: |
set -e
# The runner must refuse the legacy SQLite migrations on a Postgres target.
if MIGRATIONS_DIR=packages/storage/migrations bun scripts/db-migrate.mjs; then
echo "db-migrate applied SQLite migrations to Postgres" >&2; exit 1
fi
MIGRATIONS_DIR=packages/storage/migrations-pg bun scripts/db-migrate.mjs
PORT=8090 bun services/api/dist/index.js > api.log 2>&1 &
for i in $(seq 1 30); do curl -fsS http://127.0.0.1:8090/api/healthz && break; sleep 1; done
curl -fsS http://127.0.0.1:8090/api/1/push
curl -fsS http://127.0.0.1:8090/api/store/extensions
cat api.log
# package + release jobs are stubbed until the Chromium build lands in CI.
package:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- run: echo "package stub - implemented later"
release:
runs-on: ubuntu-latest
needs: package
if: startsWith(github.ref, 'refs/tags/v')
steps:
- run: echo "release stub - implemented later"