File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,27 @@ for file in **/requirements.txt; do
101
101
file=$( dirname " $file " )
102
102
cd " $file "
103
103
104
+ # First we look up the environment variable `RUN_TESTS_DIRS`. If
105
+ # the value is set, we'll iterate through the colon separated
106
+ # directory list.
107
+ if [[ -n " ${RUN_TESTS_DIRS:- } " ]]; then
108
+ IFS=" :"
109
+ read -ra run_tests_dirs <<< " ${RUN_TESTS_DIRS}"
110
+ match=0
111
+ for d in " ${run_tests_dirs[@]} " ; do
112
+ # If the current dir starts with one of the
113
+ # RUN_TESTS_DIRS, we should run the tests.
114
+ if [[ " ${file} " = " ${d} " * ]]; then
115
+ match=1
116
+ break
117
+ fi
118
+ done
119
+ IFS=" "
120
+ if [[ $match -eq 0 ]]; then
121
+ continue
122
+ fi
104
123
# If $DIFF_FROM is set, use it to check for changes in this directory.
105
- if [[ -n " ${DIFF_FROM:- } " ]] && [[ " ${test_all} " == " false" ]]; then
124
+ elif [[ -n " ${DIFF_FROM:- } " ]] && [[ " ${test_all} " == " false" ]]; then
106
125
git diff --quiet " $DIFF_FROM " .
107
126
CHANGED=$?
108
127
if [[ " $CHANGED " -eq 0 ]]; then
@@ -146,6 +165,9 @@ for file in **/requirements.txt; do
146
165
echo -e " \n Testing completed.\n"
147
166
fi
148
167
168
+ # Remove noxfile.py if it's not tracked by git.
169
+ git ls-files --error-unmatch noxfile.py > /dev/null 2>&1 | rm noxfile.py
170
+
149
171
done
150
172
cd " $ROOT "
151
173
Original file line number Diff line number Diff line change 38
38
# TRAMPOLINE_IMAGE_SOURCE: The location of the Dockerfile.
39
39
# RUN_TESTS_SESSION: The nox session to run.
40
40
# TRAMPOLINE_BUILD_FILE: The script to run in the docker container.
41
+ # RUN_TESTS_DIR: A colon separated directory list relative to the
42
+ # project root.
41
43
42
44
set -euo pipefail
43
45
245
247
# Passing down env vars
246
248
for e in " ${pass_down_envvars[@]} "
247
249
do
248
- docker_flags+=(" --env" " ${e} =${! e} " )
250
+ if [[ -n " ${! e:- } " ]]; then
251
+ docker_flags+=(" --env" " ${e} =${! e} " )
252
+ fi
249
253
done
250
254
251
255
# If arguments are given, all arguments will become the commands run
252
256
# in the container, otherwise run TRAMPOLINE_BUILD_FILE.
253
-
254
257
if [[ $# -ge 1 ]]; then
255
258
log_yellow " Running the given commands '" " ${@: 1} " " ' in the container."
256
259
readonly commands=(" ${@: 1} " )
Original file line number Diff line number Diff line change @@ -18,6 +18,10 @@ required_envvars+=(
18
18
)
19
19
20
20
pass_down_envvars+=(
21
+ "BUILD_SPECIFIC_GCLOUD_PROJECT"
22
+ "REPORT_TO_BUILD_COP_BOT"
23
+ # The nox session to run.
24
+ "RUN_TESTS_DIRS"
21
25
"RUN_TESTS_SESSION"
22
26
)
23
27
You can’t perform that action at this time.
0 commit comments