File tree Expand file tree Collapse file tree 21 files changed +157
-63
lines changed Expand file tree Collapse file tree 21 files changed +157
-63
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,9 @@ jobs:
161
161
run : .github/scripts/check_docs.sh
162
162
163
163
- name : Test gifs
164
- run : gifs/generate_gifs.sh $(ls gifs/scenarios/)
164
+ run : |
165
+ SKIP_RENDER=true
166
+ gifs/generate_gifs.sh $(ls gifs/scenarios/)
165
167
166
168
checks :
167
169
timeout-minutes : 15
Original file line number Diff line number Diff line change @@ -196,9 +196,18 @@ function updateFile(){
196
196
197
197
p " cat $1 "
198
198
rougify --theme tulip $1
199
+
199
200
sleep 1
200
201
}
201
202
203
+ function clearConsole(){
204
+ clear
205
+ }
206
+
207
+ function doSleep(){
208
+ sleep $1
209
+ }
210
+
202
211
check_pv
203
212
#
204
213
# handle some default params
Original file line number Diff line number Diff line change
1
+ # Mock of demo magic, for running on CI
2
+
3
+ function p() {
4
+ echo " running: $@ "
5
+ }
6
+
7
+ function pe() {
8
+ p " $@ "
9
+ run_cmd " $@ "
10
+ }
11
+
12
+ function pei {
13
+ NO_WAIT=true pe " $@ "
14
+ }
15
+
16
+ function cmd() {
17
+ run_cmd " ${command} "
18
+ }
19
+
20
+ function run_cmd() {
21
+ eval " $@ "
22
+ }
23
+
24
+ function updateFile(){
25
+ rm -f $1
26
+ if [ $# -eq 1 ]; then
27
+ while IFS= read -r data; do echo " $data " >> $1 ; done ;
28
+ else
29
+ echo $2 > $1
30
+ fi
31
+
32
+ p " cat $1 "
33
+ rougify --theme tulip $1
34
+
35
+ doSleep 1
36
+ }
37
+
38
+ function clearConsole(){
39
+ echo clear
40
+ }
41
+
42
+ function doSleep(){
43
+ echo sleep $1
44
+ }
Original file line number Diff line number Diff line change @@ -12,21 +12,23 @@ test -f $OUT/failures.txt && rm $OUT/failures.txt
12
12
13
13
docker build gifs --tag gif-renderer
14
14
docker build gifs/svg_render/ --tag svg_rendrer
15
+ tty && TTY_OPS=" -it"
15
16
16
17
for name in " $@ "
17
18
do
18
19
echo processing $name
19
20
svg_render_mappings=" -v $SCRIPT_DIR /../website/static/img:/data -v $OUT /.scala:/out"
20
21
svg_render_ops=" --in /out/$name .cast --width 70 --height 20 --term iterm2 --padding 20"
21
- echo " start"
22
+ echo " start with $TTY_OPS "
22
23
23
- # generate termnail session
24
- docker run --rm -it -v $OUT /.scala:/data/out gif-renderer ./run_scenario.sh $name || (
24
+ # Run the scenario
25
+ docker run --rm $TTY_OPS -v $OUT /.scala:/data/out gif-renderer ./run_scenario.sh $name || (
25
26
echo " Scenario failed: $name " &&
26
27
echo $name >> $OUT /failures.txt
27
28
)
28
- # render svgs
29
- if [ -z " $SKIP_RENDER " ]; then
29
+
30
+ # do not render gifs without TTY
31
+ if [ -n " $TTY_OPS " ]; then
30
32
docker run --rm $svg_render_mappings svg_rendrer a $svg_render_ops --out /data/$name .svg --profile " /profiles/light"
31
33
docker run --rm $svg_render_mappings svg_rendrer a $svg_render_ops --out /data/dark/$name .svg --profile " /profiles/dark"
32
34
fi
Original file line number Diff line number Diff line change @@ -23,7 +23,16 @@ echo "Done with $?"
23
23
test -f status.txt && rm status.txt
24
24
25
25
# do recording
26
- asciinema rec --overwrite --command=" $script -n" $SCRIPT_DIR /out/$name .cast
26
+ tty &&
27
+ # do recording with tty
28
+ asciinema rec --overwrite --command=" $script -n" $SCRIPT_DIR /out/$name .cast ||
29
+ # without just run the command
30
+ (
31
+ export ASCIINEMA_REC=true &&
32
+ # remove magic from demo...
33
+ cp $SCRIPT_DIR /demo-no-magic.sh $SCRIPT_DIR /demo-magic.sh &&
34
+ $script -n
35
+ )
27
36
28
37
test -f status.txt || (
29
38
echo " Scenarion $sctip failed." &&
Original file line number Diff line number Diff line change @@ -15,22 +15,22 @@ if [[ -z "${ASCIINEMA_REC}" ]]; then
15
15
else
16
16
. $SCRIPT_DIR /../demo-magic.sh
17
17
# # hide the evidence
18
- clear
18
+ clearConsole
19
19
20
20
# Put your stuff here
21
21
p scala-cli
22
22
scala-cli
23
23
p java
24
24
java
25
25
26
- sleep 2
26
+ doSleep 2
27
27
28
28
pe " curl -sSLf https://virtuslab.github.io/scala-cli-packages/scala-setup.sh | sh"
29
29
pe ' source ~/.profile'
30
30
pe " echo 'println(\" Hello from scala-cli\" )' | scala-cli -"
31
31
32
32
33
33
# Wait a bit to read output of last command
34
- sleep 2
34
+ doSleep 2
35
35
echo " " && echo " ok" > status.txt
36
36
fi
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -e
4
+
5
+ # #######################
6
+ # include the magic
7
+ # #######################
8
+
9
+ SCRIPT_DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd)
10
+
11
+ if [[ -z " ${ASCIINEMA_REC} " ]]; then
12
+ # Code here will be run before the recording session
13
+ # Warm up scala-cli
14
+ # echo "println(1)" | scala-cli -
15
+ # or do other preparation (e.g. create code)
16
+ echo OK
17
+ else
18
+ . $SCRIPT_DIR /../demo-magic.sh
19
+ # hide the evidence
20
+ clearConsole
21
+
22
+ # Put your stuff here
23
+ # pe "echo 'println(\"<description>\")' | scala-cli -"
24
+
25
+ # Wait a bit to read output of last command
26
+ # doSleep 2
27
+ echo " " && echo " ok" > status.txt && echo " ok" > status.txt
28
+ fi
Original file line number Diff line number Diff line change @@ -16,18 +16,18 @@ if [[ -z "${ASCIINEMA_REC}" ]]; then
16
16
else
17
17
. $SCRIPT_DIR /../demo-magic.sh
18
18
# # hide the evidence
19
- clear
19
+ clearConsole
20
20
21
21
# Put your stuff here
22
22
cat << EOF | updateFile Main.scala
23
23
@main def hello() = {println("Hello "+"world")}
24
24
EOF
25
- sleep 2
25
+ doSleep 2
26
26
pe ' scala-cli .'
27
27
pe ' scala-cli fmt .'
28
28
p " cat Main.scala"
29
29
rougify --theme tulip Main.scala
30
30
pe ' scala-cli package .'
31
- sleep 4
31
+ doSleep 4
32
32
echo " " && echo " ok" > status.txt
33
33
fi
Original file line number Diff line number Diff line change 20
20
else
21
21
. $SCRIPT_DIR /../demo-magic.sh
22
22
# # hide the evidence
23
- clear
23
+ clearConsoleConsole
24
24
25
25
cat << EOF | updateFile demo.scala
26
26
@main def demo(args: String *) =
29
29
30
30
pe " scala-cli compile demo.scala" || true
31
31
32
- sleep 5
32
+ doSleep 5
33
33
34
- clear
34
+ clearConsoleConsole
35
35
36
36
cat << EOF | updateFile demo.scala
37
37
def niceArgs(args: String*): String =
@@ -40,11 +40,11 @@ def niceArgs(args: String*): String =
40
40
@main def demo(args: String*) = println(niceArgs(args*))
41
41
EOF
42
42
43
- pe " scala-cli demo.scala -- Ala jake Mike"
43
+ pe " scala-cli demo.scala -- Ala jake Mike" || echo " FAILED! "
44
44
45
- sleep 5
45
+ doSleep 5
46
46
47
- clear
47
+ clearConsoleConsole
48
48
49
49
cat << EOF | updateFile demo.test.scala
50
50
// using lib "org.scalameta::munit:0.7.29"
62
62
pe " scala-cli test demo.scala demo.test.scala" || true
63
63
64
64
# Wait a bit to read output of last command
65
- sleep 5
65
+ doSleep 5
66
66
echo " " && echo " ok" > status.txt
67
67
fi
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ if [[ -z "${ASCIINEMA_REC}" ]]; then
15
15
else
16
16
. $SCRIPT_DIR /../demo-magic.sh
17
17
# # hide the evidence
18
- clear
18
+ clearConsole
19
19
20
20
cat << EOF | updateFile HelloWorld.scala
21
21
object HelloWorld {
29
29
pe " scala-cli HelloWorld.scala"
30
30
31
31
# Wait a bit to read output of last command
32
- sleep 5
33
- clear
32
+ doSleep 5
33
+ clearConsole
34
34
cat << EOF | updateFile HelloWorld.sc
35
35
println("Hello world from script")
36
36
EOF
37
37
38
38
pe " scala-cli HelloWorld.sc"
39
39
40
- sleep 5
40
+ doSleep 5
41
41
echo " " && echo " ok" > status.txt
42
42
fi
You can’t perform that action at this time.
0 commit comments