Skip to content

Commit b303854

Browse files
authored
feat(stores): Splitting Sled and Indexeddb Store into separate crates
More details in pull request #498 .
2 parents e03ee91 + 44fe3a6 commit b303854

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1552
-1230
lines changed

.github/workflows/appservice.yml

+6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
- ready_for_review
813

914
env:
1015
CARGO_TERM_COLOR: always
1116

1217
jobs:
1318
test-appservice:
19+
if: github.event_name == 'push' || !github.event.pull_request.draft
1420
name: ${{ matrix.name }}
1521

1622
runs-on: ${{ matrix.os || 'ubuntu-latest' }}

.github/workflows/ci.yml

+11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
name: CI
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [main]
67
pull_request:
78
branches: [main]
9+
types:
10+
- opened
11+
- reopened
12+
- synchronize
13+
- ready_for_review
814

915
env:
1016
CARGO_TERM_COLOR: always
@@ -13,6 +19,7 @@ jobs:
1319
style:
1420
name: Check style
1521
runs-on: ubuntu-latest
22+
if: github.event_name == 'push' || !github.event.pull_request.draft
1623

1724
steps:
1825
- name: Checkout the repo
@@ -36,6 +43,7 @@ jobs:
3643
name: Spell Check with Typos
3744
needs: [style]
3845
runs-on: ubuntu-latest
46+
if: github.event_name == 'push' || !github.event.pull_request.draft
3947

4048
steps:
4149
- name: Checkout Actions Repository
@@ -48,6 +56,7 @@ jobs:
4856
name: Run clippy
4957
needs: [style]
5058
runs-on: ubuntu-latest
59+
if: github.event_name == 'push' || !github.event.pull_request.draft
5160

5261
steps:
5362
- name: Checkout the repo
@@ -72,6 +81,7 @@ jobs:
7281

7382
test-features:
7483
name: ${{ matrix.name }}
84+
if: github.event_name == 'push' || !github.event.pull_request.draft
7585

7686
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
7787
strategy:
@@ -141,6 +151,7 @@ jobs:
141151

142152
test:
143153
name: ${{ matrix.name }}
154+
if: github.event_name == 'push' || !github.event.pull_request.draft
144155

145156
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
146157
strategy:

.github/workflows/docs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
docs:
1010
name: Docs
1111
runs-on: ubuntu-latest
12+
if: github.event_name == 'push' || !github.event.pull_request.draft
1213

1314
steps:
1415
- name: Checkout repository

.github/workflows/wasm.yml

+25-29
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
- ready_for_review
813

914
env:
1015
CARGO_TERM_COLOR: always
@@ -13,25 +18,24 @@ jobs:
1318
check-wasm:
1419
name: Build test
1520
runs-on: ubuntu-latest
21+
if: github.event_name == 'push' || !github.event.pull_request.draft
1622

1723
strategy:
18-
# fail-fast: true
19-
24+
fail-fast: true
2025
matrix:
2126
name:
2227
- matrix-qrcode
2328
- matrix-sdk (no-default, wasm-flags)
2429
- matrix-sdk-base
2530
- matrix-sdk-common
2631
- matrix-sdk-crypto
27-
- matrix-sdk-base / indexeddb_state_store
28-
- matrix-sdk-crypto / indexeddb_cryptostore
32+
- matrix-sdk / indexeddb_stores
2933

3034
include:
3135
- name: matrix-qrcode
3236
cargo_args: --package matrix-qrcode
3337
- name: matrix-sdk (no-default, wasm-flags)
34-
cargo_args: --no-default-features --features qrcode,encryption,indexeddb_stores,rustls-tls --package matrix-sdk
38+
cargo_args: --no-default-features --features qrcode,encryption,indexeddb_stores,rustls-tls --package matrix-sdk --lib
3539
- name: matrix-sdk-base
3640
cargo_args: --package matrix-sdk-base
3741
- name: matrix-sdk-common
@@ -40,10 +44,8 @@ jobs:
4044
cargo_args: --package matrix-sdk-crypto
4145

4246
# special check for specific features
43-
- name: matrix-sdk-base / indexeddb_state_store
44-
cargo_args: --package matrix-sdk-base --features indexeddb_state_store
45-
- name: matrix-sdk-crypto / indexeddb_cryptostore
46-
cargo_args: --package matrix-sdk-crypto --features indexeddb_cryptostore
47+
- name: matrix-sdk / indexeddb_stores
48+
cargo_args: --package matrix-sdk --no-default-features --features indexeddb_stores,encryption,rustls-tls --lib
4749

4850
steps:
4951
- name: Checkout the repo
@@ -59,7 +61,6 @@ jobs:
5961

6062
- name: Load cache
6163
uses: Swatinem/rust-cache@v1
62-
6364
# needed for libolm-sys compilation
6465
- name: Install emscripten
6566
uses: mymindstorm/setup-emsdk@v11
@@ -76,26 +77,26 @@ jobs:
7677
# building wasm is not enough, we've seen runtime errors before,
7778
# hence the tests
7879
name: ${{ matrix.name }} test
80+
if: github.event_name == 'push' || !github.event.pull_request.draft
7981
runs-on: ubuntu-latest
8082
continue-on-error: ${{ matrix.experimental }}
8183

8284
strategy:
8385
matrix:
8486
include:
85-
- name: "matrix-sdk-crypto @Node14 emcc2.0"
86-
experimental: false
87-
emcc_version: 2.0.27
88-
base_dir: matrix-sdk-crypto
89-
cargo_args: --features indexeddb_cryptostore
90-
- name: matrix-sdk-base
91-
experimental: false
92-
base_dir: matrix-sdk-base
93-
cargo_args: --features indexeddb_state_store,indexeddb_cryptostore
9487
- name: matrix-sdk
9588
experimental: false
9689
base_dir: matrix-sdk
97-
# FIXME: we have to skip all examples b/c of https://github.com/rustwasm/wasm-pack/issues/666
98-
cargo_args: --no-default-features --features indexeddb_stores,rustls-tls --lib
90+
cargo_args: --no-default-features --features indexeddb_stores,rustls-tls --lib
91+
- name: matrix-sdk-encryption
92+
experimental: false
93+
emcc_version: 2.0.27
94+
node_version: '14'
95+
base_dir: matrix-sdk
96+
cargo_args: --no-default-features --features indexeddb_stores,rustls-tls,encryption --lib
97+
- name: "matrix-sdk-indexeddb"
98+
base_dir: matrix-sdk-indexeddb
99+
experimental: false
99100
- name: "matrix-sdk-example-wasm_command_bot @Node14"
100101
experimental: false
101102
emcc_version: 2.0.27
@@ -106,11 +107,6 @@ jobs:
106107
npm install
107108
npm test
108109
wasm-pack test --firefox --headless
109-
110-
# these are _known_ broken on latest node
111-
# - name: matrix-sdk-crypto
112-
# experimental: true
113-
# base_dir: matrix-sdk-crypto
114110
- name: matrix-sdk-example-wasm_command_bot
115111
base_dir: matrix-sdk/examples/wasm_command_bot
116112
# this might fail
@@ -160,14 +156,14 @@ jobs:
160156
emcc -v
161157
162158
- name: Default wasm-pack tests
163-
if: ${{!matrix.cmd}}
159+
if: ${{ !matrix.cmd }}
164160
run: |
165161
cd crates/${{matrix.base_dir}}
166162
wasm-pack test --node -- ${{ matrix.cargo_args }}
167-
wasm-pack test --firefox --headless -- --features ${{ matrix.cargo_args }}
163+
wasm-pack test --firefox --headless -- ${{ matrix.cargo_args }}
168164
169165
- name: Testing with custom command
170-
if: ${{matrix.cmd}}
166+
if: ${{ matrix.cmd }}
171167
run: |
172168
cd crates/${{matrix.base_dir}}
173169
${{matrix.cmd}}

crates/matrix-sdk-base/Cargo.toml

+8-31
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,19 @@ rustdoc-args = ["--cfg", "docsrs"]
1717

1818
[features]
1919
default = []
20-
encryption = ["matrix-sdk-crypto"]
20+
encryption = ["matrix-sdk-crypto", "store_key"]
2121
qrcode = ["matrix-sdk-crypto/qrcode"]
22-
sled_state_store = [
23-
"sled",
24-
"tokio",
22+
23+
# Store Key is a helper feature for state store implementations
24+
store_key = [
2525
"pbkdf2",
2626
"hmac",
2727
"sha2",
2828
"rand",
2929
"chacha20poly1305",
3030
]
31-
sled_cryptostore = ["matrix-sdk-crypto/sled_cryptostore"]
32-
33-
indexeddb_state_store = ["indexed_db_futures", "wasm-bindgen", "pbkdf2", "hmac", "sha2", "rand", "chacha20poly1305"]
34-
indexeddb_cryptostore = ["matrix-sdk-crypto/indexeddb_cryptostore"]
31+
# helpers for testing features build upon this
32+
testing = [ "http" ]
3533

3634
[dependencies]
3735
async-stream = "0.3.2"
@@ -50,38 +48,17 @@ ruma = { version = "0.5.0", features = ["client-api-c", "signatures", "unstable-
5048
serde = { version = "1.0.126", features = ["rc"] }
5149
serde_json = "1.0.64"
5250
sha2 = { version = "0.10.1", optional = true }
53-
sled = { version = "0.34.6", optional = true }
5451
thiserror = "1.0.25"
5552
tracing = "0.1.26"
5653
zeroize = { version = "1.3.0", features = ["zeroize_derive"] }
57-
58-
## Feature sled_state_store
59-
tokio = { version = "1.7.1", optional = true, default-features = false, features = ["sync", "fs"] }
60-
61-
## Feature indexeddb-state-store
62-
indexed_db_futures = { version = "0.2.0", optional = true }
63-
wasm-bindgen = { version = "0.2.74", features = ["serde-serialize"], optional = true }
54+
anyhow = "1"
55+
http = { version = "0.2.4", optional = true }
6456

6557
[dev-dependencies]
6658
futures = { version = "0.3.15", default-features = false, features = ["executor"] }
6759
http = "0.2.4"
6860
matrix-sdk-test = { version = "0.4.0", path = "../matrix-sdk-test" }
69-
70-
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
71-
atty = "0.2.14"
72-
clap = "3.1.0"
73-
rustyline = "9.0.0"
74-
rustyline-derive = "0.6.0"
75-
syntect = "4.5.0"
7661
tokio = { version = "1.7.1", default-features = false, features = [
7762
"rt-multi-thread",
7863
"macros",
7964
] }
80-
tempfile = "3.2.0"
81-
82-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
83-
wasm-bindgen-test = "0.3.24"
84-
85-
[[example]]
86-
name = "state_inspector"
87-
required-features = ["sled_state_store"]

crates/matrix-sdk-base/README.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ library.
66
The following crate feature flags are available:
77

88
* `encryption`: Enables end-to-end encryption support in the library.
9-
* `sled_cryptostore`: Enables a Sled based store for the encryption
10-
keys. If this is disabled and `encryption` support is enabled the keys will
11-
by default be stored only in memory and thus lost after the client is
12-
destroyed.
13-
* `sled_state_store`: Enables a Sled based store for the storage of the local
14-
client state.
9+
* `qrcode`: Enbles QRcode generation and reading code
10+
* `store_key`: Provides extra facilities for StateStores to manage store keys
11+
* `testing`: provides facilities and functions for tests, in particular for integration testing store implementations. ATTENTION: do not ever use outside of tests, we do not provide any stability warantees on these, these are merely helpers. If you find you _need_ any function provided here outside of tests, please open a Github Issue and inform us about your use case for us to consider.

0 commit comments

Comments
 (0)