12
12
tags : ["**"]
13
13
workflow_dispatch :
14
14
15
+ defaults :
16
+ run :
17
+ # Both TigerVNC and TurboVNC reports "the input device is not a TTY" if
18
+ # started without a TTY. GitHub Actions environments doesn't come with one,
19
+ # so this provides one.
20
+ #
21
+ # ref: https://github.com/actions/runner/issues/241#issuecomment-842566950
22
+ #
23
+ shell : script --quiet --return --log-out /dev/null --command "bash -e {0}"
24
+
15
25
jobs :
16
- container :
26
+ image-test :
17
27
runs-on : ubuntu-22.04
18
28
timeout-minutes : 10
19
29
strategy :
@@ -28,21 +38,127 @@ jobs:
28
38
29
39
- name : Build image
30
40
run : |
31
- docker build --build-arg vncserver=${{ matrix.vncserver }} -t jupyter-remote-desktop-proxy .
41
+ docker build --progress=plain --build-arg vncserver=${{ matrix.vncserver }} -t test .
42
+
43
+ - name : (inside container) websockify --help
44
+ run : |
45
+ docker run test websockify --help
46
+
47
+ - name : (inside container) vncserver -help
48
+ run : |
49
+ # -help flag is not available for TurboVNC, but it emits the -help
50
+ # equivalent information anyhow if passed -help, but also errors. Due
51
+ # to this, we fallback to use the errorcode of vncsrever -list.
52
+ docker run test bash -c "vncserver -help || vncserver -list > /dev/null"
53
+
54
+ - name : Install websocat, a test dependency"
55
+ run : |
56
+ wget -q https://github.com/vi/websocat/releases/download/v1.12.0/websocat.x86_64-unknown-linux-musl \
57
+ -O /usr/local/bin/websocat
58
+ chmod +x /usr/local/bin/websocat
59
+
60
+ - name : Test vncserver
61
+ if : always()
62
+ run : |
63
+ container_id=$(docker run -d -it -p 5901:5901 test vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
64
+ sleep 1
65
+
66
+ echo "::group::Install netcat, a test dependency"
67
+ docker exec --user root $container_id bash -c '
68
+ apt update
69
+ apt install -y netcat
70
+ '
71
+ echo "::endgroup::"
72
+
73
+ docker exec -it $container_id timeout --preserve-status 1 nc -v localhost 5901 2>&1 | tee -a /dev/stderr | \
74
+ grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; }
75
+
76
+ echo "::group::vncserver logs"
77
+ docker exec $container_id bash -c 'cat ~/.vnc/*.log'
78
+ echo "::endgroup::"
79
+
80
+ docker stop $container_id > /dev/null
81
+ if [ "$TEST_OK" == "false" ]; then
82
+ echo "One or more tests failed!"
83
+ exit 1
84
+ fi
85
+
86
+ - name : Test websockify'ed vncserver
87
+ if : always()
88
+ run : |
89
+ container_id=$(docker run -d -it -p 5901:5901 test websockify --verbose --log-file=/tmp/websockify.log --heartbeat=30 5901 -- vncserver -xstartup /opt/install/jupyter_remote_desktop_proxy/share/xstartup -verbose -fg -geometry 1680x1050 -SecurityTypes None -rfbport 5901)
90
+ sleep 1
91
+
92
+ echo "::group::Install websocat, a test dependency"
93
+ docker exec --user root $container_id bash -c '
94
+ wget -q https://github.com/vi/websocat/releases/download/v1.12.0/websocat.x86_64-unknown-linux-musl \
95
+ -O /usr/local/bin/websocat
96
+ chmod +x /usr/local/bin/websocat
97
+ '
98
+ echo "::endgroup::"
99
+
100
+ docker exec -it $container_id websocat --binary --one-message --exit-on-eof "ws://localhost:5901/" 2>&1 | tee -a /dev/stderr | \
101
+ grep --quiet RFB && echo "Passed test" || { echo "Failed test" && TEST_OK=false; }
102
+
103
+ echo "::group::websockify logs"
104
+ docker exec $container_id bash -c "cat /tmp/websockify.log"
105
+ echo "::endgroup::"
32
106
33
- - name : Smoke test image
107
+ echo "::group::vncserver logs"
108
+ docker exec $container_id bash -c 'cat ~/.vnc/*.log'
109
+ echo "::endgroup::"
110
+
111
+ docker stop $container_id > /dev/null
112
+ if [ "$TEST_OK" == "false" ]; then
113
+ echo "One or more tests failed!"
114
+ exit 1
115
+ fi
116
+
117
+ - name : Test project's proxy to websockify'ed vncserver
118
+ if : always()
34
119
run : |
35
- container_id=$(docker run -d -p 8888:8888 -e JUPYTER_TOKEN=secret jupyter-remote-desktop-proxy)
120
+ container_id=$(docker run -d -it -p 8888:8888 -e JUPYTER_TOKEN=secret test)
121
+ sleep 3
122
+
123
+ curl --silent --fail 'http://localhost:8888/desktop/?token=secret' | grep --quiet 'Jupyter Remote Desktop Proxy' && echo "Passed get index.html test" || { echo "Failed get index.html test" && TEST_OK=false; }
124
+ curl --silent --fail 'http://localhost:8888/desktop/static/dist/viewer.js?token=secret' > /dev/null && echo "Passed get viewer.js test" || { echo "Failed get viewer.js test" && TEST_OK=false; }
125
+
126
+ # The first attempt often fails, but the second always(?) succeeds.
127
+ #
128
+ # This could be related to jupyter-server-proxy's issue
129
+ # https://github.com/jupyterhub/jupyter-server-proxy/issues/459
130
+ # because the client/proxy websocket handshake completes before the
131
+ # proxy/server handshake. This issue is tracked for this project by
132
+ # https://github.com/jupyterhub/jupyter-remote-desktop-proxy/issues/105.
133
+ #
134
+ websocat --binary --one-message --exit-on-eof 'ws://localhost:8888/desktop-websockify/?token=secret' 2>&1 \
135
+ | tee -a /dev/stderr \
136
+ | grep --quiet RFB \
137
+ && echo "Passed initial websocket test" \
138
+ || { \
139
+ echo "Failed initial websocket test" \
140
+ && sleep 1 \
141
+ && websocat --binary --one-message --exit-on-eof 'ws://localhost:8888/desktop-websockify/?token=secret' 2>&1 \
142
+ | tee -a /dev/stderr \
143
+ | grep --quiet RFB \
144
+ && echo "Passed second websocket test" \
145
+ || { echo "Failed second websocket test" && TEST_OK=false; } \
146
+ }
147
+
148
+ echo "::group::jupyter_server logs"
149
+ docker logs $container_id
150
+ echo "::endgroup::"
151
+
152
+ echo "::group::vncserver logs"
153
+ docker exec $container_id bash -c 'cat ~/.vnc/*.log'
154
+ echo "::endgroup::"
36
155
37
- # -help flag is only available for TigerVNC, where TurboVNC can't
38
- # print info without returning an error code.
39
- docker exec $container_id vncserver -help || true
40
- docker exec $container_id vncserver -list
156
+ timeout 5 docker stop $container_id > /dev/null && echo "Passed SIGTERM test" || { echo "Failed SIGTERM test" && TEST_OK=false; }
41
157
42
- sleep 10
43
- curl 'http://localhost:8888/desktop/?token=secret' | grep 'Jupyter Remote Desktop Proxy'
44
- # Test if the built JS file is present in the image
45
- curl 'http://localhost:8888/desktop/dist/viewer.js?token=secret' > /dev/null
158
+ if [ "$TEST_OK" == "false" ]; then
159
+ echo "One or more tests failed!"
160
+ exit 1
161
+ fi
46
162
47
163
# TODO: Check VNC desktop works, e.g. by comparing Playwright screenshots
48
164
# https://playwright.dev/docs/test-snapshots
0 commit comments