summaryrefslogtreecommitdiffstats
path: root/.ci
diff options
context:
space:
mode:
Diffstat (limited to '.ci')
-rwxr-xr-x.ci/check-bashisms.sh4
-rwxr-xr-x.ci/check-cla-for-multiple-commits.sh25
-rwxr-xr-x.ci/check-for-staging-images.sh43
-rwxr-xr-x.ci/common.sh50
-rwxr-xr-x.ci/find-tabs.sh38
-rwxr-xr-x.ci/find-trailing-whitespaces.sh39
6 files changed, 199 insertions, 0 deletions
diff --git a/.ci/check-bashisms.sh b/.ci/check-bashisms.sh
index 0dae2255b7..0915725bae 100755
--- a/.ci/check-bashisms.sh
+++ b/.ci/check-bashisms.sh
@@ -14,14 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+set -eu
+
if ! which checkbashisms >/dev/null && ! sudo yum install devscripts-minimal && ! sudo apt-get install devscripts
then
printf "checkbashisms command not found - please install it \n\
(e.g. sudo apt-get install devscripts | yum install devscripts-minimal )\n" >&2
exit 2
fi
+
find . -not -path '*/.*' -name '*.sh' -exec checkbashisms {} + || exit 3
find . -not -path '*/.*' -name '*.failover' -exec checkbashisms -f \{\} + || exit 4
! find . -not -path '*/.*' -name '*.sh' -exec grep 'local .*=' {} + || exit 5
! find . -not -path '*/.*' -name '*.failover' -exec grep 'local .*=' {} + || exit 6
+
exit 0
diff --git a/.ci/check-cla-for-multiple-commits.sh b/.ci/check-cla-for-multiple-commits.sh
new file mode 100755
index 0000000000..13927d9a7d
--- /dev/null
+++ b/.ci/check-cla-for-multiple-commits.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# Copyright © 2021 Orange
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eu
+
+git fetch origin
+
+echo "<------------- AUTHORS LIST ------------->"
+# We are always running on a merge request
+COMMON_ANCESTOR=$(git merge-base HEAD origin/master)
+git log --format=%ae "$COMMON_ANCESTOR..HEAD" | sort | uniq
+echo "<---------------------------------------->"
diff --git a/.ci/check-for-staging-images.sh b/.ci/check-for-staging-images.sh
new file mode 100755
index 0000000000..ae183b61f1
--- /dev/null
+++ b/.ci/check-for-staging-images.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# Copyright © 2020 Samsung Electronics
+# Modification copyright © 2021 Orange
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+BASE_URL="https://nexus3.onap.org/repository/docker.release"
+
+USED_IMAGES=$(grep -r -E -o -h ':\s*onap/.*:.*' | sed -e 's/^: //' -e 's/^ //' | sort | uniq)
+REPO_IMAGES=$(curl -s $BASE_URL/v2/_catalog | jq -r '.repositories[]')
+NOT_AVAILABLE_IMAGES=$(echo "$USED_IMAGES" | grep -vE "$(echo "$REPO_IMAGES" | tr "\n" "|" | sed 's/|$//')")
+USED_IMAGES=$(echo "$USED_IMAGES" | grep -E "$(echo "$REPO_IMAGES" | tr "\n" "|" | sed 's/|$//')")
+for i in $USED_IMAGES; do
+ TMP_IMG=$(echo "$i" | cut -d ":" -f1)
+ TMP_TAG=$(echo "$i" | cut -d ":" -f2)
+ if [ "$LAST_IMG" != "$TMP_IMG" ]; then
+ AVAILABLE_TAGS=$(curl -s $BASE_URL/v2/$TMP_IMG/tags/list | jq -r '.tags[]')
+ fi
+ if ! echo "$AVAILABLE_TAGS" | grep "$TMP_TAG" > /dev/null; then
+ NOT_AVAILABLE_IMAGES="$NOT_AVAILABLE_IMAGES\n$i"
+ fi
+ LAST_IMG="$TMP_IMG"
+ printf "."
+done
+printf "\n"
+if [ -n "$NOT_AVAILABLE_IMAGES" ]; then
+ echo "[ERROR] Only release images are allowed in helm charts."
+ echo "[ERROR] Images not found in release repo:"
+ printf "%b$NOT_AVAILABLE_IMAGES\n"
+ exit 1
+fi
+exit 0
diff --git a/.ci/common.sh b/.ci/common.sh
new file mode 100755
index 0000000000..2a21f29779
--- /dev/null
+++ b/.ci/common.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Copyright © 2021 Orange
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+RED="\033[31m"
+YELLOW="\033[33m"
+BLUE="\033[94m"
+GREEN="\033[32m"
+NO_COLOR="\033[0m"
+
+title(){
+ MSG="$BLUE$1$NO_COLOR"
+ printf "%s" "$MSG"
+}
+
+subtitle() {
+ MSG="$YELLOW$1$NO_COLOR"
+ printf "%s" "$MSG"
+}
+
+
+# Utility method that prints SUCCESS if a test was succesful, or FAIL together with the test output
+handle_test_result(){
+ EXIT_CODE=$1
+ RESULT="$2"
+ # Change color to red or green depending on SUCCESS
+ if [ "$EXIT_CODE" -eq "0" ]; then
+ printf "%sSUCCESS" "${GREEN}"
+ else
+ printf "%sFAIL" "${RED}"
+ fi
+ # Print RESULT if not empty
+ if [ -n "$RESULT" ] ; then
+ printf "\n%s" "$RESULT"
+ fi
+ # Reset color
+ printf "%s" "${NO_COLOR}"
+}
diff --git a/.ci/find-tabs.sh b/.ci/find-tabs.sh
new file mode 100755
index 0000000000..9527445ff7
--- /dev/null
+++ b/.ci/find-tabs.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Copyright © 2021 Orange
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+tabs_lines="" # Lines containing tabs
+
+for file in $(git grep --cached -Il '' | sed -e 's/^/.\//')
+do
+ lines=$(grep -ErnIH "\t" "$file" | grep -v Makefile | cut -f-2 -d ":")
+ if [ -n "$lines" ]; then
+ tabs_lines=$([ -z "$tabs_lines" ] && echo "$lines" || printf "%s\n%s" "$tabs_lines" "$lines")
+ fi
+done
+
+exit_code=0
+
+# If tabs_lines is not empty, change the exit code to 1 to fail the CI.
+if [ -n "$tabs_lines" ]; then
+ printf "\n***** Lines containing tabs *****\n\n"
+ echo "${tabs_lines}"
+ exit_code=1
+fi
+
+exit $exit_code
diff --git a/.ci/find-trailing-whitespaces.sh b/.ci/find-trailing-whitespaces.sh
new file mode 100755
index 0000000000..d01984b54b
--- /dev/null
+++ b/.ci/find-trailing-whitespaces.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Copyright © 2021 Orange
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+tw_lines="" # Lines containing trailing whitespaces.
+
+for file in $(git grep --cached -Il '' | sed -e 's/^/.\//')
+do
+ lines=$(grep -ErnIH " +$" $file | cut -f-2 -d ":")
+ if [ -n "$lines" ]; then
+ tw_lines=$([ -z "$tw_lines" ] && echo "$lines" || printf "%s\n%s" "$tw_lines" "$lines")
+ fi
+done
+
+exit_code=0
+
+
+# If tw_lines is not empty, change the exit code to 1 to fail the CI.
+if [ -n "$tw_lines" ]; then
+ printf "\n***** Lines containing trailing whitespace *****\n\n"
+ echo "${tw_lines}"
+ exit_code=1
+fi
+
+exit $exit_code