Skip to content

Commit

Permalink
Merge pull request #1447 from zhuangqh/add-shellcheck
Browse files Browse the repository at this point in the history
fix: correct shell script format via shellcheck reports
  • Loading branch information
allencloud authored Jun 1, 2018
2 parents dabd3bb + 96f0609 commit 74e5ac7
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 118 deletions.
25 changes: 25 additions & 0 deletions .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This Dockerfile is used to build an image which is used in circle CI
# to run the the following check or validation:
# markdownlint
# misspell
# ShellCheck
FROM ubuntu:16.04

RUN apt-get update \
&& apt-get install -y rubygems git curl \
&& gem install rake \
&& gem install bundler \
&& apt-get clean

# install markdownlint
RUN git clone https://github.com/markdownlint/markdownlint.git \
&& cd markdownlint && git checkout v0.4.0 && rake install

# install misspell
RUN git clone https://github.com/client9/misspell.git \
&& cd misspell && curl -L -o ./install-misspell.sh https://git.io/misspell && sh ./install-misspell.sh

RUN mv misspell/bin/misspell /usr/local/bin/

# install shellcheck
RUN apt-get install shellcheck
14 changes: 10 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
misspell-and-markdown-lint:
markdownlint-misspell-shellcheck:
docker:
- image: allencloud/mdlmisspell:v0.1
# this image is build from Dockerfile located in ./.circleci/Dockerfile
- image: allencloud/pouchlint:v0.1
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
steps:
- checkout
Expand All @@ -15,7 +16,12 @@ jobs:
find ./ -name "*.md" | grep -v vendor | grep -v extra | grep -v commandline | grep -v .github | grep -v swagger | grep -v api | xargs mdl -r ~MD010,~MD013,~MD024,~MD029,~MD033,~MD036
- run:
name: use opensource tool client9/misspell to correct commonly misspelled English words
command: find ./* -name "*" | grep -v extra | grep -v vendor | xargs misspell -error
command: |
find ./* -name "*" | grep -v extra | grep -v vendor | xargs misspell -error
- run:
name: use ShellCheck (https://github.com/koalaman/shellcheck) to check the validateness of shell scripts in pouch repo
command: |
find ./ -name "*.sh" | grep -v vendor | grep -v extra | xargs shellcheck
code-check:
docker:
Expand Down Expand Up @@ -52,6 +58,6 @@ workflows:
version: 2
ci:
jobs:
- misspell-and-markdown-lint
- markdownlint-misspell-shellcheck
- code-check
- unit-test
24 changes: 12 additions & 12 deletions hack/cri-test/test-cri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
set -o nounset
set -o pipefail

source $(dirname "${BASH_SOURCE[0]}")/test-utils.sh
source "$(dirname "${BASH_SOURCE[0]}")/test-utils.sh"

POUCH_SOCK="/var/run/pouchcri.sock"

Expand All @@ -42,8 +42,8 @@ GOPATH=${GOPATH%%:*}
# Install CNI first
mkdir -p /etc/cni/net.d /opt/cni/bin

git clone https://github.com/containernetworking/plugins $GOPATH/src/github.com/containernetworking/plugins
cd $GOPATH/src/github.com/containernetworking/plugins
git clone https://github.com/containernetworking/plugins "$GOPATH/src/github.com/containernetworking/plugins"
cd "$GOPATH/src/github.com/containernetworking/plugins"

./build.sh
cp bin/* /opt/cni/bin
Expand Down Expand Up @@ -89,26 +89,26 @@ GINKGO=${GOPATH}/bin/ginkgo
GINKGO_PKG=github.com/onsi/ginkgo/ginkgo

# Install critest
if [ ! -x "$(command -v ${CRITEST})" ]; then
if [ ! -x "$(command -v "${CRITEST}")" ]; then
go get -d ${CRITOOL_PKG}/...
cd ${GOPATH}/src/${CRITOOL_PKG}
cd "${GOPATH}/src/${CRITOOL_PKG}"
git fetch --all
git checkout ${CRITOOL_VERSION}
git checkout "${CRITOOL_VERSION}"
make
fi
which ${CRITEST}
which "${CRITEST}"

# Install ginkgo
if [ ! -x "$(command -v ${GINKGO})" ]; then
if [ ! -x "$(command -v "${GINKGO}")" ]; then
go get -u ${GINKGO_PKG}
fi
which ${GINKGO}
which "${GINKGO}"

mkdir -p ${REPORT_DIR}
test_setup ${REPORT_DIR}
mkdir -p "${REPORT_DIR}"
test_setup "${REPORT_DIR}"

# Run cri validation test
sudo env PATH=${PATH} GOPATH=${GOPATH} ${CRITEST} --runtime-endpoint=${POUCH_SOCK} --ginkgo.focus="${CRI_FOCUS}" --ginkgo.skip="${CRI_SKIP}"
sudo env PATH="${PATH}" GOPATH="${GOPATH}" "${CRITEST}" --runtime-endpoint=${POUCH_SOCK} --ginkgo.focus="${CRI_FOCUS}" --ginkgo.skip="${CRI_SKIP}"
test_exit_code=$?

test_teardown
Expand Down
16 changes: 8 additions & 8 deletions hack/cri-test/test-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# limitations under the License.

ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. ${ROOT}/versions
. "${ROOT}/versions"
# POUCH_FLAGS are the extra flags to use when start pouchd.
POUCH_FLAGS=${POUCH_FLAGS:-""}
# RESTART_WAIT_PERIOD is the period to wait before restarting pouchd/containerd.
RESTART_WAIT_PERIOD=${RESTART_WAIT_PERIOD:-10}

POUCH_SOCK=/var/run/pouchcri.sock
# POUCH_SOCK=/var/run/pouchcri.sock

pouch_pid=
containerd_pid=
Expand All @@ -35,22 +35,22 @@ test_setup() {
echo "containerd is not installed, please run hack/make.sh"
exit 1
fi
containerd_pid_command=`pgrep containerd`
containerd_pid_command=$(pgrep containerd)
containerd_pid=${containerd_pid_command}
if [ ! -n "${containerd_pid}" ]; then
keepalive "/usr/local/bin/containerd" ${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
keepalive "/usr/local/bin/containerd" "${RESTART_WAIT_PERIOD}" &> "${report_dir}/containerd.log" &
containerd_pid=$!
fi
# Wait for containerd to be running by using the containerd client ctr to check the version
# of the containerd server. Wait an increasing amount of time after each of five attempts
readiness_check "ctr version"

# Start pouchd
pouch_pid_command=`pgrep pouchd`
pouch_pid_command=$(pgrep pouchd)
pouch_pid=${pouch_pid_command}
if [ ! -n "${pouch_pid}" ]; then
keepalive "pouchd --enable-cri --sandbox-image=gcr.io/google_containers/pause-amd64:3.0 ${POUCH_FLAGS}" \
${RESTART_WAIT_PERIOD} &> ${report_dir}/pouch.log &
"${RESTART_WAIT_PERIOD}" &> "${report_dir}/pouch.log" &
pouch_pid=$!
fi
readiness_check "pouch version"
Expand All @@ -71,11 +71,11 @@ test_teardown() {
# keepalive process is eventually killed in test_teardown.
keepalive() {
local command=$1
echo ${command}
echo "${command}"
local wait_period=$2
while true; do
${command}
sleep ${wait_period}
sleep "${wait_period}"
done
}

Expand Down
2 changes: 1 addition & 1 deletion hack/generate-swagger-models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
# Get the absolute path of this file
DIR="$( cd "$( dirname "$0" )" && pwd )"

swagger generate model -f $DIR/../apis/swagger.yml -t $DIR/../apis -m types
swagger generate model -f "$DIR/../apis/swagger.yml" -t "$DIR/../apis" -m types
10 changes: 5 additions & 5 deletions hack/install_lxcfs_on_centos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
#

yes | yum install autotools-dev m4 autoconf2.13 autobook autoconf-archive gnu-standards autoconf-doc libtool
yes | yum install fuse-devel.$(uname -p)
yes | yum install pam-devel.$(uname -p)
yes | yum install fuse.$(uname -p)
yes | yum install "fuse-devel.$(uname -p)"
yes | yum install "pam-devel.$(uname -p)"
yes | yum install "fuse.$(uname -p)"

TMP=$(mktemp -d)
trap "rm -rf $TMP" EXIT
trap 'rm -rf "$TMP"' EXIT

cd $TMP &&
cd "$TMP" &&
git clone -b stable-2.0 https://github.com/lxc/lxcfs.git &&
cd lxcfs

Expand Down
Loading

0 comments on commit 74e5ac7

Please sign in to comment.