envision 0.16.0

A ratatui framework for collaborative TUI development with headless testing support
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  test:
    name: Test (${{ matrix.os }}, ${{ matrix.rust }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        rust: [stable, "1.85"]
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust ${{ matrix.rust }}
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-${{ matrix.rust }}-

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest

      - name: Run tests
        shell: bash
        run: |
          if [ "${{ matrix.rust }}" = "stable" ]; then
            cargo nextest run --all-features --profile ci
          else
            cargo nextest run --no-default-features --features serialization,input-components,data-components,display-components,navigation-components,overlay-components,compound-components --profile ci
          fi

      - name: Run doc tests
        shell: bash
        env:
          # Windows defaults the main thread stack to 1 MB. The merged doctest
          # binary exceeds that at init under Rust 1.85; bump to 16 MB to leave
          # headroom over Linux/macOS's 8 MB default. RUSTDOCFLAGS is what
          # rustdoc reads to compile doctest binaries. Scoped to Windows.
          RUSTDOCFLAGS: ${{ matrix.os == 'windows-latest' && '-C link-args=/STACK:16777216' || '' }}
        run: |
          if [ "${{ matrix.rust }}" = "stable" ]; then
            cargo test --doc --all-features
          else
            cargo test --doc --no-default-features --features serialization,input-components,data-components,display-components,navigation-components,overlay-components,compound-components
          fi

      - name: Build examples
        shell: bash
        run: |
          if [ "${{ matrix.rust }}" = "stable" ]; then
            cargo build --examples
          else
            cargo build --examples --no-default-features --features serialization,input-components,data-components,display-components,navigation-components,overlay-components,compound-components
          fi

  no-default-features:
    name: No Default Features
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-no-default-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-no-default-

      - name: Check without default features
        run: cargo check --no-default-features

      - name: Install cargo-nextest
        uses: taiki-e/install-action@v2
        with:
          tool: nextest

      - name: Test without default features
        run: cargo nextest run --no-default-features --profile ci

      - name: Run doc tests without default features
        run: cargo test --doc --no-default-features

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          components: clippy

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-clippy-

      - name: Run clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          components: rustfmt

      - name: Check formatting
        run: cargo fmt --all -- --check

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Install cargo-tarpaulin
        run: cargo install cargo-tarpaulin

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-coverage-

      - name: Generate coverage
        run: cargo tarpaulin --out xml --output-dir coverage

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v4
        with:
          files: coverage/cobertura.xml
          fail_ci_if_error: false
          token: ${{ secrets.CODECOV_TOKEN }}

  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-docs-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-docs-

      - name: Build documentation
        run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: -D warnings

      - name: Setup Pages
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        uses: actions/configure-pages@v4

      - name: Prepare docs for deployment
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        run: |
          echo '<meta http-equiv="refresh" content="0; url=envision/index.html">' > target/doc/index.html

      - name: Upload artifact
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        uses: actions/upload-pages-artifact@v3
        with:
          path: target/doc

  changes:
    name: Detect Changes
    runs-on: ubuntu-latest
    permissions:
      pull-requests: read
    outputs:
      backend: ${{ steps.filter.outputs.backend }}
      runtime: ${{ steps.filter.outputs.runtime }}
      component-view: ${{ steps.filter.outputs.component-view }}
      component-events: ${{ steps.filter.outputs.component-events }}
    steps:
      - uses: actions/checkout@v4
      - uses: dorny/paths-filter@v3
        id: filter
        with:
          filters: |
            backend:
              - 'src/backend/**'
              - 'benches/capture_backend.rs'
              - 'Cargo.toml'
              - 'Cargo.lock'
            runtime:
              - 'src/app/**'
              - 'src/backend/**'
              - 'src/overlay/**'
              - 'benches/runtime.rs'
              - 'Cargo.toml'
              - 'Cargo.lock'
            component-view:
              - 'src/component/**'
              - 'src/backend/**'
              - 'src/theme/**'
              - 'benches/component_view.rs'
              - 'Cargo.toml'
              - 'Cargo.lock'
            component-events:
              - 'src/component/**'
              - 'src/input/**'
              - 'benches/component_events.rs'
              - 'Cargo.toml'
              - 'Cargo.lock'

  bench-backend:
    name: Bench Backend
    needs: changes
    if: needs.changes.outputs.backend == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-bench-

      - name: Restore baseline
        uses: actions/cache@v4
        with:
          path: target/criterion
          key: criterion-baseline-backend-${{ github.base_ref || 'main' }}
          restore-keys: |
            criterion-baseline-backend-main

      - name: Run benchmarks
        run: cargo bench --bench capture_backend --all-features

      - name: Save baseline
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        uses: actions/cache/save@v4
        with:
          path: target/criterion
          key: criterion-baseline-backend-main

      - name: Upload benchmark results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: criterion-report-backend
          path: target/criterion
          retention-days: 14

  bench-runtime:
    name: Bench Runtime
    needs: changes
    if: needs.changes.outputs.runtime == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-bench-

      - name: Restore baseline
        uses: actions/cache@v4
        with:
          path: target/criterion
          key: criterion-baseline-runtime-${{ github.base_ref || 'main' }}
          restore-keys: |
            criterion-baseline-runtime-main

      - name: Run benchmarks
        run: cargo bench --bench runtime --all-features

      - name: Save baseline
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        uses: actions/cache/save@v4
        with:
          path: target/criterion
          key: criterion-baseline-runtime-main

      - name: Upload benchmark results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: criterion-report-runtime
          path: target/criterion
          retention-days: 14

  bench-component-view:
    name: Bench Component View
    needs: changes
    if: needs.changes.outputs.component-view == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-bench-

      - name: Restore baseline
        uses: actions/cache@v4
        with:
          path: target/criterion
          key: criterion-baseline-component-view-${{ github.base_ref || 'main' }}
          restore-keys: |
            criterion-baseline-component-view-main

      - name: Run benchmarks
        run: cargo bench --bench component_view --all-features

      - name: Save baseline
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        uses: actions/cache/save@v4
        with:
          path: target/criterion
          key: criterion-baseline-component-view-main

      - name: Upload benchmark results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: criterion-report-component-view
          path: target/criterion
          retention-days: 14

  bench-component-events:
    name: Bench Component Events
    needs: changes
    if: needs.changes.outputs.component-events == 'true'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable

      - name: Cache cargo registry
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-bench-

      - name: Restore baseline
        uses: actions/cache@v4
        with:
          path: target/criterion
          key: criterion-baseline-component-events-${{ github.base_ref || 'main' }}
          restore-keys: |
            criterion-baseline-component-events-main

      - name: Run benchmarks
        run: cargo bench --bench component_events --all-features

      - name: Save baseline
        if: github.ref == 'refs/heads/main' && github.event_name == 'push'
        uses: actions/cache/save@v4
        with:
          path: target/criterion
          key: criterion-baseline-component-events-main

      - name: Upload benchmark results
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: criterion-report-component-events
          path: target/criterion
          retention-days: 14

  deploy-docs:
    name: Deploy Documentation
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    needs: docs
    runs-on: ubuntu-latest
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4