-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-10849] Improve package dependency checks
This change enables the unit test script to run the linters to enable shared calculation of package dependencies. This change also adds the capability to filter for file types when considering a package to be changed and also includes a package's testdata directory for consideration. Change-Id: I52e2267d129a16e7070bd3a600a8916df1a2f2a4 Signed-off-by: Troy Ronda <[email protected]>
- Loading branch information
Showing
11 changed files
with
168 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This script runs Go linting and vetting tools | ||
|
||
set -e | ||
LINT_CHANGED_ONLY="${LINT_CHANGED_ONLY:-false}" | ||
GO_CMD="${GO_CMD:-go}" | ||
SCRIPT_DIR="$(dirname "$0")" | ||
|
||
REPO="github.com/hyperledger/fabric-sdk-go" | ||
|
||
echo "Running" $(basename "$0") | ||
|
||
source ${SCRIPT_DIR}/lib/find_packages.sh | ||
source ${SCRIPT_DIR}/lib/linter.sh | ||
|
||
# Find all packages that should be linted. | ||
declare -a PKG_SRC=( | ||
"./test" | ||
) | ||
findPackages | ||
|
||
# Reduce Linter checks to changed packages. | ||
if [ "$LINT_CHANGED_ONLY" = true ]; then | ||
findChangedLinterPkgs | ||
fi | ||
|
||
if [ ${#PKGS[@]} -eq 0 ]; then | ||
echo "Skipping tests since no packages were changed" | ||
exit 0 | ||
fi | ||
|
||
runLinter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
GOMETALINT_CMD="gometalinter" | ||
|
||
function runLinter { | ||
packagesToDirs | ||
|
||
echo "Directories to lint: ${DIRS[@]}" | ||
|
||
echo "Running metalinters..." | ||
${GOMETALINT_CMD} --config=./gometalinter.json "${DIRS[@]}" | ||
echo "Metalinters finished successfully" | ||
} | ||
|
||
function findChangedLinterPkgs { | ||
findChangedFiles | ||
|
||
if [[ "${CHANGED_FILES[@]}" =~ ( |^)(test/fixtures/|test/metadata/|test/scripts/|Makefile( |$)) ]]; then | ||
echo "Test scripts, fixtures or metadata changed - running all tests" | ||
else | ||
findChangedPackages | ||
filterExcludedPackages | ||
appendDepPackages | ||
PKGS=(${DEP_PKGS[@]}) | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.