fabric-samples/ci/scripts/lint.sh
Saptha Surendran 6aa3017ccb
Added hsm samples using Gateway (#759)
* Added hsmm Samples using Gateway

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Used asset-transfer-basic chaincode

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* moved samples under asset-transfer-basic

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* ci pipeline changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* HSM config path changed

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* added pkcs11 enabled ca

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* HSM template added

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* moved  binaries to fabric  samples bin
added go mod and go sum
Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Gopath reverrted back to localDirectory

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* go mod added and cleanup

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* test file directory

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* test file directory

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* migrate to latest gateway and go version

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* hsm script changes
Readme changes
Added npm prepare

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* moved samples out of asset-transfer-basic

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Name changes

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* code refactor

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* go vet by tag

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* pkcs11 tag added to lint script

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* Readme updates

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* application-typescript code refactor

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>

* readme note added

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
2022-07-15 09:18:30 -04:00

50 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
function print() {
GREEN='\033[0;32m'
NC='\033[0m'
echo
echo -e "${GREEN}${1}${NC}"
}
go install golang.org/x/tools/cmd/goimports@latest
dirs=("$(find . -name "*-go" -o -name "*-java" -o -name "*-javascript" -o -name "*-typescript" -not -path '*/.*')")
for dir in $dirs; do
if [[ -d $dir ]] && [[ ! $dir =~ node_modules ]]; then
print "Linting $dir"
pushd $dir
if [[ "$dir" =~ "-go" ]]; then
print "Running go vet"
go vet -tags pkcs11 ./...
print "Running gofmt"
output=$(gofmt -l -s $(go list -tags pkcs11 -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
print "Running goimports"
output=$(goimports -l $(go list -tags pkcs11 -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" || "$dir" =~ "-typescript" ]]; then
print "Installing node modules"
npm install
print "Running Lint"
npm run lint
elif [[ "$dir" =~ "-java" ]]; then
if [[ -f "pom.xml" ]]; then
print "Running Maven Build"
mvn clean package
else
print "Running Gradle Build"
./gradlew build
fi
fi
popd
fi
done