Skip to content

Commit eba356c

Browse files
committed
Add test to CI and improve portability
I fixed a few path gotchas and added the test so it runs with unpinned dependencies.
1 parent f9e90f3 commit eba356c

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ jobs:
9797
if: success() || failure()
9898
run: pytest --cov=src --cov-report=lcov
9999

100+
- name: Check quickstart, including installation
101+
if: success() || failure()
102+
run: bash ./docs/source/quickstart/test_quickstart_example.sh
103+
100104
coverage:
101105
runs-on: ubuntu-latest
102106
needs: [base_coverage, test]
Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
set -e
2-
1+
# cd to this directory
2+
cd "${BASH_SOURCE%/*}/"
3+
rm -rf .venv
4+
# Override the virtual environment so we use the package
5+
# from this repo, not from pypi
6+
python -m venv .venv
7+
source .venv/bin/activate
8+
pip install ../../..
39
# Run the quickstart code in the background
4-
bash ./quickstart_example.sh 2>&1 &
10+
bash "quickstart_example.sh" 2>&1 &
511
quickstart_example_pid=$!
612
echo "Spawned example with PID $quickstart_example_pid"
713

14+
function killserver {
15+
# Stop the server that we spawned.
16+
children=$(ps -o pid= --ppid "$quickstart_example_pid")
17+
kill $children
18+
echo "Killed spawned processes: $children"
19+
20+
wait
21+
}
22+
trap killserver EXIT
23+
824
# Wait for it to respond
925
# Loop until the command is successful or the maximum number of attempts is reached
1026
ret=7
1127
attempt_num=0
12-
while [[ $ret == 7 ]] && [ $attempt_num -le 50 ]; do
28+
while [[ $ret == 7 ]]; do # && [ $attempt_num -le 50 ]
1329
# Execute the command
1430
ret=0
1531
curl -sf -m 10 http://localhost:5000/counter/counter || ret=$?
@@ -29,22 +45,17 @@ while [[ $ret == 7 ]] && [ $attempt_num -le 50 ]; do
2945
done
3046
echo "Final return value $ret on attempt $attempt_num"
3147

32-
# Check the Python client code
33-
echo "Running Python client code"
34-
(. .venv/bin/activate && python counter_client.py)
35-
36-
37-
# Get the spawned server's PID
38-
children=$(ps -o pid= --ppid "$quickstart_example_pid")
39-
kill $children
40-
echo "Killed spawned processes: $children"
41-
42-
wait
43-
4448
if [[ $ret == 0 ]]; then
4549
echo "Success"
46-
exit 0
4750
else
4851
echo "Curl returned $ret, likely something went wrong."
4952
exit -1
50-
fi
53+
fi
54+
55+
# Check the Python client code
56+
echo "Running Python client code"
57+
(source .venv/bin/activate && python counter_client.py)
58+
if [[ $? != 0 ]]; then
59+
echo "Python client code did not run OK."
60+
exit -1
61+
fi

0 commit comments

Comments
 (0)