Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 3572c6e

Browse files
committed
ci: Run examples for plugins
Signed-off-by: John Andersen <[email protected]>
1 parent 8c2fd83 commit 3572c6e

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

.ci/run.sh

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ PYTHON=${PYTHON:-"python3.7"}
1010

1111
TEMP_DIRS=()
1212

13+
function run_plugin_examples() {
14+
cd "${SRC_ROOT}/${PLUGIN}/examples"
15+
if [ -f "requirements.txt" ]; then
16+
"${PYTHON}" -m pip install -r requirements.txt
17+
fi
18+
# Run example tests in top level examples directory
19+
for dir in $(find . -type d); do
20+
# Run example tests in examples subdirectories
21+
cd "${SRC_ROOT}/${PLUGIN}/examples"
22+
cd "${dir}"
23+
"${PYTHON}" -m unittest discover -v
24+
done
25+
cd "${SRC_ROOT}/${PLUGIN}"
26+
}
27+
1328
function run_plugin() {
1429
# Create a virtualenv
1530
venv_dir="$(mktemp -d)"
@@ -18,20 +33,28 @@ function run_plugin() {
1833
source "${venv_dir}/bin/activate"
1934
"${PYTHON}" -m pip install -U pip twine
2035

21-
"${PYTHON}" -m pip install -U "${SRC_ROOT}"
36+
"${PYTHON}" -m pip install -U -e "${SRC_ROOT}"
2237

2338
if [ "x${PLUGIN}" = "xmodel/tensorflow_hub" ]; then
24-
"${PYTHON}" -m pip install -U "${SRC_ROOT}/model/tensorflow"
39+
"${PYTHON}" -m pip install -U -e "${SRC_ROOT}/model/tensorflow"
2540
fi
2641

2742
cd "${PLUGIN}"
2843
PACKAGE_NAME=$(dffml service dev setuppy kwarg name setup.py)
44+
# Install
2945
"${PYTHON}" -m pip install -e .
46+
# Run the tests
3047
"${PYTHON}" setup.py test
48+
# Run examples if they exist and we aren't at the root
49+
if [ -d "examples" ] && [ "x${PLUGIN}" != "x." ]; then
50+
run_plugin_examples
51+
fi
52+
# Uninstall
3153
"${PYTHON}" -m pip uninstall -y "${PACKAGE_NAME}"
32-
cd -
54+
cd "${SRC_ROOT}"
3355

3456
if [ "x${PLUGIN}" = "x." ]; then
57+
exit 0
3558
# Try running create command
3659
plugin_creation_dir="$(mktemp -d)"
3760
TEMP_DIRS+=("${plugin_creation_dir}")
@@ -56,10 +79,7 @@ function run_plugin() {
5679
"${PYTHON}" -m dffml service dev install
5780

5881
# Run the examples
59-
cd "${SRC_ROOT}/examples"
60-
"${PYTHON}" -m pip install -r requirements.txt
61-
"${PYTHON}" -m unittest discover
62-
cd "${SRC_ROOT}"
82+
run_plugin_examples
6383

6484
# Deactivate venv
6585
deactivate

0 commit comments

Comments
 (0)