3434 container : null
3535 runs-on : ${{ matrix.runner }}
3636 container : ${{ matrix.container }}
37-
37+ env :
38+ CARGO_TARGET_DIR : ${{ github.workspace }}/target
3839 steps :
3940 - name : Find Git ref
4041 env :
5354 with :
5455 ref : ${{ env.GIT_REF }}
5556 - uses : dsherret/rust-toolchain-file@v1
57+ - name : Cache Rust dependencies
58+ uses : Swatinem/rust-cache@v2
59+ with :
60+ workspaces : ${{ github.workspace }}
61+ shared-key : spacetimedb
62+ cache-on-failure : true
63+ cache-all-crates : true
64+ cache-workspace-crates : true
65+
5666 - uses : actions/setup-dotnet@v4
5767 with :
5868 global-json-file : global.json
@@ -71,21 +81,25 @@ jobs:
7181 if : runner.os == 'Windows'
7282 run : choco install psql -y --no-progress
7383 shell : powershell
84+ - name : Build crates
85+ run : cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
7486 - name : Start Docker daemon
7587 if : runner.os == 'Linux'
7688 run : /usr/local/bin/start-docker.sh
7789
7890 - name : Build and start database (Linux)
7991 if : runner.os == 'Linux'
80- run : docker compose up -d
92+ run : |
93+ # Our .dockerignore omits `target`, which our CI Dockerfile needs.
94+ rm .dockerignore
95+ docker compose -f .github/docker-compose.yml up -d
8196 - name : Build and start database (Windows)
8297 if : runner.os == 'Windows'
8398 run : |
8499 # Fail properly if any individual command fails
85100 $ErrorActionPreference = 'Stop'
86101 $PSNativeCommandUseErrorActionPreference = $true
87102
88- cargo build -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
89103 Start-Process target/debug/spacetimedb-cli.exe -ArgumentList 'start --pg-port 5432'
90104 cd modules
91105 # the sdk-manifests on windows-latest are messed up, so we need to update them
@@ -101,7 +115,7 @@ jobs:
101115 run : python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams
102116 - name : Stop containers (Linux)
103117 if : always() && runner.os == 'Linux'
104- run : docker compose down
118+ run : docker compose -f .github/docker-compose.yml down
105119
106120 test :
107121 name : Test Suite
@@ -110,6 +124,8 @@ jobs:
110124 image : localhost:5000/spacetimedb-ci:latest
111125 options : >-
112126 --privileged
127+ env :
128+ CARGO_TARGET_DIR : ${{ github.workspace }}/target
113129 steps :
114130 - name : Find Git ref
115131 env :
@@ -129,6 +145,13 @@ jobs:
129145 ref : ${{ env.GIT_REF }}
130146
131147 - uses : dsherret/rust-toolchain-file@v1
148+ - name : Cache Rust dependencies
149+ uses : Swatinem/rust-cache@v2
150+ with :
151+ workspaces : ${{ github.workspace }}
152+ shared-key : spacetimedb
153+ # Let the smoketests job save the cache since it builds the most things
154+ save-if : false
132155
133156 - uses : actions/setup-dotnet@v3
134157 with :
@@ -179,13 +202,23 @@ jobs:
179202 image : localhost:5000/spacetimedb-ci:latest
180203 options : >-
181204 --privileged
205+ env :
206+ CARGO_TARGET_DIR : ${{ github.workspace }}/target
182207 steps :
183208 - name : Checkout sources
184209 uses : actions/checkout@v3
185210
186211 - uses : dsherret/rust-toolchain-file@v1
187212 - run : echo ::add-matcher::.github/workflows/rust_matcher.json
188213
214+ - name : Cache Rust dependencies
215+ uses : Swatinem/rust-cache@v2
216+ with :
217+ workspaces : ${{ github.workspace }}
218+ shared-key : spacetimedb
219+ # Let the smoketests job save the cache since it builds the most things
220+ save-if : false
221+
189222 - uses : actions/setup-dotnet@v3
190223 with :
191224 global-json-file : global.json
@@ -222,12 +255,22 @@ jobs:
222255 image : localhost:5000/spacetimedb-ci:latest
223256 options : >-
224257 --privileged
258+ env :
259+ CARGO_TARGET_DIR : ${{ github.workspace }}/target
225260 steps :
226261 - uses : actions/checkout@v3
227262
228263 - uses : dsherret/rust-toolchain-file@v1
229264 - run : echo ::add-matcher::.github/workflows/rust_matcher.json
230265
266+ - name : Cache Rust dependencies
267+ uses : Swatinem/rust-cache@v2
268+ with :
269+ workspaces : ${{ github.workspace }}
270+ shared-key : spacetimedb
271+ # Let the smoketests job save the cache since it builds the most things
272+ save-if : false
273+
231274 - name : Run bindgen tests
232275 run : cargo test -p spacetimedb-codegen
233276
@@ -408,6 +451,8 @@ jobs:
408451 image : localhost:5000/spacetimedb-ci:latest
409452 options : >-
410453 --privileged
454+ env :
455+ CARGO_TARGET_DIR : ${{ github.workspace }}/target
411456 steps :
412457 - name : Find Git ref
413458 env :
@@ -451,6 +496,14 @@ jobs:
451496
452497 - uses : dsherret/rust-toolchain-file@v1
453498
499+ - name : Cache Rust dependencies
500+ uses : Swatinem/rust-cache@v2
501+ with :
502+ workspaces : ${{ github.workspace }}
503+ shared-key : spacetimedb
504+ # Let the smoketests job save the cache since it builds the most things
505+ save-if : false
506+
454507 - name : Check for docs change
455508 run : |
456509 cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md
0 commit comments