From: Sylvain Desbureaux Date: Wed, 8 Dec 2021 11:59:32 +0000 (+0100) Subject: [GLOBAL] Move to Gitlab X-Git-Tag: 10.0.0~160^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=oom.git;a=commitdiff_plain;h=d035a0a5fea7bf94cab1b1d6816c61febdfb8eb6 [GLOBAL] Move to Gitlab Add all necessary files in order to move OOM repo to gitlab and also uses gitlab-ci features. Issue-ID: OOM-1 Signed-off-by: Sylvain Desbureaux Change-Id: Ie3ba8d22828b103219d590886a8c58825eff2eef --- 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/kubernetes/contrib/tools/check-for-staging-images.sh b/.ci/check-for-staging-images.sh similarity index 96% rename from kubernetes/contrib/tools/check-for-staging-images.sh rename to .ci/check-for-staging-images.sh index 9705ee6ea8..ae183b61f1 100755 --- a/kubernetes/contrib/tools/check-for-staging-images.sh +++ b/.ci/check-for-staging-images.sh @@ -1,6 +1,7 @@ #!/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. @@ -16,10 +17,6 @@ BASE_URL="https://nexus3.onap.org/repository/docker.release" -if [ "$GERRIT_BRANCH" = "staging" ]; then - exit 0 -fi - 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/|$//')") 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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000..4b15de00b1 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,269 @@ +--- +# 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. +stages: + - linting + - build + - test + +cla_authors: + stage: linting + image: bitnami/git:2 + script: + - . .ci/common.sh + - title "Running cla authors retrieval..." + - exit_code=0 + - RESULT=$(.ci/check-cla-for-multiple-commits.sh 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + needs: [] + rules: + - if: $CI_MERGE_REQUEST_ID + + +pylint: + stage: linting + image: cytopia/pylint + script: + - . .ci/common.sh + - title "Running pylint check..." + - exit_code=0 + - RESULT=$(find kubernetes/ TOSCA/ docs/ -name '*.py' -print0 | xargs -0 pylint 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + needs: [] + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - '**/*.py' + +commit-message: + stage: linting + image: jorisroovers/gitlint:0.16.0 + script: + - . .ci/common.sh + - title "*** Running gitlint..." + - exit_code=0 + - RESULT=$(gitlint 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + needs: [] + rules: + - if: $CI_MERGE_REQUEST_ID + + +trailing-whitespaces: + stage: linting + image: alpine/git:v2.24.1 + script: + - . .ci/common.sh + - title "Running trailing whitespaces check..." + - exit_code=0 + - RESULT=$(.ci/find-trailing-whitespaces.sh 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + needs: [] + rules: + - if: $CI_MERGE_REQUEST_ID + +tabs: + stage: linting + image: alpine/git:v2.24.1 + script: + - . .ci/common.sh + - title "Running tabs check..." + - exit_code=0 + - RESULT=$(.ci/find-tabs.sh 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + needs: [] + rules: + - if: $CI_MERGE_REQUEST_ID + +documentation:doc8: + stage: linting + image: testthedocs/ttd-doc8 + script: + - . .ci/common.sh + - title "Running doc8 check..." + - exit_code=0 + - RESULT=$(doc8 docs 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - docs/**/* + needs: [] + +documentation:link-check: + stage: linting + image: python:3.7 + script: + - . .ci/common.sh + - pip install -r requirements.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.os.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt + - title "Running documentation links check..." + - exit_code=0 + - RESULT=$(sphinx-build -W -b linkcheck -d /tmp/doctrees ./docs/ ./docs/_build/linkcheck 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - docs/**/* + needs: [] + +documentation:spelling: + stage: linting + image: python:3.7 + script: + - . .ci/common.sh + - apt-get update + - apt-get install -qq --yes curl libenchant-2-2 + - curl -LO https://git.onap.org/doc/plain/docs/spelling_wordlist.txt + - pip install -r requirements.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.os.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt + - title "Running documentation spelling check..." + - exit_code=0 + - RESULT=$(sphinx-build -b spelling -d /tmp/doctrees ./docs/ ./docs/_build/spelling 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - docs/**/* + needs: [] + +bashisms: + stage: linting + image: manabu/checkbashisms-docker + script: + - . .ci/common.sh + - title "Running bashisms check..." + - exit_code=0 + - RESULT=$(.ci/check-bashisms 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + rules: + - if: $CI_MERGE_REQUEST_ID + needs: [] + +helm:fast: + stage: linting + services: + - name: bitnami/chartmuseum:latest + alias: chartmuseum + image: alpine/helm:3.6.3 + variables: + SKIP_LINT: "TRUE" + script: + - . .ci/common.sh + - apk add --no-cache make + - helm repo add local http://chartmuseum:8080/ + - helm plugin install --version v0.9.0 https://github.com/chartmuseum/helm-push.git + - title "Running helm fast check..." + - cd kubernetes + - exit_code=0 + - make all || exit_code=$? + - handle_test_result $exit_code "" + - exit $exit_code + needs: [] + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - kubernetes/**/* + +helm:full: + stage: build + services: + - name: bitnami/chartmuseum:latest + alias: chartmuseum + image: alpine/helm:3.6.3 + script: + - . .ci/common.sh + - apk add --no-cache make + - helm repo add local http://chartmuseum:8080/ + - helm plugin install --version v0.9.0 https://github.com/chartmuseum/helm-push.git + - title "Running full helm check..." + - cd kubernetes + - exit_code=0 + - make all || exit_code=$? + - handle_test_result $exit_code "" + - exit $exit_code + needs: + - helm:fast + timeout: 6h + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - kubernetes/**/* + +documentation: + stage: build + image: python:3.7 + script: + - . .ci/common.sh + - apt-get update + - apt-get install --yes graphviz plantuml + - pip install -r requirements.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.os.txt + -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt + - title "Running documentation build..." + - exit_code=0 + - RESULT=$(sphinx-build -q -W -b html -d /tmp/doctrees ./docs/ ./docs/_build/html 2>&1) || exit_code=$? + - handle_test_result $exit_code "$RESULT" + - exit $exit_code + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - docs/* + needs: + - documentation:spelling + - documentation:link-check + - documentation:doc8 + +gating:launch: + stage: test + image: busybox + script: + - . .ci/common.sh + - title "Launching request for a gate" + needs: + - bashisms + - helm:fast + - tabs + - trailing-whitespaces + rules: + - if: $CI_MERGE_REQUEST_ID + changes: + - .ci/* + - .gitlab-ci.yml + - kubernetes/**/* diff --git a/.gitlab/merge_request_templates/Default.md b/.gitlab/merge_request_templates/Default.md new file mode 100644 index 0000000000..73c9e68a22 --- /dev/null +++ b/.gitlab/merge_request_templates/Default.md @@ -0,0 +1,41 @@ +## What does this MR do? + + + +## Related issues + + + +## Author's checklist + +- [ ] The title of the MR is in form of `[IMPACTED] A title` + - `IMPACTED` being an ONAP component (`SO`, `AAI`, ...) or `OOM` component ( + `DOC`, `COMMON`, `GENERAL`, `CI`, ...) +- [ ] You have filled `What does thirs MR do?` +- [ ] You have filled `Related issues` +- [ ] Your last commit message follows the rule: + + ```bash + [IMPACTED] A title + + One or several sentences describing the isssue and the way it's solved + + Issue-ID: PROJECT-1234 + Signed-off-by: Your Name + ``` + +- [ ] Your CLA is submitted in LF + +## Maintener's checklist + +- [ ] Title is OK +- [ ] Commit Message is OK +- [ ] Administrative checks are green +- [ ] Linting checks are green +- [ ] Gate is OK + +/assign @maintainers diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000000..e76164c4b2 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,66 @@ +# 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. + + +[MASTER] +# Specify a score threshold to be exceeded before program exits with error. +fail-under=3.43 + +[MESSAGES CONTROL] +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=all" to +# disable everything first and then reenable specific checks. For example, if +# you want to run only the similarities checker, you can use "--disable=all +# --enable=similarities". If you want to run only the classes checker, but have +# no Warning level messages displayed, use "--disable=all --enable=classes +# --disable=W". +disable=raw-checker-failed, + bad-inline-option, + locally-disabled, + file-ignored, + suppressed-message, + useless-suppression, + deprecated-pragma, + use-symbolic-message-instead, + missing-docstring + + +[REPORTS] +# Set the output format. Available formats are text, parseable, colorized, json +# and msvs (visual studio). You can also give a reporter class, e.g. +# mypackage.mymodule.MyReporterClass. +output-format=colorized + +# Tells whether to display a full report or only the messages. +reports=yes + +# Activate the evaluation score. +score=yes + +[FORMAT] +# Maximum number of characters on a single line. +max-line-length=120 + +[BASIC] + +# Regular expression matching correct method names. Overrides method-naming- +# style. +method-rgx="(([a-z_][a-zA-Z0-9_]{2,})|(_[a-z0-9_]*)|(__[a-zA-Z][a-zA-Z0-9_]+__))$" + +# Regular expression matching correct variable names. Overrides variable- +# naming-style. +variable-rgx="[a-zA-Z_][a-zA-Z0-9_]{1,30}$" + diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000..c255f42940 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,17 @@ +# 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. + +# Translation of INFO.yaml into standard file. +# Mike and Borislav are not set here yet but will be when username is found. +* @kopasiak @sylvainOL diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..a932d65a53 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,88 @@ + + +# Contributing to OOM + +Thanks for taking the time to contribute to OOM! +Please see a few informations on how to dot it. + +## How to become a contributor and submit your own code + +### Environment setup + +In order to be able to check on your side before submitting, you'll need to +install some binaries: + +* helm (satisfying the targeted version as seen in [setup guide]( +docs/oom_cloud_setup_guide.rst#software-requirements). +* chartmuseum (in order to push dependency charts) +* helm push (version 0.9.0 as of today) +* make + +### Linting and testing + +OOM use helm linting in order to check that the templates rendering is correct +with default values. + +first step is to start chartmuseum: + +```shell +nohup chartmuseum --storage="local" --storage-local-rootdir="/tmp/chartstorage" \ + --port 6464 & +``` + +then you add `local` repository to helm: + +```shell +helm repo remove local && helm repo add local http://localhost:6464 +``` + +As full rendering may be extremely long (~9h), you can only lint the common +part and the component you're working on. +Here's an example with AAI: + +```shell +cd kubernetes +make common && make aai +``` + +If you work on non default path, it's strongly advised to also render the +template of your component / subcomponent to be sure it's as expected. + +Here's an example enabling service mesh on aai graphadmin: + +```shell +cd aai/components/ +helm template --release-name onap --debug \ + --set global.ingress.virtualhost.baseurl=toto \ + --set global.ingress.enabled=true --set global.masterPassword="toto" \ + --set global.serviceMesh.enabled=true --set global.serviceMesh.tls=true \ + aai-graphadmin +``` + +All the output will be the rendered YAML if it's OK or you may see an error. +Usually the errors comes from bad indentation or unknown value. + +### Contributing A Patch + +1. Fork the desired repo, develop and test your code changes. +2. Sign the LFN CLA () +3. Submit a pull request. +4. Work with the reviewers on their suggestions. +5. Ensure to rebase to the HEAD of your target branch and squash un-necessary + commits ( + ) + before final merger of your contribution. diff --git a/README.md b/README.md new file mode 100644 index 0000000000..cb4923d426 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ + + +# ONAP Operations Manager + +## Description + +The ONAP Operations Manager (OOM) is responsible for life-cycle management of +the ONAP platform itself; components such as SO, SDNC, etc. + +It is not responsible for the management of services, VNFs or infrastructure +instantiated by ONAP or used by ONAP to host such services or VNFs. + +OOM uses the open-source Kubernetes container management system as a means to +manage the containers that compose ONAP where the containers are hosted either +directly on bare-metal servers or on VMs hosted by a 3rd party management +system. + +OOM ensures that ONAP is easily deployable and maintainable throughout its life +cycle while using hardware resources efficiently. + +Full documentation is available in ONAP documentation in [operations and +administration guides]( +https://docs.onap.org/en/latest/guides/onap-operator/index.html). + +## Contributing + +Please see [contributing](./CONTRIBUTING.md) file to learn on how to contribute + +## Issues + +All issues should be filled in [ONAP Jira](https://jira.onap.org). + diff --git a/kubernetes/Makefile b/kubernetes/Makefile index f96a32a4f0..1b24a7962c 100644 --- a/kubernetes/Makefile +++ b/kubernetes/Makefile @@ -88,7 +88,7 @@ plugins: @cp -R helm $(PACKAGE_DIR)/ check-for-staging-images: - $(ROOT_DIR)/contrib/tools/check-for-staging-images.sh + $(ROOT_DIR)/../.ci/check-for-staging-images.sh helm-repo-update: @$(HELM_BIN) repo update