Skip to content

Commit

Permalink
fix(build): fix shellcheck review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <[email protected]>
  • Loading branch information
Abhinandan-Purkait committed Nov 22, 2023
1 parent 61667db commit f594995
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 35 deletions.
1 change: 0 additions & 1 deletion .bettercodehub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ languages:
- go
exclude:
- /pkg/generated/.*
- /vendor/.*
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
reporter: github-pr-review
path: '.'
pattern: '*.sh'
exclude: './.git/*,./vendor/*'
exclude: './.git/*'

unit-test:
# to ignore builds on release
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
reporter: github-pr-review
path: '.'
pattern: '*.sh'
exclude: './vendor/*'

unit-test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/test-cov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
set -e
echo "" > coverage.txt

for d in $(go list ./... | grep -v 'vendor\|pkg/apis\|pkg/client\|tests'); do
for d in $(go list ./... | grep -v 'pkg/apis\|pkg/client\|tests'); do
#TODO - Include -race while creating the coverage profile.
go test -coverprofile=profile.out -covermode=atomic $d

Check warning on line 22 in buildscripts/test-cov.sh

View workflow job for this annotation

GitHub Actions / lint

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./buildscripts/test-cov.sh:22:57:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)
if [ -f profile.out ]; then
Expand Down
4 changes: 2 additions & 2 deletions buildscripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
set -e

# Create a temp dir and clean it up on exit
TEMPDIR=`mktemp -d -t csi-test.XXX`
TEMPDIR=$(mktemp -d -t csi-test.XXX)
trap "rm -rf $TEMPDIR" EXIT HUP INT QUIT TERM

Check warning on line 21 in buildscripts/test.sh

View workflow job for this annotation

GitHub Actions / lint

[shellcheck] reported by reviewdog 🐶 Use single quotes, otherwise this expands now rather than when signalled. [SC2064](https://github.com/koalaman/shellcheck/wiki/SC2064) Raw Output: ./buildscripts/test.sh:21:14:warning:Use single quotes, otherwise this expands now rather than when signalled. [SC2064](https://github.com/koalaman/shellcheck/wiki/SC2064)

# Build the Maya binary for the tests
Expand All @@ -26,7 +26,7 @@ go build -o $TEMPDIR/maya || exit 1

# Run the tests
echo "--> Running tests"
GOBIN="`which go`"
GOBIN="$(which go)"
PATH=$TEMPDIR:$PATH \
$GOBIN test ${GOTEST_FLAGS:--cover -timeout=900s} $($GOBIN list ./... | grep -v 'vendor\|pkg/apis\|pkg/generated\|tests')

Check warning on line 31 in buildscripts/test.sh

View workflow job for this annotation

GitHub Actions / lint

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086) Raw Output: ./buildscripts/test.sh:31:17:info:Double quote to prevent globbing and word splitting. [SC2086](https://github.com/koalaman/shellcheck/wiki/SC2086)

Check warning on line 31 in buildscripts/test.sh

View workflow job for this annotation

GitHub Actions / lint

[shellcheck] reported by reviewdog 🐶 Quote this to prevent word splitting. [SC2046](https://github.com/koalaman/shellcheck/wiki/SC2046) Raw Output: ./buildscripts/test.sh:31:55:warning:Quote this to prevent word splitting. [SC2046](https://github.com/koalaman/shellcheck/wiki/SC2046)

33 changes: 8 additions & 25 deletions ci/ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# shellcheck disable=SC1128
#!/usr/bin/env bash

Check failure on line 16 in ci/ci-test.sh

View workflow job for this annotation

GitHub Actions / lint

[shellcheck] reported by reviewdog 🐶 The shebang must be on the first line. Delete blanks and move comments. [SC1128](https://github.com/koalaman/shellcheck/wiki/SC1128) Raw Output: ./ci/ci-test.sh:16:1:error:The shebang must be on the first line. Delete blanks and move comments. [SC1128](https://github.com/koalaman/shellcheck/wiki/SC1128)

#OPENEBS_OPERATOR=https://raw.githubusercontent.com/openebs/openebs/HEAD/k8s/openebs-operator.yaml
# NDM_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/ndm-operator.yaml
# CSTOR_RBAC=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/rbac.yaml
CSTOR_OPERATOR=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/cstor-operator.yaml
# ALL_CRD=https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/crds/all_cstor_crds.yaml
CSTOR_OPERATOR="https://raw.githubusercontent.com/openebs/cstor-operators/HEAD/deploy/cstor-operator.yaml"

CSI_OPERATOR="$GOPATH/src/github.com/openebs/cstor-csi/deploy/csi-operator.yaml"
SNAPSHOT_CLASS="$GOPATH/src/github.com/openebs/cstor-csi/deploy/snapshot-class.yaml"

#DST_PATH="$GOPATH/src/github.com/openebs"

# Prepare env for runnging BDD tests
# Minikube is already running
# kubectl apply -f $CSTOR_RBAC
# kubectl apply -f $NDM_OPERATOR
# kubectl apply -f $ALL_CRD
kubectl apply -f $CSTOR_OPERATOR
kubectl apply -f "$CSTOR_OPERATOR"
kubectl apply -f ./deploy/csi-operator.yaml
kubectl apply -f ./deploy/snapshot-class.yaml

function dumpCSINodeLogs() {
LC=$1
CSINodePOD=$(kubectl get pods -l app=openebs-csi-node -o jsonpath='{.items[0].metadata.name}' -n kube-system)
kubectl describe po $CSINodePOD -n openebs
kubectl describe po "$CSINodePOD" -n openebs
printf "\n\n"
kubectl logs --tail=${LC} $CSINodePOD -n openebs -c openebs-csi-plugin
kubectl logs --tail="${LC}" "$CSINodePOD" -n openebs -c openebs-csi-plugin
printf "\n\n"
}

function dumpCSIControllerLogs() {
LC=$1
CSIControllerPOD=$(kubectl get pods -l app=openebs-csi-controller -o jsonpath='{.items[0].metadata.name}' -n kube-system)
kubectl describe po $CSIControllerPOD -n openebs
kubectl describe po "$CSIControllerPOD" -n openebs
printf "\n\n"
kubectl logs --tail=${LC} $CSIControllerPOD -n openebs -c openebs-csi-plugin
kubectl logs --tail="${LC}" "$CSIControllerPOD" -n openebs -c openebs-csi-plugin
printf "\n\n"
}

Expand All @@ -57,18 +44,14 @@ kubectl wait --for=condition=Ready --timeout=300s pods/openebs-cstor-csi-control

# Run e2e tests for csi volumes
cd ./tests/e2e

Check warning on line 46 in ci/ci-test.sh

View workflow job for this annotation

GitHub Actions / lint

[shellcheck] reported by reviewdog 🐶 Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164](https://github.com/koalaman/shellcheck/wiki/SC2164) Raw Output: ./ci/ci-test.sh:46:1:warning:Use 'cd ... || exit' or 'cd ... || return' in case cd fails. [SC2164](https://github.com/koalaman/shellcheck/wiki/SC2164)
make e2e-test

if [ $? -ne 0 ]; then
if ! make e2e-test; then
echo "******************** CSI Controller logs***************************** "
dumpCSIControllerLogs 1000

echo "********************* CSI Node logs *********************************"
dumpCSINodeLogs 1000

#echo "******************CSI Maya-apiserver logs ********************"
#dumpMayaAPIServerLogs 1000

echo "get all the pods"
kubectl get pods --all-namespaces

Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ KUBECTL=/usr/local/bin/kubectl


# If you want to change the Kubernetes version for e2e test, specify this variable from command line.
# e.g. $ make TEST_KUBERNETES_VERSION=1.17 test
TEST_KUBERNETES_VERSION=1.17
# e.g. $ make TEST_KUBERNETES_VERSION=1.25.16 test
TEST_KUBERNETES_VERSION=1.25.16

ifeq ($(TEST_KUBERNETES_VERSION),1.17)
KUBERNETES_VERSION=1.17.2
ifeq ($(TEST_KUBERNETES_VERSION),1.25.16)
KUBERNETES_VERSION=1.25.16.2
endif


Expand Down

0 comments on commit f594995

Please sign in to comment.