Skip to content

Commit d456096

Browse files
committed
chore: run system tests only for modified packages
1 parent daf5ab8 commit d456096

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

.kokoro/system.sh

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,40 @@ pwd
3838
# A file for running system tests
3939
system_test_script="${PROJECT_ROOT}/.kokoro/system-single.sh"
4040

41+
# This is needed in order for `git diff` to succeed
42+
git config --global --add safe.directory $(realpath .)
43+
4144
# Run system tests for each package with directory packages/*/tests/system
4245
for dir in `find 'packages' -type d -wholename 'packages/*/tests/system'`; do
4346
# Get the path to the package by removing the suffix /tests/system
4447
package=$(echo $dir | cut -f -2 -d '/')
45-
echo "Running system tests for ${package}"
46-
pushd ${package}
47-
# Temporarily allow failure.
48+
should_test=false
49+
50+
files_to_check=${package}/CHANGELOG.md
51+
52+
echo "checking changes with 'git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- ${files_to_check}'"
4853
set +e
49-
${system_test_script}
50-
ret=$?
54+
package_modified=$(git diff "${KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH}...${KOKORO_GITHUB_PULL_REQUEST_COMMIT}" -- ${files_to_check} | wc -l)
5155
set -e
52-
if [ ${ret} -ne 0 ]; then
53-
RETVAL=${ret}
56+
if [[ "${package_modified}" -eq 0 ]]; then
57+
echo "no change detected in ${files_to_check}, skipping"
58+
else
59+
echo "change detected in ${files_to_check}"
60+
should_test=true
5461
fi
55-
popd
56-
done
62+
if [ "${should_test}" = true ]; then
63+
echo "Running system tests for ${package}"
5764

65+
pushd ${package}
66+
# Temporarily allow failure.
67+
set +e
68+
${system_test_script}
69+
ret=$?
70+
set -e
71+
if [ ${ret} -ne 0 ]; then
72+
RETVAL=${ret}
73+
fi
74+
popd
75+
fi
76+
done
5877
exit ${RETVAL}

0 commit comments

Comments
 (0)