Skip to content

Commit ea8e8de

Browse files
committed
Added a TUI installer for the CI tests.
1 parent 7088769 commit ea8e8de

23 files changed

+3240
-28
lines changed

.flake8

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,28 @@ max-line-length = 100
5555
# One can omit the description on the __init__ docstring and simply
5656
# document the parameters, but then flake8 complains about the
5757
# structure of the __init__ doctsring. The D205 and D400 errors are
58-
# precisely those complains. We disable these in order to have a
58+
# precisely those complaints. We disable these in order to have a
5959
# sane way of documenting classes with Sphinx' autoclass.
6060

6161

6262
ignore = B902, D205, D400, D401, D100, W503
6363

6464
# D103 - Missing docstring in public function
6565
#
66-
# Ignore docstrings requirement in tests
66+
# Ignore docstrings requirement in tests.
67+
#
68+
# D101, D102, D103, D107
69+
#
70+
# We don't quite document the installer.
71+
#
72+
# E402 - module level import not at top of file
73+
#
74+
# In the installer, we need to patch Textual for non-unicode terminal
75+
# support, and that needs to be the first thing done before we import
76+
# other stuff.
77+
#
6778

68-
per-file-ignores = tests/*:D103
79+
per-file-ignores =
80+
tests/*: D103
81+
tests/installer/*: D101, D102, D103, D104, D107
82+
tests/installer/main.py: E402, D101, D102, D103, D107

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ updates:
1616
- dependency-name: "pystache"
1717
- dependency-name: "typeguard"
1818
- dependency-name: "packaging"
19+
- dependency-name: "requests"
1920

psij-ci-run

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22

33
usage() {
44
cat <<EOF
5-
Usage: ./psij-ci-run [--help] [--repeat]
6-
--help Displays this message
7-
--repeat If specified, run tests every 24 hours in a loop.
5+
Usage: ./psij-ci-run [--help] [--repeat] [--reschedule HH:MM] [--log]
6+
--help
7+
Displays this message.
8+
--repeat
9+
If specified, run tests every 24 hours in a loop.
10+
--reschedule HH:MM
11+
If specified, reschedule the tests at HH:MM using the
12+
at command.
13+
--log
14+
Disables output and redirects to a log instead. Used
15+
when running the tests automatically.
816
EOF
917
}
1018

@@ -16,12 +24,16 @@ failifempty() {
1624
fi
1725
}
1826

27+
MYPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
28+
cd "$MYPATH"
29+
1930
if [ -f psij-ci-env ]; then
2031
source psij-ci-env
2132
fi
2233

2334
REPEAT=0
2435
RESCHEDULE=0
36+
NO_OUT=0
2537

2638
while [ "$1" != "" ]; do
2739
case "$1" in
@@ -38,13 +50,26 @@ while [ "$1" != "" ]; do
3850
TIME="$2"
3951
shift 2
4052
;;
53+
--log)
54+
NO_OUT=1
55+
shift
56+
;;
4157
*)
4258
echo "Unrecognized command line option: $1."
4359
usage
4460
exit 1
61+
;;
4562
esac
4663
done
4764

65+
if [ "$NO_OUT" == "1" ]; then
66+
exec 1<&-
67+
exec 2<&-
68+
69+
exec 1>>./testing.log
70+
exec 2>&1
71+
fi
72+
4873
if python --version 2>&1 | egrep -q 'Python 3\..*' >/dev/null 2>&1 ; then
4974
PYTHON="python"
5075
else
@@ -68,7 +93,7 @@ if [ "$REPEAT" == "1" ]; then
6893
sleep $TO_SLEEP
6994
done
7095
elif [ "$RESCHEDULE" == "1" ]; then
71-
CMD="./psij-ci-run --reschedule $TIME >> testing.log 2>&1"
96+
CMD="./psij-ci-run --reschedule $TIME --log"
7297
echo "$CMD" | at $TIME
7398
$PYTHON tests/ci_runner.py $MODE
7499
else

psij-ci-setup

Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/bin/bash
22

3+
set -o pipefail
4+
35
if pip --version 2>&1 | egrep -q 'python 3\..*' >/dev/null 2>&1 ; then
46
PIP="pip"
57
else
68
PIP="pip3"
79
fi
810

11+
if python --version 2>&1 | egrep -q 'Python 3\..*' >/dev/null 2>&1 ; then
12+
PYTHON="python"
13+
else
14+
PYTHON="python3"
15+
fi
16+
17+
918
existing_error_trailer() {
1019
echo "If you are certain that you want to install multiple entries, "
1120
echo "you can re-run this script with the \"-f\" flag. "
@@ -50,7 +59,7 @@ cron_existing_error() {
5059
}
5160

5261
cron_install() {
53-
CMD="$CMD >> testing.log 2>&1"
62+
CMD="$CMD --log"
5463
LINE="$MINUTE $HOUR * * * cd \"$MYPATH\" && $CMD"
5564
echo
5665
echo "================================================================"
@@ -109,7 +118,7 @@ at_existing_error() {
109118
}
110119

111120
at_install() {
112-
CMD="$CMD --reschedule $HOUR:$MINUTE >> testing.log 2>&1"
121+
CMD="$CMD --reschedule $HOUR:$MINUTE --log"
113122
echo
114123
echo "================================================================"
115124
echo "The following will be executed:"
@@ -141,7 +150,7 @@ screen_existing_error() {
141150
}
142151

143152
screen_install() {
144-
CMD="$CMD --repeat >> testing.log 2>&1"
153+
CMD="$CMD --repeat --log"
145154
echo
146155
echo "================================================================"
147156
echo "WARNING: Screen sessions do not persist across reboots. Please "
@@ -166,7 +175,7 @@ manual_existing_error() {
166175
}
167176

168177
manual_install() {
169-
CMD="$CMD --repeat >> testing.log 2>&1"
178+
CMD="$CMD --repeat --log"
170179
echo
171180
echo "================================================================"
172181
echo "Please run the following command in the background: "
@@ -271,14 +280,76 @@ check_key() {
271280
fi
272281
}
273282

283+
284+
not_cached() {
285+
if [ ! -d .packages ]; then
286+
return 0
287+
fi
288+
if [ ! -f .packages/req_csum.txt ]; then
289+
return 0
290+
fi
291+
REQ_CSUM=`cat .packages/req_csum.txt`
292+
CRT_CSUM=`cat requirements*.txt | md5sum`
293+
294+
if [ "$REQ_CSUM" != "$CRT_CSUM" ]; then
295+
return 0
296+
else
297+
return 1
298+
fi
299+
}
300+
301+
dots_for_lines() {
302+
while read LINE; do
303+
echo -n .
304+
done
305+
}
306+
307+
install_deps() {
308+
if not_cached; then
309+
echo -n "Installing dependencies..."
310+
311+
exec 3> >(dots_for_lines >> /dev/stdout)
312+
OUT=`$PIP install --target .packages --upgrade -r requirements-tests.txt --no-compile 2>&1 1>&3`
313+
314+
if [ "$?" != "0" ]; then
315+
echo "FAILED"
316+
echo "$OUT"
317+
exit 2
318+
else
319+
echo "Done"
320+
cat requirements*.txt | md5sum >.packages/req_csum.txt
321+
fi
322+
fi
323+
324+
export PYTHONPATH=`pwd`/.packages:$PYTHONPATH
325+
}
326+
327+
274328
FORCE=0
329+
PLAIN=0
275330

276-
if [ "$1" == "-f" ]; then
277-
FORCE=1
331+
while [ "$1" != "" ]; do
332+
if [ "$1" == "-f" ]; then
333+
FORCE=1
334+
elif [ "$1" == "--plain" ]; then
335+
PLAIN=1
336+
else
337+
echo "Unknown option \"$1\""
338+
exit 1
339+
fi
278340
shift
279-
fi
341+
done
280342

281343
MYPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
344+
cd "$MYPATH"
345+
346+
if [ "$PLAIN" != "1" ]; then
347+
install_deps
348+
349+
echo "Running TUI installer. To run the normal installer, use \"psij-ci-setup --plain\""
350+
351+
exec $PYTHON tests/run_installer.py
352+
fi
282353

283354
echo
284355
echo "================================================================"
@@ -297,21 +368,8 @@ check_email
297368

298369
check_key
299370

300-
cd "$MYPATH"
301-
302-
echo -n "Installing dependencies..."
303-
304-
OUT=`$PIP install --target .packages --upgrade -r requirements-tests.txt 2>&1`
305-
306-
if [ "$?" != "0" ]; then
307-
echo "FAILED"
308-
echo $OUT
309-
exit 2
310-
else
311-
echo "Done"
312-
fi
371+
install_deps
313372

314-
export PYTHONPATH=`pwd`/.packages:$PYTHONPATH
315373

316374
HOUR=`echo $(($RANDOM % 24))`
317375
MINUTE=`echo $(($RANDOM % 60))`

requirements-tests.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ requests >= 2.25.1
88
pytest-cov
99
pytest-timeout
1010
filelock >= 3.4, < 3.18
11+
textual
12+
tree-sitter
13+
tree-sitter-bash

tests/installer/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)