Skip to content

Commit 0f78add

Browse files
Merge master into tyler/spacetime-json-docs
Resolves conflict in spacetime_config.rs: master added r#gen keyword escaping (Rust 2024) to generate-inheritance test assertions, but this branch removed generate inheritance entirely, so those assertions are correctly absent.
2 parents 5a2cdb1 + c5743cf commit 0f78add

314 files changed

Lines changed: 9290 additions & 3498 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/package.yml

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ on:
44
push:
55
tags:
66
- '**'
7-
branches:
8-
- master
9-
- release/*
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
1011

1112
jobs:
1213
build-cli:
14+
if: ${{ !(startsWith(github.ref, 'refs/tags/') && matrix.target == 'x86_64-pc-windows-msvc') }}
1315
strategy:
1416
fail-fast: false
1517
matrix:
@@ -85,3 +87,89 @@ jobs:
8587
source_dir: build
8688
endpoint: https://nyc3.digitaloceanspaces.com
8789
destination_dir: ${{ steps.extract_branch.outputs.branch }}
90+
91+
build-cli-windows-signed:
92+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
93+
name: Build and sign CLI for x86_64 Windows
94+
runs-on: [self-hosted, windows, signing]
95+
environment: codesign
96+
concurrency:
97+
group: codesign-${{ github.ref }}
98+
cancel-in-progress: false
99+
100+
steps:
101+
- name: Checkout
102+
uses: actions/checkout@v3
103+
104+
- name: Install Rust
105+
uses: dsherret/rust-toolchain-file@v1
106+
107+
- name: Install rust target
108+
run: rustup target add x86_64-pc-windows-msvc
109+
110+
- name: Compile
111+
run: |
112+
cargo build --release --target x86_64-pc-windows-msvc -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
113+
114+
- name: Write certificate file
115+
shell: powershell
116+
env:
117+
DIGICERT_CERT_B64: ${{ secrets.DIGICERT_CERT_B64 }}
118+
run: |
119+
[IO.File]::WriteAllBytes("digicert.crt", [Convert]::FromBase64String($env:DIGICERT_CERT_B64))
120+
121+
- name: Sign binaries
122+
shell: powershell
123+
env:
124+
DIGICERT_KEYPAIR_ALIAS: ${{ secrets.DIGICERT_KEYPAIR_ALIAS }}
125+
run: |
126+
$ErrorActionPreference = 'Stop'
127+
$targetDir = Join-Path $env:GITHUB_WORKSPACE 'target\x86_64-pc-windows-msvc\release'
128+
$certFile = Join-Path $env:GITHUB_WORKSPACE 'digicert.crt'
129+
130+
$signtool = Get-Command signtool.exe -ErrorAction Stop
131+
132+
$files = @(
133+
(Join-Path $targetDir 'spacetimedb-update.exe'),
134+
(Join-Path $targetDir 'spacetimedb-cli.exe'),
135+
(Join-Path $targetDir 'spacetimedb-standalone.exe')
136+
)
137+
138+
foreach ($file in $files) {
139+
& $signtool.Path sign /csp "DigiCert Signing Manager KSP" /kc $env:DIGICERT_KEYPAIR_ALIAS /f $certFile /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $file
140+
& $signtool.Path verify /v /pa $file
141+
}
142+
143+
- name: Package (windows)
144+
shell: powershell
145+
run: |
146+
$ErrorActionPreference = 'Stop'
147+
New-Item -ItemType Directory -Force -Path build | Out-Null
148+
$releaseDir = Join-Path $env:GITHUB_WORKSPACE 'target\x86_64-pc-windows-msvc\release'
149+
150+
Copy-Item (Join-Path $releaseDir 'spacetimedb-update.exe') (Join-Path $env:GITHUB_WORKSPACE 'build\spacetimedb-update-x86_64-pc-windows-msvc.exe')
151+
Compress-Archive -Force -Path @(
152+
(Join-Path $releaseDir 'spacetimedb-cli.exe'),
153+
(Join-Path $releaseDir 'spacetimedb-standalone.exe')
154+
) -DestinationPath (Join-Path $env:GITHUB_WORKSPACE 'build\spacetime-x86_64-pc-windows-msvc.zip')
155+
156+
- name: Extract branch name
157+
shell: powershell
158+
run: |
159+
$ErrorActionPreference = 'Stop'
160+
$branch = $env:GITHUB_HEAD_REF
161+
if ([string]::IsNullOrEmpty($branch)) {
162+
$branch = $env:GITHUB_REF -replace '^refs/heads/', ''
163+
}
164+
"branch=$branch" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
165+
id: extract_branch
166+
167+
- name: Upload to DO Spaces
168+
uses: shallwefootball/s3-upload-action@master
169+
with:
170+
aws_key_id: ${{ secrets.AWS_KEY_ID }}
171+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY}}
172+
aws_bucket: ${{ vars.AWS_BUCKET }}
173+
source_dir: build
174+
endpoint: https://nyc3.digitaloceanspaces.com
175+
destination_dir: ${{ steps.extract_branch.outputs.branch }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,6 @@ nul
264264
# AI agent config
265265
.codex
266266
.claude
267+
268+
# Any local file
269+
*.local

.rustfmt.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
max_width = 120
2-
edition = "2021"
2+
style_edition = "2021"
3+
edition = "2024"

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ debug = true
107107

108108
[workspace.package]
109109
version = "2.0.3"
110-
edition = "2021"
110+
edition = "2024"
111111
# update rust-toolchain.toml too!
112112
rust-version = "1.93.0"
113113

crates/auth/src/identity.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ impl TryInto<SpacetimeIdentityClaims> for IncomingClaims {
115115

116116
let computed_identity = Identity::from_claims(&self.issuer, &self.subject);
117117
// If an identity is provided, it must match the computed identity.
118-
if let Some(token_identity) = self.identity {
119-
if token_identity != computed_identity {
120-
return Err(anyhow::anyhow!(
118+
if let Some(token_identity) = self.identity
119+
&& token_identity != computed_identity
120+
{
121+
return Err(anyhow::anyhow!(
121122
"Identity mismatch: token identity {token_identity:?} does not match computed identity {computed_identity:?}",
122123
));
123-
}
124124
}
125125

126126
Ok(SpacetimeIdentityClaims {

crates/bench/src/schemas.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub fn table_name<T: BenchTable>(style: IndexStrategy) -> TableName {
171171
#[derive(Clone)]
172172
pub struct XorShiftLite(pub u64);
173173
impl XorShiftLite {
174-
fn gen(&mut self) -> u64 {
174+
fn r#gen(&mut self) -> u64 {
175175
let old = self.0;
176176
self.0 ^= self.0 << 13;
177177
self.0 ^= self.0 >> 7;
@@ -189,36 +189,36 @@ pub trait RandomTable {
189189
/// Then in the filter benchmarks, `mean_result_count = table_size / buckets`.
190190
///
191191
/// Currently the same number of buckets is used for all attributes.
192-
fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self;
192+
fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self;
193193
}
194194

195195
impl RandomTable for u32_u64_str {
196-
fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self {
197-
let name = nth_name(rng.gen() % buckets).into();
198-
let age = rng.gen() % buckets;
196+
fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self {
197+
let name = nth_name(rng.r#gen() % buckets).into();
198+
let age = rng.r#gen() % buckets;
199199
u32_u64_str { id, name, age }
200200
}
201201
}
202202

203203
impl RandomTable for u32_u64_u64 {
204-
fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self {
205-
let x = rng.gen() % buckets;
206-
let y = rng.gen() % buckets;
204+
fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self {
205+
let x = rng.r#gen() % buckets;
206+
let y = rng.r#gen() % buckets;
207207
u32_u64_u64 { id, x, y }
208208
}
209209
}
210210

211211
impl RandomTable for u64_u64_u32 {
212-
fn gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self {
213-
let x = rng.gen() % buckets;
214-
let y = rng.gen() % buckets;
212+
fn r#gen(id: u32, rng: &mut XorShiftLite, buckets: u64) -> Self {
213+
let x = rng.r#gen() % buckets;
214+
let y = rng.r#gen() % buckets;
215215
u64_u64_u32 { x, y, id }
216216
}
217217
}
218218

219219
pub fn create_sequential<T: RandomTable>(seed: u64, count: u32, buckets: u64) -> Vec<T> {
220220
let mut rng = XorShiftLite(seed);
221-
(0..count).map(|id| T::gen(id, &mut rng, buckets)).collect()
221+
(0..count).map(|id| T::r#gen(id, &mut rng, buckets)).collect()
222222
}
223223

224224
/// Create a table whose first `identical` rows are identical except for their `id` column.
@@ -237,13 +237,13 @@ pub fn create_partly_identical<T: RandomTable>(seed: u64, identical: u64, total:
237237
for _ in 0..identical {
238238
// clone to preserve rng state
239239
let mut rng_ = rng.clone();
240-
result.push(T::gen(id as u32, &mut rng_, buckets));
240+
result.push(T::r#gen(id as u32, &mut rng_, buckets));
241241
id += 1;
242242
}
243243
// advance rng
244-
drop(T::gen(id as u32, &mut rng, buckets));
244+
drop(T::r#gen(id as u32, &mut rng, buckets));
245245
for _ in identical..total {
246-
result.push(T::gen(id as u32, &mut rng, buckets));
246+
result.push(T::r#gen(id as u32, &mut rng, buckets));
247247
id += 1;
248248
}
249249
result
@@ -254,8 +254,8 @@ pub fn create_random<T: RandomTable>(seed: u64, count: u32, buckets: u64) -> Vec
254254
let mut rng = XorShiftLite(seed);
255255
(0..count)
256256
.map(|_| {
257-
let id = (rng.gen() % (u32::MAX as u64)) as u32;
258-
T::gen(id, &mut rng, buckets)
257+
let id = (rng.r#gen() % (u32::MAX as u64)) as u32;
258+
T::r#gen(id, &mut rng, buckets)
259259
})
260260
.collect()
261261
}
@@ -362,7 +362,7 @@ mod tests {
362362
}
363363
// sample some earlier names to make sure we haven't overlapped
364364
for _ in 0..30 {
365-
let prev = rng.gen() % n;
365+
let prev = rng.r#gen() % n;
366366
assert!(
367367
name != nth_name(prev),
368368
"names should not repeat, but {}->{} and {}->{}",

crates/bench/src/sqlite.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ fn memo_query<F: FnOnce() -> String>(bench_name: BenchName, table_id: &str, gene
227227
// fast path
228228
let queries = QUERIES.read().unwrap();
229229

230-
if let Some(bench_queries) = queries.get(&bench_name) {
231-
if let Some(query) = bench_queries.get(table_id) {
232-
return query.clone();
233-
}
230+
if let Some(bench_queries) = queries.get(&bench_name)
231+
&& let Some(query) = bench_queries.get(table_id)
232+
{
233+
return query.clone();
234234
}
235235

236236
// slow path

0 commit comments

Comments
 (0)