|
32 | 32 | timeout-minutes: 120 |
33 | 33 | env: |
34 | 34 | CARGO_TARGET_DIR: ${{ github.workspace }}/target |
| 35 | + SPACETIMEDB_CPP_DIR: ${{ github.workspace }}/crates/bindings-cpp |
35 | 36 | steps: |
36 | 37 | - name: Find Git ref |
37 | 38 | env: |
@@ -79,10 +80,36 @@ jobs: |
79 | 80 | with: |
80 | 81 | run_install: true |
81 | 82 |
|
| 83 | + # Install emscripten for C++ module compilation tests. |
| 84 | + - name: Install emscripten (Linux) |
| 85 | + if: runner.os == 'Linux' |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + git clone https://github.com/emscripten-core/emsdk.git ~/emsdk |
| 89 | + cd ~/emsdk |
| 90 | + ./emsdk install 4.0.21 |
| 91 | + ./emsdk activate 4.0.21 |
| 92 | +
|
| 93 | + - name: Install emscripten (Windows) |
| 94 | + if: runner.os == 'Windows' |
| 95 | + shell: pwsh |
| 96 | + run: | |
| 97 | + git clone https://github.com/emscripten-core/emsdk.git $env:USERPROFILE\emsdk |
| 98 | + cd $env:USERPROFILE\emsdk |
| 99 | + .\emsdk install 4.0.21 |
| 100 | + .\emsdk activate 4.0.21 |
| 101 | +
|
82 | 102 | - name: Install psql (Windows) |
83 | 103 | if: runner.os == 'Windows' |
84 | | - run: choco install psql -y --no-progress |
85 | | - shell: powershell |
| 104 | + shell: pwsh |
| 105 | + run: | |
| 106 | + # Fail properly if any individual command fails |
| 107 | + $ErrorActionPreference = 'Stop' |
| 108 | + $PSNativeCommandUseErrorActionPreference = $true |
| 109 | + choco install psql -y --no-progress |
| 110 | + # Check for existence, since `choco` doesn't seem to fail the step if it fails to install.. |
| 111 | + # See https://github.com/clockworklabs/SpacetimeDB/pull/4399 for more background. |
| 112 | + Get-Command psql |
86 | 113 |
|
87 | 114 | - name: Update dotnet workloads |
88 | 115 | if: runner.os == 'Windows' |
@@ -122,137 +149,34 @@ jobs: |
122 | 149 | - name: Install cargo-nextest |
123 | 150 | uses: taiki-e/install-action@nextest |
124 | 151 |
|
125 | | - - name: Run smoketests |
126 | | - # --test-threads=1 eliminates contention in the C# tests where they fight over bindings |
127 | | - # build artifacts. |
128 | | - # It also seemed to improve performance a fair amount (11m -> 6m) |
129 | | - run: cargo ci smoketests -- --test-threads=1 |
130 | | - |
131 | | - smoketests-python: |
132 | | - needs: [lints] |
133 | | - name: Smoketests (Python Legacy) (${{matrix.name}}) |
134 | | - strategy: |
135 | | - matrix: |
136 | | - include: |
137 | | - - name: Linux |
138 | | - runner: spacetimedb-new-runner-2 |
139 | | - smoketest_args: --docker |
140 | | - - name: Windows |
141 | | - runner: windows-latest |
142 | | - smoketest_args: --no-build-cli |
143 | | - runs-on: ${{ matrix.runner }} |
144 | | - timeout-minutes: 120 |
145 | | - env: |
146 | | - CARGO_TARGET_DIR: ${{ github.workspace }}/target |
147 | | - steps: |
148 | | - - name: Find Git ref |
149 | | - env: |
150 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
151 | | - shell: bash |
152 | | - run: | |
153 | | - PR_NUMBER="${{ github.event.inputs.pr_number || null }}" |
154 | | - if test -n "${PR_NUMBER}"; then |
155 | | - GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" |
156 | | - else |
157 | | - GIT_REF="${{ github.ref }}" |
158 | | - fi |
159 | | - echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" |
160 | | - - name: Checkout sources |
161 | | - uses: actions/checkout@v4 |
162 | | - with: |
163 | | - ref: ${{ env.GIT_REF }} |
164 | | - - uses: dsherret/rust-toolchain-file@v1 |
165 | | - - name: Set default rust toolchain |
166 | | - run: rustup default $(rustup show active-toolchain | cut -d' ' -f1) |
167 | | - - name: Cache Rust dependencies |
168 | | - uses: Swatinem/rust-cache@v2 |
169 | | - with: |
170 | | - workspaces: ${{ github.workspace }} |
171 | | - shared-key: spacetimedb |
172 | | - cache-on-failure: false |
173 | | - cache-all-crates: true |
174 | | - cache-workspace-crates: true |
175 | | - prefix-key: v1 |
176 | | - |
177 | | - # This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a. |
178 | | - # ChatGPT suspects that this could be due to different build invocations using the same target dir, |
179 | | - # and this makes sense to me because we only see it in this job where we mix `cargo build -p` with |
180 | | - # `cargo build --manifest-path` (which apparently build different dependency trees). |
181 | | - # However, we've been unable to fix it so... /shrug |
182 | | - - name: Check v8 outputs |
| 152 | + # --test-threads=1 eliminates contention in the C# tests where they fight over bindings |
| 153 | + # build artifacts. |
| 154 | + # It also seemed to improve performance a fair amount (11m -> 6m) |
| 155 | + - name: Run smoketests (Linux) |
| 156 | + if: runner.os == 'Linux' |
183 | 157 | shell: bash |
184 | 158 | run: | |
185 | | - find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true |
186 | | - if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then |
187 | | - echo "Could not find v8 output file librusty_v8.a; rebuilding manually." |
188 | | - cargo clean -p v8 || true |
189 | | - cargo build -p v8 |
| 159 | + if [ -f ~/emsdk/emsdk_env.sh ]; then |
| 160 | + source ~/emsdk/emsdk_env.sh |
190 | 161 | fi |
| 162 | + cargo ci smoketests -- --test-threads=1 |
191 | 163 |
|
192 | | - - uses: actions/setup-dotnet@v4 |
193 | | - with: |
194 | | - global-json-file: global.json |
195 | | - |
196 | | - - name: Override NuGet packages |
197 | | - shell: bash |
198 | | - run: | |
199 | | - dotnet pack -c Release crates/bindings-csharp/BSATN.Runtime |
200 | | - dotnet pack -c Release crates/bindings-csharp/Runtime |
201 | | - cd sdks/csharp |
202 | | - ./tools~/write-nuget-config.sh ../.. |
203 | | -
|
204 | | - # nodejs and pnpm are required for the typescript quickstart smoketest |
205 | | - - name: Set up Node.js |
206 | | - uses: actions/setup-node@v4 |
207 | | - with: |
208 | | - node-version: 22 |
209 | | - |
210 | | - - uses: pnpm/action-setup@v4 |
211 | | - with: |
212 | | - run_install: true |
213 | | - |
214 | | - - name: Install psql (Windows) |
| 164 | + # Due to Emscripten PATH issues this was separated to make sure OpenSSL still builds correctly |
| 165 | + - name: Run smoketests (Windows) |
215 | 166 | if: runner.os == 'Windows' |
216 | | - run: choco install psql -y --no-progress |
217 | | - shell: powershell |
218 | | - |
219 | | - - name: Build crates |
220 | | - run: cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update |
221 | | - |
222 | | - - name: Build and start database (Linux) |
223 | | - if: runner.os == 'Linux' |
| 167 | + shell: pwsh |
224 | 168 | run: | |
225 | | - # Our .dockerignore omits `target`, which our CI Dockerfile needs. |
226 | | - rm .dockerignore |
227 | | - docker compose -f .github/docker-compose.yml up -d |
| 169 | + if (Test-Path "$env:USERPROFILE\emsdk\emsdk_env.ps1") { |
| 170 | + & "$env:USERPROFILE\emsdk\emsdk_env.ps1" | Out-Null |
| 171 | + } |
| 172 | + cargo ci smoketests -- --test-threads=1 |
228 | 173 |
|
229 | | - - name: Build and start database (Windows) |
230 | | - if: runner.os == 'Windows' |
| 174 | + - name: Check for changes |
231 | 175 | run: | |
232 | | - # Fail properly if any individual command fails |
233 | | - $ErrorActionPreference = 'Stop' |
234 | | - $PSNativeCommandUseErrorActionPreference = $true |
235 | | -
|
236 | | - Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432' |
237 | | - cd modules |
238 | | - # the sdk-manifests on windows-latest are messed up, so we need to update them |
239 | | - dotnet workload config --update-mode manifests |
240 | | - dotnet workload update |
241 | | -
|
242 | | - - uses: actions/setup-python@v5 |
243 | | - with: { python-version: "3.12" } |
244 | | - if: runner.os == 'Windows' |
245 | | - |
246 | | - - name: Install python deps |
247 | | - run: python -m pip install -r smoketests/requirements.txt |
248 | | - |
249 | | - - name: Run Python smoketests |
250 | | - # Note: clear_database and replication only work in private |
251 | | - run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams |
252 | | - |
253 | | - - name: Stop containers (Linux) |
254 | | - if: always() && runner.os == 'Linux' |
255 | | - run: docker compose -f .github/docker-compose.yml down |
| 176 | + tools/check-diff.sh crates/smoketests || { |
| 177 | + echo 'Error: There is a diff in the smoketests directory.' |
| 178 | + exit 1 |
| 179 | + } |
256 | 180 |
|
257 | 181 | test: |
258 | 182 | needs: [lints] |
@@ -806,6 +730,12 @@ jobs: |
806 | 730 | key: Unity-${{ github.head_ref }} |
807 | 731 | restore-keys: Unity- |
808 | 732 |
|
| 733 | + - name: Login to DockerHub |
| 734 | + uses: docker/login-action@v2 |
| 735 | + with: |
| 736 | + username: ${{ vars.DOCKERHUB_USERNAME }} |
| 737 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 738 | + |
809 | 739 | - name: Run Unity tests |
810 | 740 | uses: game-ci/unity-test-runner@v4 |
811 | 741 | with: |
@@ -916,14 +846,15 @@ jobs: |
916 | 846 | exit 1 |
917 | 847 | } |
918 | 848 |
|
919 | | - - name: Check client-api bindings are up to date |
920 | | - working-directory: sdks/csharp |
921 | | - run: | |
922 | | - bash tools~/gen-client-api.sh |
923 | | - "${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || { |
924 | | - echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.' |
925 | | - exit 1 |
926 | | - } |
| 849 | + # TODO: Re-enable this once csharp is using the v2 ws api. |
| 850 | + # - name: Check client-api bindings are up to date |
| 851 | + # working-directory: sdks/csharp |
| 852 | + # run: | |
| 853 | + # bash tools~/gen-client-api.sh |
| 854 | + # "${GITHUB_WORKSPACE}"/tools/check-diff.sh src/SpacetimeDB/ClientApi || { |
| 855 | + # echo 'Error: Client API bindings are dirty. Please run `sdks/csharp/tools~/gen-client-api.sh`.' |
| 856 | + # exit 1 |
| 857 | + # } |
927 | 858 |
|
928 | 859 | - name: Start SpacetimeDB |
929 | 860 | run: | |
@@ -1130,3 +1061,59 @@ jobs: |
1130 | 1061 | fi |
1131 | 1062 |
|
1132 | 1063 | echo "No Python smoketest changes detected." |
| 1064 | +
|
| 1065 | + smoketests_mod_rs_complete: |
| 1066 | + name: Check smoketests/mod.rs is complete |
| 1067 | + runs-on: ubuntu-latest |
| 1068 | + permissions: |
| 1069 | + contents: read |
| 1070 | + env: |
| 1071 | + CARGO_TARGET_DIR: ${{ github.workspace }}/target |
| 1072 | + steps: |
| 1073 | + - name: Find Git ref |
| 1074 | + env: |
| 1075 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 1076 | + shell: bash |
| 1077 | + run: | |
| 1078 | + PR_NUMBER="${{ github.event.inputs.pr_number || null }}" |
| 1079 | + if test -n "${PR_NUMBER}"; then |
| 1080 | + GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" |
| 1081 | + else |
| 1082 | + GIT_REF="${{ github.ref }}" |
| 1083 | + fi |
| 1084 | + echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" |
| 1085 | + - name: Checkout sources |
| 1086 | + uses: actions/checkout@v4 |
| 1087 | + with: |
| 1088 | + ref: ${{ env.GIT_REF }} |
| 1089 | + - uses: dsherret/rust-toolchain-file@v1 |
| 1090 | + - name: Set default rust toolchain |
| 1091 | + run: rustup default $(rustup show active-toolchain | cut -d' ' -f1) |
| 1092 | + - name: Cache Rust dependencies |
| 1093 | + uses: Swatinem/rust-cache@v2 |
| 1094 | + with: |
| 1095 | + workspaces: ${{ github.workspace }} |
| 1096 | + shared-key: spacetimedb |
| 1097 | + cache-on-failure: false |
| 1098 | + cache-all-crates: true |
| 1099 | + cache-workspace-crates: true |
| 1100 | + prefix-key: v1 |
| 1101 | + |
| 1102 | + # This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a. |
| 1103 | + # ChatGPT suspects that this could be due to different build invocations using the same target dir, |
| 1104 | + # and this makes sense to me because we only see it in this job where we mix `cargo build -p` with |
| 1105 | + # `cargo build --manifest-path` (which apparently build different dependency trees). |
| 1106 | + # However, we've been unable to fix it so... /shrug |
| 1107 | + - name: Check v8 outputs |
| 1108 | + shell: bash |
| 1109 | + run: | |
| 1110 | + find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true |
| 1111 | + if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then |
| 1112 | + echo "Could not find v8 output file librusty_v8.a; rebuilding manually." |
| 1113 | + cargo clean -p v8 || true |
| 1114 | + cargo build -p v8 |
| 1115 | + fi |
| 1116 | +
|
| 1117 | + - name: Verify crates/smoketests/tests/smoketests/mod.rs lists all entries |
| 1118 | + run: | |
| 1119 | + cargo ci smoketests check-mod-list |
0 commit comments