mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
Use Dynamic Linter
The new lint.sh script no longer requires the use of a matrix and instead dynamically finds and lints directories. Signed-off-by: Brett Logan <lindluni@github.com>
This commit is contained in:
parent
855c8e4db3
commit
c81ba4c411
2 changed files with 44 additions and 102 deletions
|
|
@ -74,68 +74,6 @@ jobs:
|
|||
displayName: Lint
|
||||
pool:
|
||||
vmImage: ubuntu-18.04
|
||||
strategy:
|
||||
matrix:
|
||||
Basic-Application-Go:
|
||||
DIRECTORY: asset-transfer-basic
|
||||
LANGUAGE: go
|
||||
TYPE: application
|
||||
Basic-Application-Java:
|
||||
DIRECTORY: asset-transfer-basic
|
||||
LANGUAGE: java
|
||||
TYPE: application
|
||||
Basic-Application-Javascript:
|
||||
DIRECTORY: asset-transfer-basic
|
||||
LANGUAGE: javascript
|
||||
TYPE: application
|
||||
Basic-Chaincode-Go:
|
||||
DIRECTORY: asset-transfer-basic
|
||||
LANGUAGE: go
|
||||
TYPE: chaincode
|
||||
Basic-Chaincode-Java:
|
||||
DIRECTORY: asset-transfer-basic
|
||||
LANGUAGE: java
|
||||
TYPE: chaincode
|
||||
Basic-Chaincode-Javascript:
|
||||
DIRECTORY: asset-transfer-basic
|
||||
LANGUAGE: javascript
|
||||
TYPE: chaincode
|
||||
Basic-Chaincode-Typescript:
|
||||
DIRECTORY: asset-transfer-basic
|
||||
LANGUAGE: typescript
|
||||
TYPE: chaincode
|
||||
Ledger-Application-Java:
|
||||
DIRECTORY: asset-transfer-ledger-queries
|
||||
LANGUAGE: java
|
||||
TYPE: application
|
||||
Ledger-Chaincode-Go:
|
||||
DIRECTORY: asset-transfer-ledger-queries
|
||||
LANGUAGE: go
|
||||
TYPE: chaincode
|
||||
Ledger-Chaincode-Javascript:
|
||||
DIRECTORY: asset-transfer-ledger-queries
|
||||
LANGUAGE: javascript
|
||||
TYPE: chaincode
|
||||
PrivateData-Application-Javascript:
|
||||
DIRECTORY: asset-transfer-private-data
|
||||
LANGUAGE: javascript
|
||||
TYPE: application
|
||||
PrivateData-Chaincode-Go:
|
||||
DIRECTORY: asset-transfer-private-data
|
||||
LANGUAGE: go
|
||||
TYPE: chaincode
|
||||
SBE-Chaincode-Typescript:
|
||||
DIRECTORY: asset-transfer-sbe
|
||||
LANGUAGE: typescript
|
||||
TYPE: chaincode
|
||||
SBE-Chaincode-Java:
|
||||
DIRECTORY: asset-transfer-sbe
|
||||
LANGUAGE: java
|
||||
TYPE: chaincode
|
||||
Secured-Chaincode-Go:
|
||||
DIRECTORY: asset-transfer-secured-agreement
|
||||
LANGUAGE: go
|
||||
TYPE: chaincode
|
||||
steps:
|
||||
- task: GoTool@0
|
||||
inputs:
|
||||
|
|
@ -146,6 +84,8 @@ jobs:
|
|||
inputs:
|
||||
versionSpec: $(NODE_VER)
|
||||
displayName: Install Node.js
|
||||
- script: npm install -g typescript eslint tslint
|
||||
displayName: Install Javascript Linting Deps
|
||||
- script: ./ci/scripts/lint.sh
|
||||
displayName: Lint Code
|
||||
|
||||
|
|
|
|||
|
|
@ -7,45 +7,47 @@ function print() {
|
|||
echo -e "${GREEN}${1}${NC}"
|
||||
}
|
||||
|
||||
if [[ "${LANGUAGE}" == "go" ]]; then
|
||||
go get golang.org/x/tools/cmd/goimports
|
||||
dirs=("$(find . -name "*-go" -o -name "*-java" -o -name "*-javascript" -o -name "*-typescript")")
|
||||
for dir in $dirs; do
|
||||
if [[ -d $dir ]]; then
|
||||
print "Linting $dir"
|
||||
pushd $dir
|
||||
if [[ "$dir" =~ "-go" ]]; then
|
||||
go get golang.org/x/tools/cmd/goimports
|
||||
print "Running go vet"
|
||||
go vet ./...
|
||||
print "Running gofmt"
|
||||
output=$(gofmt -l -s $(go list -f '{{.Dir}}' ./...))
|
||||
if [[ "${output}" != "" ]]; then
|
||||
print "The following files contain formatting errors, please run 'gofmt -l -w <path>' to fix these issues:"
|
||||
echo "${output}"
|
||||
fi
|
||||
|
||||
cd "${DIRECTORY}/${TYPE}-${LANGUAGE}"
|
||||
print "Running go vet"
|
||||
go vet ./...
|
||||
|
||||
print "Running gofmt"
|
||||
output=$(gofmt -l -s $(go list -f '{{.Dir}}' ./...))
|
||||
if [[ "${output}" != "" ]]; then
|
||||
print "The following files contain formatting errors, please run 'gofmt -l -w <path>' to fix these issues:"
|
||||
echo "${output}"
|
||||
print "Running goimports"
|
||||
output=$(goimports -l $(go list -f '{{.Dir}}' ./...))
|
||||
if [[ "${output}" != "" ]]; then
|
||||
print "The following files contain import errors, please run 'goimports -l -w <path>' to fix these issues:"
|
||||
echo "${output}"
|
||||
fi
|
||||
elif [[ "$dir" =~ "-javascript" ]]; then
|
||||
print "Running ESLint"
|
||||
if [[ "$dir" =~ "chaincode" ]]; then
|
||||
eslint *.js */**.js
|
||||
else
|
||||
eslint *.js
|
||||
fi
|
||||
elif [[ "$dir" =~ "-java" ]]; then
|
||||
if [[ -f "pom.xml" ]]; then
|
||||
print "Running Maven Build"
|
||||
mvn clean package
|
||||
else
|
||||
print "Running Gradle Build"
|
||||
./gradlew build
|
||||
fi
|
||||
elif [[ "$dir" =~ "-typescript" ]]; then
|
||||
print "Running TSLint"
|
||||
tslint --project .
|
||||
fi
|
||||
popd
|
||||
fi
|
||||
|
||||
print "Running goimports"
|
||||
output=$(goimports -l $(go list -f '{{.Dir}}' ./...))
|
||||
if [[ "${output}" != "" ]]; then
|
||||
print "The following files contain import errors, please run 'goimports -l -w <path>' to fix these issues:"
|
||||
echo "${output}"
|
||||
fi
|
||||
elif [[ "${LANGUAGE}" == "java" ]]; then
|
||||
cd "${DIRECTORY}/${TYPE}-${LANGUAGE}"
|
||||
print "Running Gradle Build"
|
||||
./gradlew build
|
||||
elif [[ "${LANGUAGE}" == "javascript" ]]; then
|
||||
npm install -g eslint
|
||||
cd "${DIRECTORY}/${TYPE}-${LANGUAGE}"
|
||||
print "Running ESLint"
|
||||
if [[ "${TYPE}" == "chaincode" ]]; then
|
||||
eslint *.js */**.js
|
||||
else
|
||||
eslint *.js
|
||||
fi
|
||||
elif [[ "${LANGUAGE}" == "typescript" ]]; then
|
||||
npm install -g typescript tslint
|
||||
cd "${DIRECTORY}/${TYPE}-${LANGUAGE}"
|
||||
print "Running TSLint"
|
||||
tslint --project .
|
||||
else
|
||||
echo "Language not supported"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
Loading…
Reference in a new issue