Skip to content

Commit 375d195

Browse files
authored
Merge pull request #155 from tenox7/development
Release ttyplot 1.6.0 (fixes #134)
2 parents 07ce2f9 + 0d1a71d commit 375d195

16 files changed

Lines changed: 1052 additions & 234 deletions

.github/workflows/codespell.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2023 Sebastian Pipping <sebastian@pipping.org>
2+
# Licensed under Apache License Version 2.0
3+
4+
name: Enforce codespell-clean spelling
5+
6+
on:
7+
pull_request:
8+
push:
9+
schedule:
10+
- cron: '0 3 * * 5' # Every Friday at 3am
11+
workflow_dispatch:
12+
13+
# Minimum permissions for security
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
codespell:
19+
name: Enforce codespell-clean spelling
20+
runs-on: ubuntu-22.04
21+
steps:
22+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
23+
24+
- uses: codespell-project/actions-codespell@94259cd8be02ad2903ba34a22d9c13de21a74461 # v2.0
25+
with:
26+
# "nd" (with lowercase "n") is from ".Nd" (with uppercase "n") in ttyplot.1
27+
# https://github.com/codespell-project/codespell/issues/3233#issuecomment-1828026522
28+
ignore_words_list: nd

.github/workflows/linux_and_macos.yml

Lines changed: 83 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33

44
name: Build on Linux/macOS
55

6-
# Drop permissions to minimum, for security
7-
permissions:
8-
contents: read
9-
106
on:
117
pull_request:
128
push:
139
schedule:
1410
- cron: '0 3 * * 5' # Every Friday at 3am
1511
workflow_dispatch:
1612

13+
# Minimum permissions for security
14+
permissions:
15+
contents: read
16+
1717
jobs:
1818
linux:
19-
name: Build (${{ matrix.cc }} on ${{ matrix.runs-on }})
19+
name: Build (${{ matrix.cc }}/${{ matrix.make }} on ${{ matrix.runs-on }})
2020
runs-on: ${{ matrix.runs-on }}
2121
strategy:
2222
fail-fast: false
@@ -26,26 +26,37 @@ jobs:
2626
cxx: g++-13
2727
clang_major_version: null
2828
clang_repo_suffix: null
29+
make: make
2930
runs-on: ubuntu-22.04
3031
- cc: clang-17
3132
cxx: clang++-17
3233
clang_major_version: 17
3334
clang_repo_suffix: -17
35+
make: bmake
3436
runs-on: ubuntu-22.04
3537
- cc: clang-18
3638
cxx: clang++-18
3739
clang_major_version: 18
3840
clang_repo_suffix:
41+
make: bmake
3942
runs-on: ubuntu-22.04
43+
- cc: gcc-11
44+
cxx: g++-11
45+
clang_major_version: null
46+
clang_repo_suffix: null
47+
make: make
48+
runs-on: macos-12
4049
- cc: gcc-13
4150
cxx: g++-13
4251
clang_major_version: null
4352
clang_repo_suffix: null
53+
make: bmake
4454
runs-on: macos-12
4555
- cc: clang-15
4656
cxx: clang++-15
4757
clang_major_version: 15
4858
clang_repo_suffix: null
59+
make: bsdmake
4960
runs-on: macos-12
5061
steps:
5162
- name: Add Clang/LLVM repositories
@@ -61,14 +72,25 @@ jobs:
6172
run: |-
6273
sudo apt-get update
6374
sudo apt-get install --yes --no-install-recommends \
75+
bmake \
6476
libncurses-dev \
6577
pkg-config
6678
79+
- name: Install build dependencies
80+
if: "${{ runner.os == 'macOS' }}"
81+
run: |-
82+
brew tap homebrew/cask-fonts
83+
brew install \
84+
bmake \
85+
bsdmake \
86+
coreutils
87+
6788
- name: Install build dependency Clang ${{ matrix.clang_major_version }}
6889
if: "${{ runner.os == 'Linux' && contains(matrix.cxx, 'clang') }}"
6990
run: |-
7091
sudo apt-get install --yes --no-install-recommends -V \
71-
clang-${{ matrix.clang_major_version }}
92+
clang-${{ matrix.clang_major_version }} \
93+
libclang-rt-${{ matrix.clang_major_version }}-dev
7294
7395
- name: Add versioned aliases for Clang ${{ matrix.clang_major_version }}
7496
if: "${{ runner.os == 'macOS' && contains(matrix.cxx, 'clang') }}"
@@ -84,23 +106,74 @@ jobs:
84106
env:
85107
CC: ${{ matrix.cc }}
86108
CXX: ${{ matrix.cxx }}
109+
MAKE: ${{ matrix.make }}
87110
run: |-
88-
CFLAGS='-std=gnu99 -pedantic -Werror' make all torture
111+
set -x
112+
113+
# macOS default linker does not seem to support --as-needed,
114+
# would error out saying "ld: unknown option: --as-needed"
115+
if [[ ${{ runner.os }} = macOS ]]; then
116+
as_needed=
117+
else
118+
as_needed='-Wl,--as-needed'
119+
fi
120+
121+
# ASan: https://clang.llvm.org/docs/AddressSanitizer.html
122+
# UBSan: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
123+
sanitizer='-fsanitize=address,undefined -fno-sanitize-recover=all'
124+
125+
${MAKE} --version 2>/dev/null || true
126+
127+
CFLAGS="-std=gnu99 -pedantic -Werror ${sanitizer}" LDFLAGS="${as_needed} ${sanitizer}" ${MAKE}
89128
90129
- name: 'Install'
130+
env:
131+
MAKE: ${{ matrix.make }}
91132
run: |-
92133
set -x -o pipefail
93-
make install DESTDIR="${PWD}"/ROOT/
134+
${MAKE} install DESTDIR="${PWD}"/ROOT/
94135
find ROOT/ | sort | xargs ls -ld
95136
96137
- name: 'Uninstall'
138+
env:
139+
MAKE: ${{ matrix.make }}
97140
run: |-
98141
set -x
99-
make uninstall DESTDIR="${PWD}"/ROOT/
142+
${MAKE} uninstall DESTDIR="${PWD}"/ROOT/
100143
[[ "$(find ROOT/ -not -type d | tee /dev/stderr)" == '' ]] # i.e. fail CI if leftover files
101144
145+
- name: 'Run UI tests'
146+
run: |-
147+
./recordings/record.sh
148+
rm -Rf recordings/venv/
149+
150+
- name: 'Upload UI test renderings for inspection'
151+
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
152+
with:
153+
name: ttyplot_ui_test_${{ github.sha }}_${{ matrix.runs-on }}_${{ matrix.cc }}_${{ matrix.make }}
154+
path: recordings/actual*
155+
if-no-files-found: error
156+
157+
- name: 'Evaluate UI test results'
158+
run: |-
159+
cat <<"EOF"
160+
################################################################
161+
## If this step FAILS you can get the expected ANSI screenshots
162+
## back in sync with reality by running:
163+
##
164+
## $ ./recordings/get_back_in_sync.sh
165+
##
166+
## More details on the topic can be found in CONTRIBUTING.md .
167+
################################################################
168+
EOF
169+
170+
diff -u recordings/{expected,actual}.txt
171+
rm -f recordings/actual.txt
172+
102173
- name: 'Clean'
174+
env:
175+
MAKE: ${{ matrix.make }}
103176
run: |-
104177
set -x -o pipefail
105-
make clean
178+
${MAKE} clean
106179
[[ "$(git ls-files -o | tee /dev/stderr | wc -l)" -eq 0 ]]

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
torture
1+
stresstest
22
ttyplot

CONTRIBUTING.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Welcome to ttyplot!
2+
3+
This file documents how to contribute to ttyplot and
4+
things to know before facing them. It will likely
5+
never be complete, but if something important
6+
turns out to be missing here, let's add it!
7+
8+
9+
## Problem: The CI complains that the UI test failed
10+
11+
The CI does basic UI testing by making ANSI "screenshots"
12+
of the running application and comparing them
13+
against pre-recorded ANSI "screenshots" `recordings/expected.txt`.
14+
When you make changes to ttyplot that change the *runtime appearance* of
15+
ttyplot, the CI will hopefully catch these changes
16+
and reject them as a regression. In a case where these
17+
changes are made with full intention, the screenshots
18+
that the CI is comparing to at `recordings/expected.txt`
19+
will then need to be regenerated.
20+
For your convenience, an easy way to do that is:
21+
22+
```console
23+
$ ./recordings/get_back_in_sync.sh
24+
```
25+
26+
The script will re-render these screenshots and even create a Git commit
27+
for you.
28+
29+
For all that to work well on macOS, you would need to install:
30+
31+
```console
32+
$ brew tap homebrew/cask-fonts
33+
$ brew install \
34+
coreutils
35+
```
36+
37+
On a Debian-based Linux including Ubuntu, you would need to install:
38+
39+
```console
40+
$ sudo apt-get update
41+
$ sudo apt-get install --no-install-recommends -V \
42+
python3-venv
43+
```

Makefile

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ DESTDIR ?=
22
PREFIX ?= /usr/local
33
MANPREFIX ?= $(PREFIX)/man
44
CFLAGS += -Wall -Wextra
5-
LDLIBS += `pkg-config --libs ncurses`
6-
torture: LDLIBS = -lm
5+
CFLAGS += `pkg-config --cflags ncursesw`
6+
LDLIBS += `pkg-config --libs ncursesw` -lm
77

8-
all: ttyplot
8+
all: ttyplot stresstest
99

1010
install: ttyplot ttyplot.1
1111
install -d $(DESTDIR)$(PREFIX)/bin
@@ -18,13 +18,10 @@ uninstall:
1818
rm -f $(DESTDIR)$(MANPREFIX)/man1/ttyplot.1
1919

2020
clean:
21-
rm -f ttyplot torture *.o
21+
rm -f ttyplot stresstest
2222

23-
require_pkgconfig:
24-
which pkg-config
23+
.c:
24+
@pkg-config --version > /dev/null
25+
$(CC) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -o $@
2526

26-
ttyplot.o: require_pkgconfig
27-
28-
torture.o: require_pkgconfig
29-
30-
.PHONY: all clean install uninstall require_pkgconfig
27+
.PHONY: all clean install uninstall

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ ttyplot also supports *counter* style metrics, calculating *rate* by measured ti
203203
## flags
204204

205205
```
206-
ttyplot [-h] [-v] [-2] [-r] [-c plotchar] [-s scale] [-m max] [-M min] [-t title] [-u unit]
206+
ttyplot [-2] [-r] [-c plotchar] [-s scale] [-m max] [-M min] [-t title] [-u unit]
207+
ttyplot -h
208+
ttyplot -v
207209
208210
-2 read two values and draw two plots, the second one is in reverse video
209211
-r rate of a counter (divide value by measured sample interval)
@@ -223,6 +225,21 @@ ttyplot also supports *counter* style metrics, calculating *rate* by measured ti
223225
&nbsp;
224226

225227

228+
## key bindings
229+
230+
231+
when reading data from a pipe, ttyplot accepts the following commands typed at the terminal:
232+
233+
```
234+
q quit
235+
r toggle rate mode
236+
```
237+
238+
these commands do not work if the standard input is a terminal: in this case quit with <kbd>Ctrl</kbd>-<kbd>C</kbd>.
239+
240+
&nbsp;
241+
&nbsp;
242+
226243

227244
## frequently questioned answers
228245

@@ -263,4 +280,6 @@ by default in unix stdio is buffered, you can work around it in [various ways](h
263280
License: Apache 2.0
264281
Copyright (c) 2013-2018 Antoni Sawicki
265282
Copyright (c) 2019-2023 Google LLC
283+
Copyright (c) 2023 Edgar Bonet
284+
Copyright (c) 2023 Sebastian Pipping
266285
```

recordings/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/venv/
2+
/actual.txt

recordings/expected.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[90x20] Frame 1:
2+
+------------------------------------------------------------------------------------------+
3+
| .: ttyplot :. |
4+
| ^ |
5+
| │ |
6+
| │ |
7+
| │ |
8+
| │ |
9+
| │ |
10+
| │ |
11+
| │ |
12+
| │ |
13+
| │ waiting for data from stdin |
14+
| │ |
15+
| │ |
16+
| │ |
17+
| │ |
18+
| │ |
19+
| │ |
20+
| └─────────────────────────────────────────────────────────────────────────────────────> |
21+
| X Thu Jan 1 00:00:00 1970 |
22+
|   https://github.com/tenox7/ttyplot 1.6.0 |
23+
+------------------------------------------------------------------------------------------+
24+
25+
[90x20] Frame 2:
26+
+------------------------------------------------------------------------------------------+
27+
| .: ttyplot :. |
28+
| ^ 4.0   |
29+
| │   |
30+
| │   |
31+
| │   |
32+
| │ 3.0 X |
33+
| │ X |
34+
| │ X |
35+
| │ X |
36+
| │ 2.0  X |
37+
| │  X |
38+
| │  X |
39+
| │  X |
40+
| │ 1.0 XX |
41+
| │ XX |
42+
| │ XX |
43+
| │ XX |
44+
| └─────────────────────────────────────────────────────────────────────────────────────> |
45+
| X last=3.0 min=1.0 max=3.0 avg=2.0 Thu Jan 1 00:00:00 1970 |
46+
|   last=4.0 min=2.0 max=4.0 avg=3.0 https://github.com/tenox7/ttyplot 1.6.0 |
47+
+------------------------------------------------------------------------------------------+
48+
49+
[90x20] Frame 3:
50+
+------------------------------------------------------------------------------------------+
51+
| .: ttyplot :. |
52+
| ^ 4.0   |
53+
| │   |
54+
| │   |
55+
| │   |
56+
| │ 3.0 X |
57+
| │ X |
58+
| │ X |
59+
| │ X |
60+
| │ 2.0  X |
61+
| │ input stream closed  X |
62+
| │  X |
63+
| │  X |
64+
| │ 1.0 XX |
65+
| │ XX |
66+
| │ XX |
67+
| │ XX |
68+
| └─────────────────────────────────────────────────────────────────────────────────────> |
69+
| X last=3.0 min=1.0 max=3.0 avg=2.0 Thu Jan 1 00:00:00 1970 |
70+
|   last=4.0 min=2.0 max=4.0 avg=3.0 https://github.com/tenox7/ttyplot 1.6.0 |
71+
+------------------------------------------------------------------------------------------+
72+

0 commit comments

Comments
 (0)