From 9a293110239ab09d29ac55c7871c4b690521622a Mon Sep 17 00:00:00 2001 From: Cristina Pauna Date: Fri, 19 Apr 2019 16:53:27 +0300 Subject: [PATCH] Add code verification tools JIRA: IEC-2 Tools used to verify code style and correctness. Usage command: tox -e coala Change-Id: I9440349239446a6042664bdbb67f08fa0bc578b3 Signed-off-by: Cristina Pauna --- .coafile | 44 +++++++++++++++++++++++ ci/labs/arm/virtual1.yaml | 4 +-- ci/labs/arm/virtual2.yaml | 4 +-- src/foundation/hot/k8s_master_init.sh | 1 + src/foundation/scripts/cni/calico/calico.yaml | 27 +++++++------- src/foundation/scripts/cni/calico/etcd-amd64.yaml | 14 ++++---- src/foundation/scripts/cni/calico/etcd-arm64.yaml | 14 ++++---- src/foundation/scripts/cni/calico/rbac.yaml | 18 +++++----- src/foundation/scripts/config.sh | 1 + src/use_cases/seba_on_arm/install/install.sh | 2 +- tox.ini | 17 +++++++-- 11 files changed, 102 insertions(+), 44 deletions(-) create mode 100644 .coafile diff --git a/.coafile b/.coafile new file mode 100644 index 0000000..dbc38bc --- /dev/null +++ b/.coafile @@ -0,0 +1,44 @@ +[all] +ignore = .tox/**, + .git/**, + .gitignore, + .gitreview, + .gitmodules, + **.sw?, + **.orig + +[all.GitCommit] +bears = GitCommitBear +ignore_length_regex = Signed-off-by, + Also-by, + Co-authored-by, + http://, + https:// + +[all.reStructuredText] +bears = SpaceConsistencyBear +files = docs/**.rst +use_spaces = true +ignore = .git/**, + .tox/** + +[all.ShellCheck] +bears = ShellCheckBear,SpaceConsistencyBear +files = **.sh +shell = bash +use_spaces = true + +[all.YAML] +bears = YAMLLintBear +files = **.yaml, **.yml +use_spaces = true +ignore_length_regex = ^.*https?:// +max_line_length = 120 +ignore = src/use_cases/ + +[all.Python] +bears = PyLintBear +files = **.py +use_spaces = true +pylint_disable = E0401, W0401, C0111 +ignore = src/use_cases/ diff --git a/ci/labs/arm/virtual1.yaml b/ci/labs/arm/virtual1.yaml index 3a4a681..be600bd 100644 --- a/ci/labs/arm/virtual1.yaml +++ b/ci/labs/arm/virtual1.yaml @@ -10,8 +10,8 @@ version: 1.0 details: - pod_owner: ENEA AB - contact: armband@enea.com + pod_owner: Arm IEC team + contact: blueprints@lists.akraino.org # use hashtag iec lab: ENEA lab location: Stockholm, Sweden type: production diff --git a/ci/labs/arm/virtual2.yaml b/ci/labs/arm/virtual2.yaml index 6486af8..d1f210d 100644 --- a/ci/labs/arm/virtual2.yaml +++ b/ci/labs/arm/virtual2.yaml @@ -10,8 +10,8 @@ version: 1.0 details: - pod_owner: ENEA AB - contact: armband@enea.com + pod_owner: Arm IEC team + contact: blueprints@lists.akraino.org # use hashtag iec lab: ENEA lab location: Stockholm, Sweden type: production diff --git a/src/foundation/hot/k8s_master_init.sh b/src/foundation/hot/k8s_master_init.sh index 23be336..79ac03d 100644 --- a/src/foundation/hot/k8s_master_init.sh +++ b/src/foundation/hot/k8s_master_init.sh @@ -10,6 +10,7 @@ git clone https://gerrit.akraino.org/r/iec cd iec/src/foundation/scripts ./k8s_common.sh ./k8s_master.sh k8s_master_ip k8s_pod_net_cidr k8s_svc_net_cidr +# shellcheck source=/dev/null . ${HOME}/.profile ./setup-cni.sh k8s_cluster_ip k8s_pod_net_cidr token=$(kubeadm token list --skip-headers | awk 'END{print $1}') diff --git a/src/foundation/scripts/cni/calico/calico.yaml b/src/foundation/scripts/cni/calico/calico.yaml index 3f74490..8b3da19 100644 --- a/src/foundation/scripts/cni/calico/calico.yaml +++ b/src/foundation/scripts/cni/calico/calico.yaml @@ -18,7 +18,7 @@ data: # If you're using TLS enabled etcd uncomment the following. # You must also populate the Secret below with these files. etcd_ca: "" # "/calico-secrets/etcd-ca" - etcd_cert: "" # "/calico-secrets/etcd-cert" + etcd_cert: "" # "/calico-secrets/etcd-cert" etcd_key: "" # "/calico-secrets/etcd-key" # Configure the Calico backend to use. calico_backend: "bird" @@ -71,13 +71,13 @@ metadata: name: calico-etcd-secrets namespace: kube-system data: - # Populate the following files with etcd TLS configuration if desired, but leave blank if - # not using TLS for etcd. - # This self-hosted install expects three files with the following names. The values - # should be base64 encoded strings of the entire contents of each file. - # etcd-key: null - # etcd-cert: null - # etcd-ca: null +# Populate the following files with etcd TLS configuration if desired, but leave blank if +# not using TLS for etcd. +# This self-hosted install expects three files with the following names. The values +# should be base64 encoded strings of the entire contents of each file. +# etcd-key: null +# etcd-cert: null +# etcd-ca: null --- @@ -220,9 +220,9 @@ spec: readinessProbe: exec: command: - - /bin/calico-node - - -bird-ready - - -felix-ready + - /bin/calico-node + - -bird-ready + - -felix-ready periodSeconds: 10 volumeMounts: - mountPath: /lib/modules @@ -384,8 +384,8 @@ spec: readinessProbe: exec: command: - - /usr/bin/check-status - - -r + - /usr/bin/check-status + - -r volumes: # Mount in the etcd TLS secrets with mode 400. # See https://kubernetes.io/docs/concepts/configuration/secret/ @@ -401,4 +401,3 @@ kind: ServiceAccount metadata: name: calico-kube-controllers namespace: kube-system - diff --git a/src/foundation/scripts/cni/calico/etcd-amd64.yaml b/src/foundation/scripts/cni/calico/etcd-amd64.yaml index 86fda95..e3d0aa3 100644 --- a/src/foundation/scripts/cni/calico/etcd-amd64.yaml +++ b/src/foundation/scripts/cni/calico/etcd-amd64.yaml @@ -45,14 +45,14 @@ spec: fieldRef: fieldPath: status.podIP command: - - /usr/local/bin/etcd + - /usr/local/bin/etcd args: - - --name=calico - - --data-dir=/var/etcd/calico-data - - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666 - - --listen-client-urls=http://0.0.0.0:6666 - - --listen-peer-urls=http://0.0.0.0:6667 - - --auto-compaction-retention=1 + - --name=calico + - --data-dir=/var/etcd/calico-data + - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666 + - --listen-client-urls=http://0.0.0.0:6666 + - --listen-peer-urls=http://0.0.0.0:6667 + - --auto-compaction-retention=1 volumeMounts: - name: var-etcd mountPath: /var/etcd diff --git a/src/foundation/scripts/cni/calico/etcd-arm64.yaml b/src/foundation/scripts/cni/calico/etcd-arm64.yaml index f408686..940525f 100644 --- a/src/foundation/scripts/cni/calico/etcd-arm64.yaml +++ b/src/foundation/scripts/cni/calico/etcd-arm64.yaml @@ -47,14 +47,14 @@ spec: - name: ETCD_UNSUPPORTED_ARCH value: "arm64" command: - - /usr/local/bin/etcd + - /usr/local/bin/etcd args: - - --name=calico - - --data-dir=/var/etcd/calico-data - - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666 - - --listen-client-urls=http://0.0.0.0:6666 - - --listen-peer-urls=http://0.0.0.0:6667 - - --auto-compaction-retention=1 + - --name=calico + - --data-dir=/var/etcd/calico-data + - --advertise-client-urls=http://$(CALICO_ETCD_IP):6666 + - --listen-client-urls=http://0.0.0.0:6666 + - --listen-peer-urls=http://0.0.0.0:6667 + - --auto-compaction-retention=1 volumeMounts: - name: var-etcd mountPath: /var/etcd diff --git a/src/foundation/scripts/cni/calico/rbac.yaml b/src/foundation/scripts/cni/calico/rbac.yaml index 95115c7..135773c 100644 --- a/src/foundation/scripts/cni/calico/rbac.yaml +++ b/src/foundation/scripts/cni/calico/rbac.yaml @@ -9,8 +9,8 @@ metadata: name: calico-kube-controllers rules: - apiGroups: - - "" - - extensions + - "" + - extensions resources: - pods - namespaces @@ -21,7 +21,7 @@ rules: - watch - list - apiGroups: - - networking.k8s.io + - networking.k8s.io resources: - networkpolicies verbs: @@ -37,9 +37,9 @@ roleRef: kind: ClusterRole name: calico-kube-controllers subjects: -- kind: ServiceAccount - name: calico-kube-controllers - namespace: kube-system + - kind: ServiceAccount + name: calico-kube-controllers + namespace: kube-system --- @@ -72,6 +72,6 @@ roleRef: kind: ClusterRole name: calico-node subjects: -- kind: ServiceAccount - name: calico-node - namespace: kube-system + - kind: ServiceAccount + name: calico-node + namespace: kube-system diff --git a/src/foundation/scripts/config.sh b/src/foundation/scripts/config.sh index 9bd88e0..1a541a7 100755 --- a/src/foundation/scripts/config.sh +++ b/src/foundation/scripts/config.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC2034 # Host user which can log into master and each worker nodes HOST_USER=${HOST_USER:-iec} diff --git a/src/use_cases/seba_on_arm/install/install.sh b/src/use_cases/seba_on_arm/install/install.sh index 5fd5fca..cda8322 100755 --- a/src/use_cases/seba_on_arm/install/install.sh +++ b/src/use_cases/seba_on_arm/install/install.sh @@ -3,7 +3,7 @@ #Modified from https://github.com/cachengo/seba_charts/blob/master/scripts/installSEBA.sh -basepath=$(cd `dirname $0`; pwd) +basepath=$(cd "$(dirname "$0")"; pwd) CORD_REPO=${CORD_REPO:-https://charts.opencord.org} CORD_PLATFORM_VERSION=${CORD_PLATFORM_VERSION:-6.1.0} SEBA_VERSION=${SEBA_VERSION:-1.0.0} diff --git a/tox.ini b/tox.ini index f2f331f..1e35c7a 100644 --- a/tox.ini +++ b/tox.ini @@ -8,9 +8,12 @@ [tox] minversion = 1.6 envlist = - docs, - docs-linkcheck + docs, + docs-linkcheck, + coala, skipsdist = true +passenv = TOX_WORK_DIR +toxworkdir = {env:TOX_WORK_DIR:/tmp/v} [testenv:docs] deps = -rdocs/requirements.txt @@ -22,3 +25,13 @@ whitelist_externals = echo [testenv:docs-linkcheck] deps = -rdocs/requirements.txt commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck + +[testenv:coala] +basepython = python3 +whitelist_externals = rm +deps = + coala + coala-bears +commands = + rm -rf src/use_cases/seba_on_arm/src_repo/ + coala --non-interactive -- 2.16.6