Commit e842931b authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

TestPipeline: cleanup common pipeline file.

parent 93b525f2
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ pages:
    #- coverage xml -i
    # rename file because bagdges creation looks for code-coverage.xml file
    #- mv coverage.xml ./reports/code-coverage.xml
  allow_failure: true
  artifacts:
    paths:
      - public 
+41 −47
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@

.build_python_common:
  stage: build_common
  dependencies: []
  image: nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:latest
  tags:
    - k8srunner
@@ -14,32 +13,26 @@
  artifacts:
    paths:
      - ./$COMMON_BUILD_PATH/dist/
  variables:
    COMMON_BUILD_PATH: csp-lmc-common


.build_python_dev_common:
build:csp-lmc-common_pkg_dev: # Executed on a commit
  extends: .build_python_common
  dependencies: []
  script:
    - cd $COMMON_BUILD_PATH
    - python3 setup.py egg_info -b+dev.$CI_COMMIT_SHORT_SHA sdist bdist_wheel
  except:
    - master

.build_python_release_common:
build:csp-lmc-common_pkg:
  extends: .build_python_common
  script:
    - cd $COMMON_BUILD_PATH
    - python3 setup.py egg_info -b+$CI_COMMIT_SHORT_SHA sdist bdist_wheel

build:csp-lmc-common_pkg_dev: # Executed on a commit
  extends: .build_python_dev_common
  variables:
    COMMON_BUILD_PATH: csp-lmc-common

build:csp-lmc-common_pkg:
  extends: .build_python_release_common
  variables:
    COMMON_BUILD_PATH: csp-lmc-common
  only:
    refs:
      - tags
      - master

#
# Build csp-lmc-common image 
@@ -62,19 +55,11 @@ build:csp-lmc-common_pkg:
# Test csp-lmc-common project
#

.test_common:
test:csp-lmc-common:
  image: nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:latest
  stage: test_common
  tags:
    - k8srunner
  artifacts:
    paths:
      - ./$COMMON_BUILD_PATH/build/
  variables:
    COMMON_BUILD_PATH: csp-lmc-common

test:csp-lmc-common:
  extends: .test_common
  stage: test_common
  script:
    - echo $CI_REGISTRY_IMAGE
    - echo $CI_REGISTRY
@@ -90,6 +75,11 @@ test:csp-lmc-common:
    - mv setup_py_test.stdout build/csp-lmc-common-setup-test.stdout
    - mv htmlcov build/csp-lmc-common_htmlcov
    - mv coverage.xml build
  artifacts:
    paths:
      - ./$COMMON_BUILD_PATH/build/
  variables:
    COMMON_BUILD_PATH: csp-lmc-common
#
# linting stage

@@ -122,42 +112,46 @@ linting:csp-lmc-common:
.publish_python_common:
  stage: publish_common
  image: nexus.engageska-portugal.pt/ska-docker/ska-python-buildenv:latest
  variables:
    TWINE_USERNAME: $TWINE_USERNAME
    TWINE_PASSWORD: $TWINE_PASSWORD
  tags:
    - k8srunner
  before_script:
    - python3 -m pip install twine
  variables:
    COMMON_BUILD_PATH: csp-lmc-common

.publish_python_dev_common:
  extends: .publish_python_common
  except: [master]
  script:
    - cd $BUILD_PATH
    - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python3 -m twine upload --repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)

.publish_python_release_common:
  extends: .publish_python_common
  only: [master]
  script:
    - cd $COMMON_BUILD_PATH
    - twine upload --repository-url $PYPI_REPOSITORY_URL dist/* || true
    - twine upload --skip-existing -u $PYPI_USER -p $PYPI_PASS dist/* || true

# upload the common package to the Gitlab Package Repository.
# Se the '--skip-existing' because if the CI/CD pipeline is re-run (without doing a commit)
# the package version does not change and the upload to the repository fails.      
publish:csp-lmc-common_dev:
  extends: .publish_python_dev_common
  extends: .publish_python_common
  dependencies:
    - build:csp-lmc-common_pkg_dev
  variables:
    BUILD_PATH: csp-lmc-common
  variables:
    TWINE_USERNAME: gitlab-ci-token
    TWINE_PASSWORD: $CI_JOB_TOKEN
  script:
    - cd $COMMON_BUILD_PATH
    - python3 -m twine upload --skip-existing --repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)

# upload the package to the Nexus Repository only on project tagging.
publish:csp-lmc-common:
  extends: .publish_python_release_common
  extends: .publish_python_common
  dependencies:
    - build:csp-lmc-common_pkg
  variables:
    COMMON_BUILD_PATH: csp-lmc-common
    TWINE_USERNAME: $TWINE_USERNAME
    TWINE_PASSWORD: $TWINE_PASSWORD
  only:
    refs:
      - tags
  script:
    - cd $COMMON_BUILD_PATH
    - twine upload --repository-url $PYPI_REPOSITORY_URL dist/* || true
    - twine upload --skip-existing -u $PYPI_USER -p $PYPI_PASS dist/* || true



#
# Release csp-lmc-common image on nexus