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

Commit 139bfdf

Browse files
committed
[FAB-11032] Handle no package changes on CI
This change adds a check to handle the case where no packages have changed. Additionally Gopkg.lock is treated as a test script change. Change-Id: I04e86e6fc04422b24b3be2b0dafc582bdac03186 Signed-off-by: Troy Ronda <troy@troyronda.com>
1 parent c113065 commit 139bfdf

File tree

9 files changed

+23
-16
lines changed

9 files changed

+23
-16
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
.vscode
1010
debug.test
1111
vendor/
12-
12+
scripts/_go/pkg/
13+
scripts/_go/bin/
1314

1415
# Files auto-generated by docker-compose
1516
test/fixtures/fabricca/tls/certs/server/ca.org*.example.com-cert.pem

test/scripts/expiredorderer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if [ "$TEST_CHANGED_ONLY" = true ]; then
5858
findChangedFiles
5959
cd ${PWD}
6060

61-
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then
61+
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)|Gopkg.lock( |$)) ]]; then
6262
echo "Test scripts, fixtures or metadata changed - running all tests"
6363
else
6464
findChangedPackages

test/scripts/expiredpeer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if [ "$TEST_CHANGED_ONLY" = true ]; then
5858
findChangedFiles
5959
cd ${PWD}
6060

61-
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then
61+
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)|Gopkg.lock( |$)) ]]; then
6262
echo "Test scripts, fixtures or metadata changed - running all tests"
6363
else
6464
findChangedPackages

test/scripts/integration.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ if [ "$TEST_CHANGED_ONLY" = true ]; then
6262
findChangedFiles
6363
cd ${PWD}
6464

65-
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then
65+
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)|Gopkg.lock( |$)) ]]; then
6666
echo "Test scripts, fixtures or metadata changed - running all tests"
6767
else
6868
findChangedPackages

test/scripts/lib/find_packages.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ function findChangedPackages {
6767
done
6868

6969
# Make result unique and filter out non-Go "packages".
70-
CHANGED_PKGS=($(printf "%s\n" "${CHANGED_PKGS[@]}" | sort -u | xargs ${GO_CMD} list 2> /dev/null | tr '\n' ' '))
70+
if [ ${#CHANGED_PKGS[@]} -gt 0 ]; then
71+
CHANGED_PKGS=($(printf "%s\n" "${CHANGED_PKGS[@]}" | sort -u | xargs ${GO_CMD} list 2> /dev/null | tr '\n' ' '))
72+
fi
7173
}
7274

7375
function filterExcludedPackages {
@@ -81,8 +83,6 @@ function filterExcludedPackages {
8183
fi
8284
done
8385
done
84-
85-
FILTERED_PKGS=("${FILTERED_PKGS[@]}")
8686
}
8787

8888
function calcDepPackages {
@@ -102,21 +102,27 @@ function calcDepPackages {
102102
printf "Calculating package dependencies ... (${progress}%%)${progressNewline}"
103103
fi
104104

105-
declare testImports=$(${GO_CMD} list -f '{{.TestImports}}' ${pkg} | tr -d '[]' | tr ' ' '\n' | \
105+
declare -a testImports=($(${GO_CMD} list -f '{{.TestImports}}' ${pkg} | tr -d '[]' | tr ' ' '\n' | \
106106
grep "^${REPO}" | \
107107
grep -v "^${REPO}/vendor/" | \
108108
grep -v "^${REPO}/internal/github.com/" | \
109109
grep -v "^${REPO}/third_party/github.com/" | \
110110
sort -u | \
111-
tr '\n' ' ')
111+
tr '\n' ' '))
112112

113-
declare pkgDeps=$(${GO_CMD} list -f '{{.Deps}}' ${pkg} ${testImports} | tr -d '[]' | tr ' ' '\n' | \
113+
declare -a pkgDeps=($(${GO_CMD} list -f '{{.Deps}}' ${pkg} ${testImports[@]} | tr -d '[]' | tr ' ' '\n' | \
114114
grep "^${REPO}" | \
115115
grep -v "^${REPO}/vendor/" | \
116116
sort -u | \
117-
tr '\n' ' ')
117+
tr '\n' ' '))
118118

119-
declare val=$(${GO_CMD} list ${testImports} ${pkgDeps} | sort -u | tr '\n' ' ')
119+
declare -a depsAndImports=(${testImports[@]})
120+
depsAndImports+=(${pkgDeps[@]})
121+
122+
declare val=""
123+
if [ ${#depsAndImports[@]} -gt 0 ]; then
124+
val=$(${GO_CMD} list ${depsAndImports[@]} | sort -u | tr '\n' ' ')
125+
fi
120126
eval "PKGDEPS__${pkg//[-\.\/]/_}=\"${val}\""
121127
done
122128
printf "Calculating package dependencies ... (100%%)\n"

test/scripts/lib/linter.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function runLinter {
2020
function findChangedLinterPkgs {
2121
findChangedFiles
2222

23-
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then
23+
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)|Gopkg.lock( |$)) ]]; then
2424
echo "Test scripts, fixtures or metadata changed - running all tests"
2525
else
2626
findChangedPackages

test/scripts/revoked.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ if [ "$TEST_CHANGED_ONLY" = true ]; then
5858
findChangedFiles
5959
cd ${PWD}
6060

61-
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then
61+
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)|Gopkg.lock( |$)) ]]; then
6262
echo "Test scripts, fixtures or metadata changed - running all tests"
6363
else
6464
findChangedPackages

test/scripts/unit-pkcs11.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if [ "$TEST_CHANGED_ONLY" = true ]; then
4444
findChangedFiles
4545
cd ${PWD}
4646

47-
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then
47+
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)|Gopkg.lock( |$)) ]]; then
4848
echo "Test scripts, fixtures or metadata changed - running all tests"
4949
else
5050
findChangedPackages

test/scripts/unit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ findPackages
4242
if [ "$TEST_CHANGED_ONLY" = true ]; then
4343
findChangedFiles
4444

45-
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then
45+
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)|Gopkg.lock( |$)) ]]; then
4646
echo "Test scripts, fixtures or metadata changed - running all tests"
4747
else
4848
findChangedPackages

0 commit comments

Comments
 (0)