Skip to content

Commit d799470

Browse files
committed
Merge remote-tracking branch 'origin/master' into kim/ws/fragmented-writes
2 parents d9b6736 + 96a1ad4 commit d799470

168 files changed

Lines changed: 19036 additions & 111 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: TypeScript - Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18
21+
22+
- uses: pnpm/action-setup@v4
23+
with:
24+
version: 9.7
25+
run_install: true
26+
27+
- name: Get pnpm store directory
28+
working-directory: sdks/typescript
29+
shell: bash
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
33+
- uses: actions/cache@v4
34+
name: Setup pnpm cache
35+
with:
36+
path: ${{ env.STORE_PATH }}
37+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pnpm-store-
40+
41+
- name: Lint
42+
working-directory: sdks/typescript
43+
run: pnpm lint

.github/workflows/test.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: TypeScript - Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
jobs:
10+
compile-and-test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18
21+
22+
- uses: pnpm/action-setup@v4
23+
with:
24+
version: 9.7
25+
run_install: true
26+
27+
- name: Get pnpm store directory
28+
shell: bash
29+
working-directory: sdks/typescript
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
33+
- uses: actions/cache@v4
34+
name: Setup pnpm cache
35+
with:
36+
path: ${{ env.STORE_PATH }}
37+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pnpm-store-
40+
41+
- name: Compile
42+
working-directory: sdks/typescript
43+
run: pnpm compile
44+
45+
- name: Run sdk tests
46+
working-directory: sdks/typescript/packages/sdk
47+
run: pnpm test
48+
49+
# - name: Extract SpacetimeDB branch name from file
50+
# id: extract-branch
51+
# run: |
52+
# # Define the path to the branch file
53+
# BRANCH_FILE=".github/spacetimedb-branch.txt"
54+
55+
# # Default to master if file doesn't exist
56+
# if [ ! -f "$BRANCH_FILE" ]; then
57+
# echo "::notice::No SpacetimeDB branch file found, using 'master'"
58+
# echo "branch=master" >> $GITHUB_OUTPUT
59+
# exit 0
60+
# fi
61+
62+
# # Read and trim whitespace from the file
63+
# branch=$(cat "$BRANCH_FILE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
64+
65+
# # Fallback to master if empty
66+
# if [ -z "$branch" ]; then
67+
# echo "::warning::SpacetimeDB branch file is empty, using 'master'"
68+
# branch="master"
69+
# fi
70+
71+
# echo "branch=$branch" >> $GITHUB_OUTPUT
72+
# echo "Using SpacetimeDB branch from file: $branch"
73+
74+
- name: Install Rust toolchain
75+
uses: dtolnay/rust-toolchain@stable
76+
77+
- name: Cache Rust dependencies
78+
uses: Swatinem/rust-cache@v2
79+
with:
80+
workspaces: modules/quickstart-chat
81+
shared-key: quickstart-chat-test
82+
83+
- name: Install SpacetimeDB CLI from the local checkout
84+
run: |
85+
cargo install --force --path crates/cli --locked --message-format=short
86+
cargo install --force --path crates/standalone --locked --message-format=short
87+
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
88+
rm -f $HOME/.cargo/bin/spacetime
89+
ln -s $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
90+
# Clear any existing information
91+
spacetime server clear -y
92+
env:
93+
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
94+
CARGO_TARGET_DIR: modules/quickstart-chat/target
95+
96+
- name: Generate client bindings
97+
working-directory: modules/quickstart-chat
98+
run: |
99+
spacetime generate --lang typescript --out-dir ../../sdks/typescript/examples/quickstart-chat/src/module_bindings
100+
cd ../../sdks/typescript
101+
pnpm lint --write
102+
103+
- name: Check for changes
104+
working-directory: sdks/typescript
105+
run: |
106+
# This was copied from SpacetimeDB/tools/check-diff.sh.
107+
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
108+
# version, which would make this `git diff` check very brittle if included.
109+
PATTERN='^// This was generated using spacetimedb cli version.*'
110+
if ! git diff --exit-code --ignore-matching-lines="$PATTERN" -- examples/quickstart-chat/src/module_bindings; then
111+
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
112+
exit 1
113+
fi
114+
115+
# - name: Start SpacetimeDB
116+
# run: |
117+
# spacetime start &
118+
# disown
119+
120+
# - name: Publish module to SpacetimeDB
121+
# working-directory: SpacetimeDB/modules/quickstart-chat
122+
# run: |
123+
# spacetime logout && spacetime login --server-issued-login local
124+
# spacetime publish -s local quickstart-chat -c -y
125+
126+
# - name: Publish module to SpacetimeDB
127+
# working-directory: SpacetimeDB/modules/quickstart-chat
128+
# run: |
129+
# spacetime logs quickstart-chat
130+
131+
- name: Check that quickstart-chat builds
132+
working-directory: sdks/typescript/examples/quickstart-chat
133+
run: pnpm build
134+
135+
# - name: Run quickstart-chat tests
136+
# working-directory: examples/quickstart-chat
137+
# run: pnpm test
138+
#
139+
# # Run this step always, even if the previous steps fail
140+
# - name: Print rows in the user table
141+
# if: always()
142+
# run: spacetime sql quickstart-chat "SELECT * FROM user"

0 commit comments

Comments
 (0)