-
Notifications
You must be signed in to change notification settings - Fork 108
307 lines (274 loc) · 9.68 KB
/
ci.yml
File metadata and controls
307 lines (274 loc) · 9.68 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
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
name: CI
env:
APP_NAME: rtc-node
MACOSX_DEPLOYMENT_TARGET: '10.13'
CARGO_TERM_COLOR: always
permissions:
id-token: write # Required for OIDC
contents: write # Required to create GH releases
pull-requests: write # Required to interact with PRs
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
paths:
- 'packages/**'
- 'examples/**'
- 'package.json'
- 'pnpm-lock.yaml'
- 'REUSE.toml'
- '.github/workflows'
branches:
- main
jobs:
check-changes:
name: Check for changes
runs-on: ubuntu-latest
outputs:
rtc_build: ${{ steps.changes.outputs.rtc_build }}
server_sdk_build: ${{ steps.changes.outputs.server_sdk_build }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v3
id: paths
with:
filters: |
livekit-rtc:
- 'packages/livekit-rtc/**'
server-sdk:
- 'packages/livekit-server-sdk/**'
- name: Store change outputs
id: changes
run: |
echo "rtc_build=${{ steps.paths.outputs.livekit-rtc == 'true' || github.ref == 'refs/heads/main' }}" >> $GITHUB_OUTPUT
echo "server_sdk_build=${{ steps.paths.outputs.server-sdk == 'true' || github.ref == 'refs/heads/main' }}" >> $GITHUB_OUTPUT
lint:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- name: Use Node.js 24
uses: actions/setup-node@v6
with:
node-version: 24 # NPM v11.5.1 or later is required for OIDC, which ships with node v24
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Lint
run: pnpm lint
- name: Prettier
run: pnpm format:check
reuse:
name: REUSE-3.2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: fsfe/reuse-action@v5
test:
name: Test
strategy:
matrix:
node-version: [20, 22, 24, latest]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install
# RTC tests will be ran after they are built, because builds are so slow
- name: Test livekit-server-sdk (Node)
run: pnpm --filter="livekit-server-sdk" test
- name: Test livekit-server-sdk (Browser)
run: pnpm --filter="livekit-server-sdk" test:browser
- name: Test env livekit-server-sdk (Edge Runtime)
run: pnpm --filter="livekit-server-sdk" test:edge
build:
if: ${{ needs.check-changes.outputs.rtc_build == 'true' }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-large
platform: macos
target: x86_64-apple-darwin
macosx_deployment_target: '10.15'
- os: macos-15
platform: macos
target: aarch64-apple-darwin
macosx_deployment_target: '11.0'
- os: windows-latest
platform: windows
target: x86_64-pc-windows-msvc
- os: ubuntu-latest
platform: linux
target: x86_64-unknown-linux-gnu
build_image: sameli/manylinux_2_28_x86_64_cuda_12.3
- os: ubuntu-24.04-arm
platform: linux
target: aarch64-unknown-linux-gnu
build_image: quay.io/pypa/manylinux_2_28_aarch64
name: stable - ${{ matrix.target }} - node@20
runs-on: ${{ matrix.os }}
env:
RUST_BACKTRACE: full
needs: check-changes
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v6
if: ${{ !matrix.docker }}
with:
node-version: 24
cache: pnpm
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: '25.1'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
packages/livekit-rtc/.cargo-cache
packages/livekit-rtc/target/
key: ${{ matrix.target }}-cargo-${{ matrix.os }}
- name: Install dependencies
run: pnpm install
# on linux, we'll also run tests after building. for the e2e suite, this would
# only run on the main repo, and not forks
- name: Build & test (Linux)
if: ${{ matrix.platform == 'linux' }}
env:
LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
run: |
PROTOC_PATH=$(which protoc)
HOST_UID=$(id -u)
HOST_GID=$(id -g)
docker run --rm \
-e HOST_UID=$HOST_UID \
-e HOST_GID=$HOST_GID \
-e TARGET=${{ matrix.target }} \
-v $PWD:/workspace \
-v $PROTOC_PATH:/tmp/protoc:ro \
-w /workspace \
${{ matrix.build_image }} \
bash -lc '
set -euo pipefail
uname -a
cp /tmp/protoc /usr/local/bin/protoc
chmod +x /usr/local/bin/protoc
yum install -y openssl-devel libX11-devel mesa-libGL-devel libXext-devel libva-devel libdrm-devel clang clang-devel
yum install -y gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-libstdc++-devel libstdc++-devel
source /opt/rh/gcc-toolset-12/enable
gcc --version
g++ --version
clang --version
clang++ --version
curl -fsSL https://rpm.nodesource.com/setup_20.x | bash -
yum install -y nodejs --setopt=nodesource-nodejs.module_hotfixes=1
npm install --global pnpm
groupadd -g "$HOST_GID" hostgroup 2>/dev/null || true
useradd -m -u "$HOST_UID" -g "$HOST_GID" hostuser 2>/dev/null || true
su - hostuser -c "
set -euo pipefail
export RUST_BACKTRACE=full
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
export PATH=\$HOME/.cargo/bin:\$PATH
source /opt/rh/gcc-toolset-12/enable
export CC=clang
export CXX=clang++
TOOLCHAIN_ROOT=/opt/rh/gcc-toolset-12/root/usr
export CFLAGS=\"--gcc-toolchain=\$TOOLCHAIN_ROOT\"
export CXXFLAGS=\"--gcc-toolchain=\$TOOLCHAIN_ROOT\"
cd /workspace
CI=true pnpm install
cd packages/livekit-rtc
pnpm build --target $TARGET
cd ../..
pnpm --filter "./packages/livekit-server-sdk" build
export LIVEKIT_URL=${{ secrets.LIVEKIT_URL }}
export LIVEKIT_API_KEY=${{ secrets.LIVEKIT_API_KEY }}
export LIVEKIT_API_SECRET=${{ secrets.LIVEKIT_API_SECRET }}
pnpm --filter "@livekit/rtc-node" test
"
'
- name: Build (macOS)
if: ${{ matrix.platform == 'macos' }}
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
run: cd packages/livekit-rtc && pnpm build --target ${{ matrix.target }}
- name: Build (Windows)
if: ${{ matrix.platform == 'windows' }}
run: cd packages/livekit-rtc && pnpm build --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
if: github.event_name != 'pull-request'
with:
name: bindings-${{ matrix.target }}
path: packages/livekit-rtc/src/napi/${{ env.APP_NAME }}.*.node
if-no-files-found: error
release:
needs: build
if: github.ref == 'refs/heads/main'
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build server SDK
run: pnpm --filter=livekit-server-sdk build
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: packages/livekit-rtc/artifacts
- name: Move artifacts
run: pnpm artifacts
working-directory: packages/livekit-rtc
- name: List packages
run: ls -R ./packages/livekit-rtc/npm
shell: bash
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: pnpm ci:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Server SDK Docs
if: steps.changesets.outputs.published == 'true'
run: pnpm --filter=livekit-server-sdk build-docs
- name: S3 Upload Server SDK Docs
if: steps.changesets.outputs.published == 'true'
run: aws s3 cp packages/livekit-server-sdk/docs/ s3://livekit-docs/server-sdk-js --recursive
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DOCS_DEPLOY_AWS_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DOCS_DEPLOY_AWS_API_SECRET }}
AWS_DEFAULT_REGION: 'us-east-1'