atagen

matrix-rust-sdk

public
Star0
Watch0
ssh://brewery@pls.lobotomise.me:33/atagen/matrix-rust-sdk.git
.github/workflows/ci.ymlYaml433 lines12.4 KB
1
name: Rust tests
2
3
on:
4
  workflow_dispatch:
5
  push:
6
    branches: ["main", "features/**", "release-**"]
7
  pull_request:
8
    branches: ["main", "features/**", "release-**"]
9
10
permissions: {}
11
12
concurrency:
13
  group: ${{ github.workflow }}-${{ github.ref }}
14
  cancel-in-progress: true
15
16
env:
17
  CARGO_TERM_COLOR: always
18
  # Insta.rs is run directly via cargo test. We don't want insta.rs to create new snapshots files.
19
  # Just want it to run the tests (option `no` instead of `auto`).
20
  INSTA_UPDATE: no
21
22
jobs:
23
  xtask:
24
    uses: ./.github/workflows/xtask.yml
25
26
  test-matrix-sdk-features:
27
    name: 🐧 [m], ${{ matrix.name }}
28
    needs: xtask
29
30
    runs-on: ubuntu-latest
31
    strategy:
32
      fail-fast: true
33
      matrix:
34
        name:
35
          - no-encryption
36
          - no-sqlite
37
          - no-encryption-and-sqlite
38
          - sqlite-cryptostore
39
          - experimental-encrypted-state-events
40
          - markdown
41
          - socks
42
          - sso-login
43
          - search
44
45
    steps:
46
      - name: Checkout
47
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
48
        with:
49
          persist-credentials: false
50
51
      - name: Install Rust
52
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
53
        with:
54
          toolchain: stable
55
56
      - name: Install libsqlite
57
        run: |
58
          sudo apt-get update
59
          sudo apt-get install libsqlite3-dev
60
61
      - name: Load cache
62
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
63
        with:
64
          # use a separate cache for each job to work around
65
          # https://github.com/Swatinem/rust-cache/issues/124
66
          key: "${{ matrix.name }}"
67
68
          # ... but only save the cache on the main branch
69
          # cf https://github.com/Swatinem/rust-cache/issues/95
70
          save-if: ${{ github.ref == 'refs/heads/main' }}
71
72
      - name: Install nextest
73
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v 2.79.1
74
        with:
75
          tool: nextest
76
77
      - name: Get xtask
78
        uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
79
        with:
80
          path: target/debug/xtask
81
          key: "${{ needs.xtask.outputs.cachekey-linux }}"
82
          fail-on-cache-miss: true
83
84
      - name: Test
85
        run: |
86
          target/debug/xtask ci test-features ${{ matrix.name }}
87
88
  test-matrix-sdk-examples:
89
    name: 🐧 [m]-examples
90
    needs: xtask
91
    runs-on: ubuntu-latest
92
93
    steps:
94
      - name: Checkout the repo
95
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
96
        with:
97
          persist-credentials: false
98
99
      - name: Install Rust
100
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
101
        with:
102
          toolchain: stable
103
104
      - name: Load cache
105
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
106
        with:
107
          save-if: ${{ github.ref == 'refs/heads/main' }}
108
109
      - name: Install nextest
110
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v 2.79.1
111
        with:
112
          tool: nextest
113
114
      - name: Get xtask
115
        uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
116
        with:
117
          path: target/debug/xtask
118
          key: "${{ needs.xtask.outputs.cachekey-linux }}"
119
          fail-on-cache-miss: true
120
121
      - name: Test
122
        run: |
123
          target/debug/xtask ci examples
124
125
  test-matrix-sdk-crypto:
126
    name: 🐧 [m]-crypto
127
    needs: xtask
128
    runs-on: ubuntu-latest
129
130
    steps:
131
      - name: Checkout the repo
132
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
133
        with:
134
          persist-credentials: false
135
136
      - name: Install libsqlite
137
        run: |
138
          sudo apt-get update
139
          sudo apt-get install libsqlite3-dev
140
141
      - name: Install Rust
142
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
143
        with:
144
          toolchain: stable
145
          components: clippy
146
147
      - name: Load cache
148
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
149
        with:
150
          save-if: ${{ github.ref == 'refs/heads/main' }}
151
152
      - name: Install nextest
153
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v 2.79.1
154
        with:
155
          tool: nextest
156
157
      - name: Get xtask
158
        uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
159
        with:
160
          path: target/debug/xtask
161
          key: "${{ needs.xtask.outputs.cachekey-linux }}"
162
          fail-on-cache-miss: true
163
164
      - name: Test
165
        run: |
166
          target/debug/xtask ci test-crypto
167
168
  test-all-crates:
169
    name: ${{ matrix.name }}
170
171
    runs-on: ${{ matrix.os }}
172
    strategy:
173
      fail-fast: true
174
      matrix:
175
        include:
176
          - name: 🐧 all crates, 🦀 stable
177
            rust: stable
178
            os: ubuntu-latest
179
180
          - name: 🐧 all crates, 🦀 beta
181
            rust: beta
182
            os: ubuntu-latest
183
184
          - name: 🍏 all crates, 🦀 stable
185
            rust: stable
186
            os: macos-latest
187
188
    steps:
189
      - name: Checkout
190
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
191
        with:
192
          persist-credentials: false
193
194
      - name: Install protoc
195
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v2.79.1
196
        with:
197
          tool: protoc@3.20.3
198
199
      - name: Install libsqlite
200
        if: runner.os == 'Linux'
201
        run: |
202
          sudo apt-get update
203
          sudo apt-get install libsqlite3-dev
204
205
      - name: Install Rust toolchain
206
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
207
        with:
208
          toolchain: ${{ matrix.rust }}
209
210
      - name: Load cache
211
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
212
        with:
213
          save-if: ${{ github.ref == 'refs/heads/main' }}
214
215
      - name: Install nextest
216
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v 2.79.1
217
        with:
218
          tool: nextest
219
220
      - name: Test
221
        run: |
222
          cargo nextest run --workspace \
223
            --exclude matrix-sdk-integration-testing --features testing
224
225
      - name: Test documentation
226
        run: |
227
          cargo test --doc --features docsrs
228
229
  test-wasm:
230
    name: 🕸️ ${{ matrix.name }}
231
    needs: xtask
232
233
    runs-on: ubuntu-latest
234
235
    strategy:
236
      fail-fast: true
237
      matrix:
238
        include:
239
          - name: '[m]-qrcode'
240
            cmd: matrix-sdk-qrcode
241
242
          - name: '[m]-base'
243
            cmd: matrix-sdk-base
244
245
          - name: '[m]-common'
246
            cmd: matrix-sdk-common
247
248
          - name: '[m], no-default'
249
            cmd: matrix-sdk-no-default
250
251
          - name: '[m]-ui'
252
            cmd: matrix-sdk-ui
253
            check_only: true
254
255
          - name: '[m]-indexeddb'
256
            cmd: indexeddb
257
258
          - name: '[m], indexeddb stores'
259
            cmd: matrix-sdk-indexeddb-stores
260
261
          - name: '[m], indexeddb stores, no crypto'
262
            cmd: matrix-sdk-indexeddb-stores-no-crypto
263
264
    steps:
265
      - name: Checkout the repo
266
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
267
        with:
268
          persist-credentials: false
269
270
      - name: Install Rust
271
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
272
        with:
273
          toolchain: stable
274
          targets: wasm32-unknown-unknown
275
          components: clippy
276
277
      - name: Install wasm-pack
278
        uses: qmaru/wasm-pack-action@785fe709cd17eb6a97607eda9b6f5dbebed2b89c # v0.5.3
279
        if: '!matrix.check_only'
280
        with:
281
          version: v0.13.1
282
283
      - name: Load cache
284
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
285
        with:
286
          # use a separate cache for each job to work around
287
          # https://github.com/Swatinem/rust-cache/issues/124
288
          key: "${{ matrix.cmd }}"
289
290
          # ... but only save the cache on the main branch
291
          # cf https://github.com/Swatinem/rust-cache/issues/95
292
          save-if: ${{ github.ref == 'refs/heads/main' }}
293
294
      - name: Install nextest
295
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v 2.79.1
296
        with:
297
          tool: nextest
298
299
      - name: Get xtask
300
        uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
301
        with:
302
          path: target/debug/xtask
303
          key: "${{ needs.xtask.outputs.cachekey-linux }}"
304
          fail-on-cache-miss: true
305
306
      - name: Rust Check
307
        run: |
308
          target/debug/xtask ci wasm ${{ matrix.cmd }}
309
310
      - name: Wasm-Pack test
311
        if: '!matrix.check_only'
312
        run: |
313
          target/debug/xtask ci wasm-pack ${{ matrix.cmd }}
314
315
  typos:
316
    name: Spell Check with Typos
317
    runs-on: ubuntu-latest
318
319
    steps:
320
      - name: Checkout Actions Repository
321
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
322
        with:
323
          persist-credentials: false
324
325
      - name: Check the spelling of the files in our repo
326
        uses: crate-ci/typos@aca895bf05aec0cb7dffa6f94495e923224d9f17 # v1.46.2
327
328
  lint:
329
    name: Lint
330
    needs: xtask
331
    runs-on: ubuntu-latest
332
333
    steps:
334
      - name: Checkout the repo
335
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
336
        with:
337
          persist-credentials: false
338
339
      - name: Install protoc
340
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v2.79.1
341
        with:
342
          tool: protoc@3.20.3
343
344
      - name: Install Rust
345
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
346
        with:
347
          toolchain: nightly-2026-02-26
348
          components: clippy, rustfmt
349
350
      - name: Load cache
351
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
352
        with:
353
          save-if: ${{ github.ref == 'refs/heads/main' }}
354
355
      - name: Get xtask
356
        uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
357
        with:
358
          path: target/debug/xtask
359
          key: "${{ needs.xtask.outputs.cachekey-linux }}"
360
          fail-on-cache-miss: true
361
362
      - name: Check Formatting
363
        run: |
364
          target/debug/xtask ci style
365
366
      - name: Clippy
367
        run: |
368
          target/debug/xtask ci clippy
369
370
  integration-tests:
371
    name: 'Integration test (features: ${{ matrix.feature }})'
372
    runs-on: ubuntu-latest
373
374
    # run several docker containers with the same networking stack so the hostname 'synapse'
375
    # maps to the synapse container, etc.
376
    services:
377
      # tests need a synapse: this is a service and not michaelkaye/setup-matrix-synapse@main as the
378
      # latter does not provide networking for services to communicate with it.
379
      synapse:
380
        image: ghcr.io/matrix-org/synapse-service:v1.117.0 # keep in sync with ./coverage.yml
381
        env:
382
            SYNAPSE_COMPLEMENT_DATABASE: sqlite
383
            SERVER_NAME: synapse
384
        ports:
385
            - 8008:8008
386
387
    strategy:
388
      fail-fast: true
389
      matrix:
390
        feature:
391
          - "default"
392
          - "experimental-encrypted-state-events"
393
394
    steps:
395
      - name: Checkout the repo
396
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
397
        with:
398
          persist-credentials: false
399
400
      - name: Install libsqlite
401
        run: |
402
          sudo apt-get update
403
          sudo apt-get install libsqlite3-dev
404
405
      - name: Install Rust
406
        uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
407
        with:
408
          toolchain: stable
409
410
      - name: Load cache
411
        uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
412
        with:
413
          save-if: ${{ github.ref == 'refs/heads/main' }}
414
415
      - name: Install nextest
416
        uses: taiki-e/install-action@b550161ef8a7bc4f2a671c0b03a18ac9ccedea1e # v 2.79.1
417
        with:
418
          tool: nextest
419
420
      - name: Test
421
        env:
422
          RUST_LOG: "info,matrix_sdk=trace"
423
          HOMESERVER_URL: "http://localhost:8008"
424
          HOMESERVER_DOMAIN: "synapse"
425
        run: |
426
          cargo nextest run --profile ci -p matrix-sdk-integration-testing --features "${{ matrix.feature }}"
427
428
      - name: Upload test results to Codecov
429
        if: ${{ !cancelled() }}
430
        uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3
431
        with:
432
          files: ./target/nextest/ci/junit.xml
433
          token: ${{ secrets.CODECOV_TOKEN }}