forked from clockworklabs/SpacetimeDB
-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (145 loc) · 6.27 KB
/
typescript-test.yml
File metadata and controls
173 lines (145 loc) · 6.27 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
name: TypeScript - Tests
on:
push:
branches:
- master
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('sha-{0}', github.sha) }}
cancel-in-progress: true
jobs:
build-and-test:
runs-on: spacetimedb-new-runner-2
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- uses: pnpm/action-setup@v4
with:
run_install: true
- name: Get pnpm store directory
shell: bash
working-directory: crates/bindings-typescript
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Build module library and SDK
working-directory: crates/bindings-typescript
run: pnpm build
- name: Run module library and SDK tests
working-directory: crates/bindings-typescript
run: pnpm test
# - name: Extract SpacetimeDB branch name from file
# id: extract-branch
# run: |
# # Define the path to the branch file
# BRANCH_FILE=".github/spacetimedb-branch.txt"
# # Default to master if file doesn't exist
# if [ ! -f "$BRANCH_FILE" ]; then
# echo "::notice::No SpacetimeDB branch file found, using 'master'"
# echo "branch=master" >> $GITHUB_OUTPUT
# exit 0
# fi
# # Read and trim whitespace from the file
# branch=$(cat "$BRANCH_FILE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# # Fallback to master if empty
# if [ -z "$branch" ]; then
# echo "::warning::SpacetimeDB branch file is empty, using 'master'"
# branch="master"
# fi
# echo "branch=$branch" >> $GITHUB_OUTPUT
# echo "Using SpacetimeDB branch from file: $branch"
- name: Install Rust toolchain
uses: dsherret/rust-toolchain-file@v1
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: ${{ github.workspace }}
shared-key: spacetimedb
# Let the main CI job save the cache since it builds the most things
save-if: false
prefix-key: v1
# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
# ChatGPT suspects that this could be due to different build invocations using the same target dir,
# and this makes sense to me because we only see it in this job where we mix `cargo build -p` with
# `cargo build --manifest-path` (which apparently build different dependency trees).
# However, we've been unable to fix it so... /shrug
- name: Check v8 outputs
run: |
find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
cargo clean -p v8 || true
cargo build -p v8
fi
- name: Install SpacetimeDB CLI from the local checkout
run: |
cargo install --force --path crates/cli --locked --message-format=short
cargo install --force --path crates/standalone --locked --message-format=short
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
rm -f $CARGO_HOME/bin/spacetime
ln -s $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
# Clear any existing information
spacetime server clear -y
# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
# This may be due to reusing CARGO_TARGET_DIR while mixing different build strategies (`cargo install` and `cargo build -p`).
# However, this fix seems to work.
- name: Check v8 outputs
run: |
find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
cargo clean -p v8 || true
cargo build -p v8
fi
- name: Generate client bindings
working-directory: templates/chat-react-ts
run: |
pnpm generate
- name: Check for changes
working-directory: templates/chat-react-ts
run: |
"${GITHUB_WORKSPACE}"/tools/check-diff.sh src/module_bindings || {
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
exit 1
}
# - name: Start SpacetimeDB
# run: |
# spacetime start &
# disown
# - name: Publish module to SpacetimeDB
# working-directory: SpacetimeDB/templates/quickstart-chat-typescript/spacetimedb
# run: |
# spacetime logout && spacetime login --server-issued-login local
# spacetime publish -s local quickstart-chat -c -y
# - name: Publish module to SpacetimeDB
# working-directory: SpacetimeDB/templates/quickstart-chat-typescript/spacetimedb
# run: |
# spacetime logs quickstart-chat
- name: Check that quickstart-chat builds
working-directory: templates/chat-react-ts
run: pnpm build
- name: Check that templates build
working-directory: templates/
run: pnpm -r --filter "./**" run build
- name: Check that subdirectories build
working-directory: crates/bindings-typescript
run: pnpm -r --filter "./**" run build
# - name: Run quickstart-chat tests
# working-directory: examples/quickstart-chat
# run: pnpm test
#
# # Run this step always, even if the previous steps fail
# - name: Print rows in the user table
# if: always()
# run: spacetime sql quickstart-chat "SELECT * FROM user"