|
39 | 39 | # `--only-diff-head` will only run tests on project changes from the
|
40 | 40 | # previous commit.
|
41 | 41 | if [[ $* == *--only-diff-head* ]]; then
|
42 |
| - DIFF_FROM="HEAD~.." |
| 42 | + set +e |
| 43 | + git diff --quiet "HEAD~.." .kokoro/tests .kokoro/docker \ |
| 44 | + .kokoro/trampoline_v2.sh |
| 45 | + CHANGED=$? |
| 46 | + set -e |
| 47 | + if [[ "${CHANGED}" -eq 0 ]]; then |
| 48 | + DIFF_FROM="HEAD~.." |
| 49 | + else |
| 50 | + echo "Changes to test driver files detected. Running full tests." |
| 51 | + fi |
43 | 52 | fi
|
44 | 53 |
|
45 | 54 | if [[ -z "${PROJECT_ROOT:-}" ]]; then
|
@@ -94,97 +103,32 @@ set +e
|
94 | 103 | RTN=0
|
95 | 104 | ROOT=$(pwd)
|
96 | 105 |
|
97 |
| -# Find all requirements.txt in the repository (may break on whitespace). |
98 |
| -for file in **/requirements.txt; do |
99 |
| - cd "$ROOT" |
100 |
| - # Navigate to the project folder. |
101 |
| - file=$(dirname "$file") |
102 |
| - cd "$file" |
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. If the target directory is not under any |
107 |
| - # directory in the list, we skip this directory. |
108 |
| - # This environment variables are primarily for |
109 |
| - # `scripts/run_tests_local.sh`. |
110 |
| - # |
111 |
| - # The value must be a colon separated list of relative paths from |
112 |
| - # the project root. |
113 |
| - # |
114 |
| - # Example: |
115 |
| - # cdn:appengine/flexible |
116 |
| - # run tests for `cdn` and `appengine/flexible` directories. |
117 |
| - # logging/cloud-client |
118 |
| - # only run tests for `logging/cloud-client` directory. |
119 |
| - # |
120 |
| - if [[ -n "${RUN_TESTS_DIRS:-}" ]]; then |
121 |
| - match=0 |
122 |
| - for d in $(echo "${RUN_TESTS_DIRS}" | tr ":" "\n"); do |
123 |
| - # If the current dir starts with one of the |
124 |
| - # RUN_TESTS_DIRS, we should run the tests. |
125 |
| - if [[ "${file}" = "${d}"* ]]; then |
126 |
| - match=1 |
127 |
| - break |
128 |
| - fi |
129 |
| - done |
130 |
| - if [[ $match -eq 0 ]]; then |
131 |
| - continue |
132 |
| - fi |
133 |
| - fi |
134 |
| - # If $DIFF_FROM is set, use it to check for changes in this directory. |
135 |
| - if [[ -n "${DIFF_FROM:-}" ]]; then |
136 |
| - git diff --quiet "$DIFF_FROM" . |
137 |
| - CHANGED=$? |
138 |
| - if [[ "$CHANGED" -eq 0 ]]; then |
139 |
| - # echo -e "\n Skipping $file: no changes in folder.\n" |
140 |
| - continue |
141 |
| - fi |
142 |
| - fi |
| 106 | +test_prog="${PROJECT_ROOT}/.kokoro/tests/run_single_test.sh" |
143 | 107 |
|
144 |
| - echo "------------------------------------------------------------" |
145 |
| - echo "- testing $file" |
146 |
| - echo "------------------------------------------------------------" |
147 |
| - |
148 |
| - # If no local noxfile exists, copy the one from root |
149 |
| - if [[ ! -f "noxfile.py" ]]; then |
150 |
| - PARENT_DIR=$(cd ../ && pwd) |
151 |
| - while [[ "$PARENT_DIR" != "$ROOT" && ! -f "$PARENT_DIR/noxfile-template.py" ]]; |
152 |
| - do |
153 |
| - PARENT_DIR=$(dirname "$PARENT_DIR") |
154 |
| - done |
155 |
| - cp "$PARENT_DIR/noxfile-template.py" "./noxfile.py" |
156 |
| - echo -e "\n Using noxfile-template from parent folder ($PARENT_DIR). \n" |
157 |
| - cleanup_noxfile=1 |
158 |
| - else |
159 |
| - cleanup_noxfile=0 |
160 |
| - fi |
| 108 | +btlr_args=( |
| 109 | + "run" |
| 110 | + "**/requirements.txt" |
| 111 | + "--max-concurrency" |
| 112 | + "30" |
| 113 | +) |
161 | 114 |
|
162 |
| - # Use nox to execute the tests for the project. |
163 |
| - nox -s "$RUN_TESTS_SESSION" |
164 |
| - EXIT=$? |
165 |
| - |
166 |
| - # If REPORT_TO_BUILD_COP_BOT is set to "true", send the test log |
167 |
| - # to the Build Cop Bot. |
168 |
| - # See: |
169 |
| - # https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop. |
170 |
| - if [[ "${REPORT_TO_BUILD_COP_BOT:-}" == "true" ]]; then |
171 |
| - chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop |
172 |
| - $KOKORO_GFILE_DIR/linux_amd64/buildcop |
173 |
| - fi |
| 115 | +if [[ -n "${DIFF_FROM:-}" ]]; then |
| 116 | + btlr_args+=( |
| 117 | + "--git-diff" |
| 118 | + "${DIFF_FROM} ." |
| 119 | + ) |
| 120 | +fi |
174 | 121 |
|
175 |
| - if [[ $EXIT -ne 0 ]]; then |
176 |
| - RTN=1 |
177 |
| - echo -e "\n Testing failed: Nox returned a non-zero exit code. \n" |
178 |
| - else |
179 |
| - echo -e "\n Testing completed.\n" |
180 |
| - fi |
| 122 | +btlr_args+=( |
| 123 | + "--" |
| 124 | + "${test_prog}" |
| 125 | +) |
181 | 126 |
|
182 |
| - # Remove noxfile.py if we copied. |
183 |
| - if [[ $cleanup_noxfile -eq 1 ]]; then |
184 |
| - rm noxfile.py |
185 |
| - fi |
| 127 | +echo "testing/btlr" "${btlr_args[@]}" |
| 128 | + |
| 129 | +testing/btlr "${btlr_args[@]}" |
186 | 130 |
|
187 |
| -done |
| 131 | +RTN=$? |
188 | 132 | cd "$ROOT"
|
189 | 133 |
|
190 | 134 | # Remove secrets if we used decrypt-secrets.sh.
|
|
0 commit comments