aboutsummaryrefslogtreecommitdiffstats
path: root/.gitlab-ci.yml
diff options
context:
space:
mode:
Diffstat (limited to '.gitlab-ci.yml')
-rw-r--r--.gitlab-ci.yml145
1 files changed, 145 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..5ed14e3
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,145 @@
+---
+ stages:
+ - linting
+ - unit_test
+ - build
+ - test
+ - deploy
+
+ image: docker:git
+ services:
+ - docker:dind
+ variables:
+ DOCKER_DRIVER: overlay
+ # Variables for pytest.gitlab-ci.yml
+ PYTHON_VERSIONS: "v3.7 v3.8 v3.9 v3.10"
+ COVERAGE_FILE: sdk-tests-cov.xml
+ # Variables for Container-Scanning.gitlab-ci.yml
+ CI_APPLICATION_REPOSITORY: $CI_REGISTRY_IMAGE #/$CI_COMMIT_REF_SLUG
+ CI_APPLICATION_TAG: $CI_COMMIT_REF_SLUG #$CI_COMMIT_SHA
+ # Variable for pylint/pydocstyle/SAST/Code-Quality.gitlab-ci.yml
+ SRC_PATH: '/src'
+ DOC_PATH: '/docs'
+ # Variable for SAST
+ SAST_EXCLUDED_PATHS: "docs,integration_tests,scripts,tests"
+ SAST_BANDIT_EXCLUDED_PATHS: "docs,integration_tests,scripts,tests"
+
+ .before_script_docker: &before_script_docker
+ before_script:
+ - docker login -u gitlab-ci-token -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"
+
+ build_master:
+ stage: build
+ <<: *before_script_docker
+ script:
+ - docker build -t "$CI_REGISTRY_IMAGE:latest" .
+ - docker push "$CI_REGISTRY_IMAGE:latest"
+ rules:
+ - if: '$CI_COMMIT_BRANCH == "master"'
+
+ build_testing:
+ stage: build
+ <<: *before_script_docker
+ script:
+ - docker build -t "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}" .
+ - docker push "$CI_REGISTRY_IMAGE:${CI_COMMIT_REF_SLUG}"
+ rules:
+ - if: '$CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != "master"'
+
+ build_stable:
+ stage: build
+ <<: *before_script_docker
+ script:
+ - docker build -t "$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG}" .
+ - docker push "$CI_REGISTRY_IMAGE:${CI_COMMIT_TAG}"
+ rules:
+ - if: '$CI_COMMIT_TAG'
+
+ .integration_tests: &integration_tests
+ stage: test
+ variables:
+ FF_NETWORK_PER_BUILD: 1 # Enable https://docs.gitlab.com/runner/executors/docker.html#network-per-build feature
+ services:
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdc:develop
+ alias: sdc.api.fe.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-sdnc:latest
+ alias: sdnc.api.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-so:latest
+ alias: so.api.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-aai:latest
+ alias: aai.api.sparky.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-clamp:develop
+ alias: clamp.api.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-cds:latest
+ alias: cds.api.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-msb-k8s:latest
+ alias: msb.k8s.api.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dcae/mock-ves:latest
+ alias: ves.api.simpledemo.onap.org
+ - name: registry.gitlab.com/orange-opensource/lfn/onap/mock_servers/mock-dmaap:latest
+ alias: dmaap.api.simpledemo.onap.org
+ script:
+ - pip install .
+ - pip install pytest mock # mock is needed as pytest parse all files before selection
+ - PYTHONPATH=$PYTHONPATH:integration_tests/ ONAP_PYTHON_SDK_SETTINGS="urls" pytest --verbose -c /dev/null --junitxml=pytest-integration.xml integration_tests
+ artifacts:
+ reports:
+ junit: pytest-*.xml
+
+ integration_tests:3.7:
+ image: python:3.7
+ <<: *integration_tests
+
+ integration_tests:3.8:
+ image: python:3.8
+ <<: *integration_tests
+
+ integration_tests:3.9:
+ image: python:3.9
+ <<: *integration_tests
+
+ integration_tests:3.10:
+ image: python:3.10
+ <<: *integration_tests
+
+ pages:
+ stage: deploy
+ image:
+ name: python:3.7
+ script:
+ - chmod +x scripts/build_all_branches_in.sh
+ - scripts/build_all_branches_in.sh
+ artifacts:
+ paths:
+ - public
+ except:
+ variables:
+ - $JOBS_DISABLED
+
+ upload:
+ stage: deploy
+ image:
+ name: python:3.8
+ script:
+ - pip install -r upload-requirements.txt
+ - python setup.py sdist bdist_wheel
+ - twine upload --non-interactive dist/*
+ rules:
+ - if: '$CI_COMMIT_TAG'
+
+ # https://docs.gitlab.com/ee/update/deprecations.html#dependency-scanning-python-39-and-36-image-deprecation
+ gemnasium-python-dependency_scanning:
+ image:
+ name: registry.gitlab.com/gitlab-org/security-products/analyzers/gemnasium-python:2-python-3.9
+
+ include:
+ - remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pylint.gitlab-ci.yml'
+ - remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/-/raw/master/pytest.gitlab-ci.yml'
+ - remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pydocstyle.gitlab-ci.yml'
+ - remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/doc8.gitlab-ci.yml'
+ - remote: 'https://gitlab.com/Orange-OpenSource/lfn/ci_cd/gitlab-ci-templates/raw/master/pyup.gitlab-ci.yml'
+ - template: License-Scanning.gitlab-ci.yml
+ - template: Dependency-Scanning.gitlab-ci.yml
+ - template: Jobs/Code-Quality.gitlab-ci.yml
+ - template: SAST.gitlab-ci.yml
+ - template: Container-Scanning.gitlab-ci.yml