-
Notifications
You must be signed in to change notification settings - Fork 2
276 lines (243 loc) · 8.97 KB
/
Copy pathci.yml
File metadata and controls
276 lines (243 loc) · 8.97 KB
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
name: CI
on:
push:
branches: [ master ]
# Need to run on tags in order to publish tagged Docker images
tags: [ "v*" ]
pull_request:
branches: [ master ]
env:
# Minimum supported Rust version.
msrv: 1.86.0
# Nightly Rust necessary for building docs.
nightly: nightly-2025-11-02
# `mdbook` version used
MDBOOK_VERSION: 0.5.2
jobs:
build-msrv:
permissions:
contents: read
strategy:
matrix:
include:
- os: windows-latest
features: ""
- os: macos-latest
features: ""
- os: ubuntu-latest
features: --all-features
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.msrv }}
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}${{ matrix.features }}-msrv-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}${{ matrix.features }}-msrv-cargo
- name: Run tests
run: cargo test -p term-transcript ${{ matrix.features }} --all-targets
- name: Run doc tests
run: cargo test -p term-transcript ${{ matrix.features }} --doc
build:
permissions:
contents: read
strategy:
matrix:
include:
- os: windows-latest
- os: macos-latest
- os: ubuntu-latest
all_checks: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
- name: Install cargo-deny
uses: baptiste0928/cargo-install@v3
if: matrix.all_checks
with:
crate: cargo-deny
version: "^0.18.9"
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo
- name: Format
run: cargo fmt --all -- --check
if: matrix.all_checks
- name: Clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
- name: Clippy styled-str (no features)
run: cargo clippy -p styled-str --no-default-features --lib -- -D warnings
- name: Clippy (no features)
run: cargo clippy -p term-transcript --no-default-features --lib -- -D warnings
- name: Clippy (features = svg)
run: cargo clippy -p term-transcript --no-default-features --features svg --lib -- -D warnings
- name: Clippy (features = test)
run: cargo clippy -p term-transcript --no-default-features --features test --lib -- -D warnings
- name: Clippy CLI (no features)
run: cargo clippy -p term-transcript --no-default-features --all-targets -- -D warnings
- name: Check dependencies
run: cargo deny --workspace --all-features check
if: matrix.all_checks
- name: Check rainbow script outputs
run: ./e2e-tests/rainbow/bin/regenerate-rainbow-out.sh --check
if: matrix.all_checks
- name: Run tests
run: cargo test --workspace --all-features --all-targets --no-fail-fast
env:
# Skip the PowerShell snapshots when testing CLI examples
TT_IMG_SKIP: pwsh
- name: Run doc tests
run: cargo test --workspace --all-features --doc
- name: Run proptests (styled-str)
run: cargo test --release -p styled-str --test proptests
env:
PROPTEST_CASES: 100000
if: matrix.all_checks
- name: Test CLI tracing
shell: bash
run: |
RUST_LOG=term_transcript=debug \
cargo run -p term-transcript-cli --all-features -- \
exec 'echo Hello' 2>&1 | grep DEBUG
build-nightly:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.nightly }}
targets: thumbv7m-none-eabi
- name: Install mdbook
run: |
mkdir -p .bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v$MDBOOK_VERSION/mdbook-v$MDBOOK_VERSION-x86_64-unknown-linux-gnu.tar.gz \
| tar -xz --directory=.bin
sudo install .bin/mdbook /usr/local/bin
mdbook --version
- name: Cache cargo build
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-cargo-nightly-${{ hashFiles('Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-nightly
- name: Build the Book
working-directory: ./docs
run: mdbook build
- name: Build docs
run: |
cargo clean --doc && \
cargo rustdoc -p term-transcript --all-features -- -D warnings --cfg docsrs
build-docker:
needs:
- build
- build-msrv
- build-nightly
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Cache Docker build
uses: actions/cache@v5
with:
path: target/docker
key: ${{ runner.os }}-docker-buildkit-${{ hashFiles('Cargo.lock') }}
restore-keys: ${{ runner.os }}-docker-buildkit
- name: Install `socat`
run: |
sudo apt-get update && \
sudo apt-get install -y --no-install-suggests --no-install-recommends socat
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- name: Log in to Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Identify Buildx container
run: |
CONTAINER_ID=$(docker ps --filter=ancestor=moby/buildkit:buildx-stable-1 --format='{{ .ID }}')
echo "buildx_container=$CONTAINER_ID" | tee -a "$GITHUB_ENV"
- name: Restore cache
run: |
if [[ -f target/docker/cache.db ]]; then
docker cp target/docker/. "$buildx_container:/var/lib/buildkit"
docker restart "$buildx_container"
# Wait until the container is restarted
sleep 5
fi
docker buildx du # Check the restored cache
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
file: crates/term-transcript-cli/Dockerfile
load: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# We want to only store cache volumes (type=exec.cachemount) since
# their creation is computationally bound as opposed to other I/O-bound volume types.
- name: Extract image cache
run: |
docker buildx prune --force --filter=type=regular
docker buildx prune --force --filter=type=source.local
rm -rf target/docker && mkdir -p target/docker
docker cp "$buildx_container:/var/lib/buildkit/." target/docker
du -ah -d 1 target/docker
- name: Test image (--help)
run: docker run --rm "$IMAGE_TAG" --help
env:
IMAGE_TAG: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- name: Test image (print)
run: |
docker run -i --rm --env COLOR=always "$IMAGE_TAG" print - < examples/rainbow.svg
env:
IMAGE_TAG: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- name: Test image (exec, nc host)
run: |
mkfifo /tmp/shell.fifo
cat /tmp/shell.fifo | bash -i 2>&1 | nc -lU /tmp/shell.sock > /tmp/shell.fifo &
docker run --rm -v /tmp/shell.sock:/tmp/shell.sock "$IMAGE_TAG" \
exec --shell nc --echoing --args=-U --args=/tmp/shell.sock 'ls -al' \
> test.svg
docker run -i --rm --env COLOR=always "$IMAGE_TAG" print - < test.svg
env:
IMAGE_TAG: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- name: Test image (exec, socat host)
run: |
rm -f /tmp/shell.sock
socat UNIX-LISTEN:/tmp/shell.sock,fork EXEC:"bash -i",pty,setsid,ctty,stderr &
docker run --rm -v /tmp/shell.sock:/tmp/shell.sock "$IMAGE_TAG" \
exec --shell nc --echoing --args=-U --args=/tmp/shell.sock 'ls -al' \
> test-pty.svg
docker run -i --rm --env COLOR=always "$IMAGE_TAG" print - < test-pty.svg
env:
IMAGE_TAG: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
- name: Publish image
if: github.event_name == 'push'
run: docker push "$IMAGE_TAG"
env:
IMAGE_TAG: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}