Skip to content

Commit 590fe3a

Browse files
committed
ci: create GIF recording on CI
1 parent 82d3c31 commit 590fe3a

4 files changed

Lines changed: 117 additions & 70 deletions

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,50 @@ jobs:
109109
run: cargo build --verbose --locked
110110
- name: Run tests
111111
run: cargo test --verbose
112+
record:
113+
runs-on: ubuntu-latest
114+
115+
steps:
116+
- uses: actions/checkout@v4
117+
- name: Update Rust
118+
run: rustup update stable
119+
- name: Main cache
120+
uses: actions/cache@v4
121+
with:
122+
path: |
123+
~/.cargo/bin/
124+
~/.cargo/registry/index/
125+
~/.cargo/registry/cache/
126+
~/.cargo/git/db/
127+
target/
128+
key: ${{ runner.os }}-record-${{ hashFiles('**/Cargo.lock') }}
129+
- name: Build ttyd
130+
run: |
131+
sudo apt-get update
132+
sudo apt-get install -y build-essential cmake git libjson-c-dev libwebsockets-dev
133+
git clone https://github.com/tsl0922/ttyd.git
134+
cd ttyd && mkdir build && cd build
135+
cmake ..
136+
make && sudo make install
137+
- name: Add sources for VHS
138+
run: |
139+
sudo mkdir -p /etc/apt/keyrings
140+
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
141+
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
142+
- name: Install ffmpeg and VHS
143+
run: sudo apt update && sudo apt install vhs ffmpeg
144+
- name: Create GIF and screenshots
145+
run: vhs assets/envfetch.tape
146+
- name: Upload assets
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: envfetch-record
150+
path: |
151+
assets/envfetch.gif
152+
assets/envfetch.ascii
153+
assets/interactive_main.png
154+
assets/interactive_add.png
155+
assets/main.png
112156
coverage:
113157
runs-on: ubuntu-latest
114158

assets/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# THIS FILE USED JUST FOR DEMONSTRATION!!!
2+
HELLO_VAR=HELLO

assets/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# What's this?
2+
3+
This directory contains some assets and service files.
4+
5+
## Structure
6+
7+
```sh
8+
assets
9+
├── .env.example # Example .env file, used for demonstartion
10+
├── assets/README.md # This file
11+
├── assets/default_config.toml # Default config file, packs during compilation
12+
├── assets/envfetch.ascii # Text representation of utility's work. Will be used for integration tests later
13+
├── assets/envfetch.gif # Demonstration of utility's work
14+
├── assets/envfetch.tape # VHS tape, used to create GIF and images
15+
├── assets/interactive_add.png # Picture of creating variable in interactive mode
16+
├── assets/interactive_main.png # Picture of interactive mode main screen
17+
└── assets/main.png # Picture of main commands
18+
```
19+
20+
## How to record GIF
21+
22+
Firstly, [install VHS](https://github.com/charmbracelet/vhs#installation) and thhen from ROOT DIRECTORY of repo run following:
23+
24+
```sh
25+
vhs assets/envfetch.tape
26+
```
27+
28+
This will create all screenshots and GIF image.

assets/envfetch.tape

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -4,92 +4,65 @@
44
#
55
# vhs assets/envfetch.tape
66

7-
# VHS documentation
8-
#
9-
# Output:
10-
# Output <path>.gif Create a GIF output at the given <path>
11-
# Output <path>.mp4 Create an MP4 output at the given <path>
12-
# Output <path>.webm Create a WebM output at the given <path>
13-
#
14-
# Require:
15-
# Require <string> Ensure a program is on the $PATH to proceed
16-
#
17-
# Settings:
18-
# Set FontSize <number> Set the font size of the terminal
19-
# Set FontFamily <string> Set the font family of the terminal
20-
# Set Height <number> Set the height of the terminal
21-
# Set Width <number> Set the width of the terminal
22-
# Set LetterSpacing <float> Set the font letter spacing (tracking)
23-
# Set LineHeight <float> Set the font line height
24-
# Set LoopOffset <float>% Set the starting frame offset for the GIF loop
25-
# Set Theme <json|string> Set the theme of the terminal
26-
# Set Padding <number> Set the padding of the terminal
27-
# Set Framerate <number> Set the framerate of the recording
28-
# Set PlaybackSpeed <float> Set the playback speed of the recording
29-
# Set MarginFill <file|#000000> Set the file or color the margin will be filled with.
30-
# Set Margin <number> Set the size of the margin. Has no effect if MarginFill isn't set.
31-
# Set BorderRadius <number> Set terminal border radius, in pixels.
32-
# Set WindowBar <string> Set window bar type. (one of: Rings, RingsRight, Colorful, ColorfulRight)
33-
# Set WindowBarSize <number> Set window bar size, in pixels. Default is 40.
34-
# Set TypingSpeed <time> Set the typing speed of the terminal. Default is 50ms.
35-
#
36-
# Sleep:
37-
# Sleep <time> Sleep for a set amount of <time> in seconds
38-
#
39-
# Type:
40-
# Type[@<time>] "<characters>" Type <characters> into the terminal with a
41-
# <time> delay between each character
42-
#
43-
# Keys:
44-
# Escape[@<time>] [number] Press the Escape key
45-
# Backspace[@<time>] [number] Press the Backspace key
46-
# Delete[@<time>] [number] Press the Delete key
47-
# Insert[@<time>] [number] Press the Insert key
48-
# Down[@<time>] [number] Press the Down key
49-
# Enter[@<time>] [number] Press the Enter key
50-
# Space[@<time>] [number] Press the Space key
51-
# Tab[@<time>] [number] Press the Tab key
52-
# Left[@<time>] [number] Press the Left Arrow key
53-
# Right[@<time>] [number] Press the Right Arrow key
54-
# Up[@<time>] [number] Press the Up Arrow key
55-
# Down[@<time>] [number] Press the Down Arrow key
56-
# PageUp[@<time>] [number] Press the Page Up key
57-
# PageDown[@<time>] [number] Press the Page Down key
58-
# Ctrl+<key> Press the Control key + <key> (e.g. Ctrl+C)
59-
#
60-
# Display:
61-
# Hide Hide the subsequent commands from the output
62-
# Show Show the subsequent commands in the output
63-
647
Output assets/envfetch.gif
658
Output assets/envfetch.ascii
669

6710
Require envfetch
6811

69-
Set TypingSpeed 150ms
70-
Set FontSize 32
71-
Set Width 2400
72-
Set Height 1200
12+
Set PlaybackSpeed 0.5
13+
Set CursorBlink false
14+
Set Framerate 60
15+
Set TypingSpeed 400ms
16+
Set FontSize 24
17+
Set Width 1600
18+
Set Height 800
7319

7420
# Basic set
75-
Type "envfetch set MY_VAR_TEST 'Hello for everyone!' -- echo hello" Sleep 500ms Enter
76-
#Sleep 500ms
21+
Type `envfetch set MY_VAR_TEST "Hello for everyone!" -- echo hello` Sleep 500ms Enter
22+
Sleep 500ms
7723
Type "envfetch get MY_VAR_TEST" Sleep 500ms Enter
78-
#Sleep 500ms
24+
Sleep 500ms
7925
# Global set
80-
Type "envfetch set MY_VAR_TEST 'Hello for everyone!' --global" Sleep 500ms Enter
81-
#Sleep 500ms
26+
Type `envfetch set MY_VAR_TEST "Hello for everyone!" --global` Sleep 500ms Enter
27+
Sleep 500ms
8228
# Get with wrong name
8329
Type "envfetch get MY_VAR_TESTT" Sleep 500ms Enter
84-
#Sleep 500ms
30+
Sleep 500ms
8531
# Get with normal name
8632
Type "envfetch get MY_VAR_TEST" Sleep 500ms Enter
87-
#Sleep 500ms
33+
Sleep 500ms
8834
# Add globally
8935
Type "envfetch add MY_VAR_TEST ! --global" Sleep 500ms Enter
90-
#Sleep 500ms
36+
Sleep 500ms
9137
# Remove globally
9238
Type "envfetch delete MY_VAR_TEST --global" Sleep 500ms Enter
93-
#Sleep 500ms
39+
Sleep 500ms
40+
# Load
41+
Type "envfetch get HELLO_VAR" Sleep 500ms Enter
42+
Sleep 500ms
43+
Type `envfetch load --global --file "assets/.env.example"` Sleep 500ms Enter
44+
Sleep 500ms
45+
Type "envfetch get HELLO_VAR" Sleep 500ms Enter
46+
Sleep 500ms
47+
Screenshot "assets/main.png"
48+
# Print list of variables
49+
Type "envfetch print" Sleep 500ms Enter
50+
Sleep 500ms
51+
# Interactive mode
52+
Type "envfetch interactive" Sleep 500ms Enter
53+
Sleep 3s
54+
Down@2
55+
Sleep 600ms
56+
Ctrl+r
57+
Sleep 1s
58+
Down@4
59+
Sleep 600ms
60+
Up
61+
Sleep 2s
62+
Screenshot "assets/interactive_main.png"
63+
Type "a"
64+
Screenshot "assets/interactive_add.png"
65+
Escape
66+
Ctrl+q
9467

9568
Sleep 5s

0 commit comments

Comments
 (0)