@@ -5,52 +5,61 @@ if [ -d "$HOME/.local/bin" ]; then
55 export PATH=" $HOME /.local/bin:$PATH "
66fi
77
8+ SRC_ROOT=${SRC_ROOT:- " ${PWD} " }
9+ PYTHON=${PYTHON:- " python3.7" }
10+
11+ TEMP_DIRS=()
12+
813function run_plugin() {
9- python setup.py install
10- cd " $PLUGIN "
11- coverage run setup.py test
12- coverage report -m
14+ # Create a virtualenv
15+ venv_dir=" $( mktemp -d) "
16+ TEMP_DIRS+=(" ${venv_dir} " )
17+ " ${PYTHON} " -m venv " ${venv_dir} "
18+ source " ${venv_dir} /bin/activate"
19+ " ${PYTHON} " -m pip install -U pip
20+
21+ " ${PYTHON} " -m pip install -U " ${SRC_ROOT} "
22+
23+ cd " ${PLUGIN} "
24+ " ${PYTHON} " setup.py test
1325 cd -
1426
15- if [ " x$PLUGIN " = " x." ]; then
16- cd examples
17- python -m pip install -r requirements.txt
18- python -m unittest discover
19- cd ..
27+ if [ " x${PLUGIN} " = " x." ]; then
28+ # Try running create command
29+ plugin_creation_dir=" $( mktemp -d) "
30+ TEMP_DIRS+=(" ${plugin_creation_dir} " )
31+ cd " ${plugin_creation_dir} "
32+ # Plugins we know how to make
33+ PLUGINS=(\
34+ " model" \
35+ " operations" \
36+ " service" \
37+ " source" \
38+ " config" )
39+ for plugin in ${PLUGINS[@]} ; do
40+ dffml service dev create " ${plugin} " " travis-test-${plugin} "
41+ cd " travis-test-${plugin} "
42+ " ${PYTHON} " -m pip install -U .
43+ " ${PYTHON} " setup.py test
44+ cd " ${plugin_creation_dir} "
45+ done
46+
47+ # Run the examples
48+ cd " ${SRC_ROOT} /examples"
49+ " ${PYTHON} " -m pip install -r requirements.txt
50+ " ${PYTHON} " -m unittest discover
51+
52+ # Deactivate venv
53+ deactivate
54+
55+ # Create the docs
56+ cd " ${SRC_ROOT} "
57+ " ${PYTHON} " -m pip install -U -e " ${SRC_ROOT} [dev]"
58+ " ${PYTHON} " -m dffml service dev install
2059 ./scripts/docs.sh
21- # Try running create for real
22- cd $( mktemp -d)
23- # TODO Bash array
24- # Create model
25- dffml service dev create model travis-test-model
26- cd travis-test-model
27- python setup.py install
28- python setup.py test
29- cd ..
30- # Create operations
31- dffml service dev create operations travis-test-operations
32- cd travis-test-operations
33- python setup.py install
34- python setup.py test
35- cd ..
36- # Create service
37- dffml service dev create service travis-test-service
38- cd travis-test-service
39- python setup.py install
40- python setup.py test
41- cd ..
42- # Create source
43- dffml service dev create source travis-test-source
44- cd travis-test-source
45- python setup.py install
46- python setup.py test
47- cd ..
48- # Create config
49- dffml service dev create config travis-test-config
50- cd travis-test-config
51- python setup.py install
52- python setup.py test
53- cd ..
60+
61+ # Run with coverage
62+ " ${PYTHON} " -m coverage run setup.py test
5463 fi
5564}
5665
@@ -84,15 +93,27 @@ function run_whitespace() {
8493}
8594
8695function run_style() {
87- black --check .
96+ black --check " ${SRC_ROOT} "
97+ }
98+
99+ function cleanup_temp_dirs() {
100+ if [ " x${NO_RM_TEMP} " != " x" ]; then
101+ return
102+ fi
103+ for temp_dir in ${TEMP_DIRS[@]} ; do
104+ rm -rf " ${temp_dir} "
105+ done
88106}
89107
90- if [ " x$PLUGIN " != " x" ]; then
108+ # Clean up temporary directories on exit
109+ trap cleanup_temp_dirs EXIT
110+
111+ if [ " x${PLUGIN} " != " x" ]; then
91112 run_plugin
92- elif [ " x$CHANGELOG " != " x" ]; then
113+ elif [ " x${ CHANGELOG} " != " x" ]; then
93114 run_changelog
94- elif [ " x$WHITESPACE " != " x" ]; then
115+ elif [ " x${ WHITESPACE} " != " x" ]; then
95116 run_whitespace
96- elif [ " x$STYLE " != " x" ]; then
117+ elif [ " x${ STYLE} " != " x" ]; then
97118 run_style
98119fi
0 commit comments