Skip to content

Commit fdd4618

Browse files
authored
CI - Test that quickstart-chat builds (#197)
* Test quickstart-chat in CI * fix? * ignore diffs containing SpacetimeDB commit * prettier config * fix? * [REVERT THIS TEST COMMIT] add diff to module bindings * revert previous test commit * [REVERT THIS TEST COMMIT] introduce a typechecking error * revert previous test commit * tiny review --------- Co-authored-by: Zeke Foppa <[email protected]>
1 parent 6ea0c6f commit fdd4618

File tree

2 files changed

+70
-63
lines changed

2 files changed

+70
-63
lines changed

.github/workflows/test.yml

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -70,71 +70,77 @@ jobs:
7070
# echo "branch=$branch" >> $GITHUB_OUTPUT
7171
# echo "Using SpacetimeDB branch from file: $branch"
7272

73-
# - name: Checkout SpacetimeDB
74-
# uses: actions/checkout@v4
75-
# with:
76-
# repository: clockworklabs/SpacetimeDB
77-
# ref: ${{ steps.extract-branch.outputs.branch }}
78-
# path: SpacetimeDB
79-
80-
# - name: Install Rust toolchain
81-
# uses: dtolnay/rust-toolchain@stable
82-
83-
# - name: Cache Rust dependencies
84-
# uses: Swatinem/rust-cache@v2
85-
# with:
86-
# workspaces: SpacetimeDB/modules/quickstart-chat
87-
# shared-key: quickstart-chat-test
88-
89-
# - name: Install SpacetimeDB CLI from the local checkout
73+
- name: Checkout SpacetimeDB
74+
uses: actions/checkout@v4
75+
with:
76+
repository: clockworklabs/SpacetimeDB
77+
# ref: ${{ steps.extract-branch.outputs.branch }}
78+
path: SpacetimeDB
79+
80+
- name: Install Rust toolchain
81+
uses: dtolnay/rust-toolchain@stable
82+
83+
- name: Cache Rust dependencies
84+
uses: Swatinem/rust-cache@v2
85+
with:
86+
workspaces: SpacetimeDB/modules/quickstart-chat
87+
shared-key: quickstart-chat-test
88+
89+
- name: Install SpacetimeDB CLI from the local checkout
90+
run: |
91+
cargo install --force --path SpacetimeDB/crates/cli --locked --message-format=short
92+
cargo install --force --path SpacetimeDB/crates/standalone --locked --message-format=short
93+
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
94+
rm -f $HOME/.cargo/bin/spacetime
95+
ln -s $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
96+
# Clear any existing information
97+
spacetime server clear -y
98+
env:
99+
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
100+
CARGO_TARGET_DIR: SpacetimeDB/modules/quickstart-chat/target
101+
102+
- name: Generate client bindings
103+
working-directory: SpacetimeDB/modules/quickstart-chat
104+
run: |
105+
spacetime generate --lang typescript --out-dir ../../../examples/quickstart-chat/src/module_bindings
106+
pnpm lint --write
107+
108+
- name: Check for changes
109+
run: |
110+
# This was copied from SpacetimeDB/tools/check-diff.sh.
111+
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
112+
# version, which would make this `git diff` check very brittle if included.
113+
PATTERN='^// This was generated using spacetimedb cli version.*'
114+
if ! git diff --exit-code --ignore-matching-lines="$PATTERN" -- examples/quickstart-chat/src/module_bindings; then
115+
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
116+
exit 1
117+
fi
118+
119+
# - name: Start SpacetimeDB
90120
# run: |
91-
# cargo install --force --path SpacetimeDB/crates/cli --locked --message-format=short
92-
# cargo install --force --path SpacetimeDB/crates/standalone --locked --message-format=short
93-
# # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
94-
# rm $HOME/.cargo/bin/spacetime || echo "haven't run on this host before"
95-
# ln -s $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
96-
# # Clear any existing information
97-
# spacetime server clear -y
98-
# env:
99-
# # Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
100-
# CARGO_TARGET_DIR: SpacetimeDB/modules/quickstart-chat/target
101-
102-
# - name: Generate client bindings
121+
# spacetime start &
122+
# disown
123+
124+
# - name: Publish module to SpacetimeDB
103125
# working-directory: SpacetimeDB/modules/quickstart-chat
104126
# run: |
105-
# spacetime generate --lang typescript --out-dir ../../../examples/quickstart-chat/src/module_bindings
106-
# pnpm lint --write
127+
# spacetime logout && spacetime login --server-issued-login local
128+
# spacetime publish -s local quickstart-chat -c -y
107129

108-
# - name: Check for changes
130+
# - name: Publish module to SpacetimeDB
131+
# working-directory: SpacetimeDB/modules/quickstart-chat
109132
# run: |
110-
# git diff --exit-code examples/quickstart-chat/src/module_bindings || {
111-
# echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
112-
# exit 1
113-
# - name: Start SpacetimeDB
114-
# run: |
115-
# spacetime start &
116-
# disown
117-
#
118-
# - name: Publish module to SpacetimeDB
119-
# working-directory: SpacetimeDB/modules/quickstart-chat
120-
# run: |
121-
# spacetime logout && spacetime login --server-issued-login local
122-
# spacetime publish -s local quickstart-chat -c -y
123-
#
124-
# - name: Check if SpacetimeDB process is running
125-
# run: |
126-
# echo "Currently running spacetime processes:"
127-
# pgrep -laf spacetime || echo "No spacetime process found."
128-
#
129-
# - name: Publish module to SpacetimeDB
130-
# working-directory: SpacetimeDB/modules/quickstart-chat
131-
# run: |
132-
# spacetime logs quickstart-chat
133-
#
134-
# - name: Run all tests recursively
135-
# run: pnpm test
136-
#
137-
# # Run this step always, even if the previous steps fail
138-
# - name: Print rows in the user table
139-
# if: always()
140-
# run: spacetime sql quickstart-chat "SELECT * FROM user"
133+
# spacetime logs quickstart-chat
134+
135+
- name: Check that quickstart-chat builds
136+
working-directory: examples/quickstart-chat
137+
run: pnpm build
138+
139+
# - name: Run quickstart-chat tests
140+
# working-directory: examples/quickstart-chat
141+
# run: pnpm test
142+
#
143+
# # Run this step always, even if the previous steps fail
144+
# - name: Print rows in the user table
145+
# if: always()
146+
# run: spacetime sql quickstart-chat "SELECT * FROM user"

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
pnpm-lock.yaml
33
dist
44
target
5+
/.github

0 commit comments

Comments
 (0)