Skip to content
Snippets Groups Projects
Commit 5e1f0fee authored by Katleho Madisa's avatar Katleho Madisa
Browse files

Merge branch 'sar-255/Publish-package-to-CAR' into 'main'

SAR-255 Included build_wheel.yml file to publish package to the new CAR

See merge request ska-telescope/ska-tango-base!57
parents b17dac24 10ad3067
No related branches found
No related tags found
No related merge requests found
FROM nexus.engageska-portugal.pt/ska-tango-images/pytango-builder:9.3.3.3 AS buildenv FROM artefact.skao.int/ska-tango-images-pytango-builder:9.3.10 AS buildenv
RUN apt-get update && apt-get install gnupg2 -y RUN apt-get update && apt-get install gnupg2 -y
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
"davidanson.vscode-markdownlint", "davidanson.vscode-markdownlint",
"alexkrechik.cucumberautocomplete", "alexkrechik.cucumberautocomplete",
], ],
"postCreateCommand": "python3 -m pip install -e /workspaces/ska-tango-base --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple", "postCreateCommand": "python3 -m pip install -e /workspaces/ska-tango-base --extra-index-url https://artefact.skao.int/repository/pypi/simple",
"remoteUser": "tango", "remoteUser": "tango",
"remoteEnv": { "remoteEnv": {
"PATH": "/home/tango/.local/bin:${containerEnv:PATH}", "PATH": "/home/tango/.local/bin:${containerEnv:PATH}",
......
# GitLab CI in conjunction with GitLab Runner can use Docker Engine to test and build any application. # GitLab CI in conjunction with GitLab Runner can use Docker Engine to test and build any application.
# Docker, when used with GitLab CI, runs each job in a separate and isolated container using the predefined image that is set up in .gitlab-ci.yml. # Docker, when used with GitLab CI, runs each job in a separate and isolated container using the predefined image that is set up in .gitlab-ci.yml.
# In this case we use the latest python docker image to build and test this project. # In this case we use the latest python docker image to build and test this project.
image: nexus.engageska-portugal.pt/ska-tango-images/pytango-builder:9.3.3.3 image: artefact.skao.int/ska-tango-images-pytango-builder:9.3.10
include:
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/post_step.yml'
# cache is used to specify a list of files and directories which should be cached between jobs. You can only use paths that are within the project workspace. # cache is used to specify a list of files and directories which should be cached between jobs. You can only use paths that are within the project workspace.
# If cache is defined outside the scope of jobs, it means it is set globally and all jobs will use that definition # If cache is defined outside the scope of jobs, it means it is set globally and all jobs will use that definition
...@@ -34,37 +30,13 @@ clean shell runner: ...@@ -34,37 +30,13 @@ clean shell runner:
# Gitlab CI badges creation # Gitlab CI badges creation
- rm -rf build/* - rm -rf build/*
build wheel for publication: # Executed on a tag
stage: build
tags:
- k8srunner
script:
- python3 setup.py egg_info -b+$CI_COMMIT_SHORT_SHA sdist bdist_wheel
rules:
- if: '$CI_COMMIT_TAG'
artifacts:
paths:
- ./dist/
build wheel for development: # Executed on non-tagged commit
stage: build
tags:
- k8srunner
script:
- python3 setup.py egg_info -b+dev.$CI_COMMIT_SHORT_SHA sdist bdist_wheel
rules:
- if: '$CI_COMMIT_TAG == null || $CI_COMMIT_TAG == ""'
artifacts:
paths:
- ./dist/
unit tests: unit tests:
stage: test stage: test
tags: tags:
- k8srunner - k8srunner
script: script:
- echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) - echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)
- python3 -m pip install --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) - python3 -m pip install --extra-index-url https://artefact.skao.int/repository/pypi-all/simple -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)
- make test - make test
- scripts/validate-metadata.sh - scripts/validate-metadata.sh
artifacts: artifacts:
...@@ -77,44 +49,12 @@ linting: ...@@ -77,44 +49,12 @@ linting:
- k8srunner - k8srunner
script: script:
- echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) - echo $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)
- python3 -m pip install --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA) - python3 -m pip install --extra-index-url https://artefact.skao.int/repository/pypi-all/simple -U $(ls -d ./dist/*.whl | grep $CI_COMMIT_SHORT_SHA)
- make lint - make lint
artifacts: artifacts:
paths: paths:
- ./build - ./build
publish to nexus:
stage: publish
tags:
- k8srunner
variables:
TWINE_USERNAME: $TWINE_USERNAME
TWINE_PASSWORD: $TWINE_PASSWORD
script:
# check metadata requirements
- scripts/validate-metadata.sh
- python3 -m pip install twine
- twine upload --repository-url $PYPI_REPOSITORY_URL dist/*
rules:
# PyPI package release only on tags, and confirm semantic versioning of tag
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/'
release docker image:
stage: release
image: nexus.engageska-portugal.pt/ska-docker/tango-builder:latest
before_script:
- docker login -u $DOCKER_REGISTRY_USERNAME -p $DOCKER_REGISTRY_PASSWORD $DOCKER_REGISTRY_HOST
tags:
- k8srunner
script:
- make build
- make push
rules:
# Images only allow manual run on tags, and confirm semantic versioning of tag
- if: '$CI_COMMIT_TAG && $CI_COMMIT_TAG =~ /^((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/'
when: manual
allow_failure: true
pages: pages:
stage: pages stage: pages
tags: tags:
...@@ -129,3 +69,16 @@ pages: ...@@ -129,3 +69,16 @@ pages:
only: only:
- master - master
include:
# Create Gitlab CI badges from CI metrics
# https://developer.skatelescope.org/en/latest/tools/continuousintegration.html#automated-collection-of-ci-health-metrics-as-part-of-the-ci-pipeline
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/post_step.yml'
# Publish Python packages
# https://developer.skao.int/en/latest/tools/software-package-release-procedure.html#building-and-publishing-python-packages
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/build_wheel.yml'
# Publish OCI images
# https://developer.skao.int/en/latest/tools/software-package-release-procedure.html#oci-image
- project: 'ska-telescope/templates-repository'
file: 'gitlab-ci/includes/build_push.yml'
...@@ -21,15 +21,11 @@ endif ...@@ -21,15 +21,11 @@ endif
RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-release-support
ifeq ($(strip $(DOCKER_REGISTRY_HOST)),) ifeq ($(strip $(CAR_OCI_REGISTRY_HOST)),)
DOCKER_REGISTRY_HOST = nexus.engageska-portugal.pt CAR_OCI_REGISTRY_HOST = artefact.skao.int
endif endif
ifeq ($(strip $(DOCKER_REGISTRY_USER)),) IMAGE=$(CAR_OCI_REGISTRY_HOST)/$(NAME)
DOCKER_REGISTRY_USER = ska-telescope
endif
IMAGE=$(DOCKER_REGISTRY_HOST)/$(DOCKER_REGISTRY_USER)/$(NAME)
VERSION=$(shell . $(RELEASE_SUPPORT) ; getVersion) VERSION=$(shell . $(RELEASE_SUPPORT) ; getVersion)
TAG=$(shell . $(RELEASE_SUPPORT); getTag) TAG=$(shell . $(RELEASE_SUPPORT); getTag)
...@@ -53,7 +49,7 @@ pre-push: ...@@ -53,7 +49,7 @@ pre-push:
post-push: post-push:
docker-build: .release docker-build: .release
docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH) --build-arg DOCKER_REGISTRY_HOST=$(DOCKER_REGISTRY_HOST) --build-arg DOCKER_REGISTRY_USER=$(DOCKER_REGISTRY_USER) --build-arg IMAGE_VERSION=$(VERSION) docker build $(DOCKER_BUILD_ARGS) -t $(IMAGE):$(VERSION) $(DOCKER_BUILD_CONTEXT) -f $(DOCKER_FILE_PATH) --build-arg CAR_OCI_REGISTRY_HOST=$(CAR_OCI_REGISTRY_HOST) --build-arg IMAGE_VERSION=$(VERSION)
@DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \ @DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \
DOCKER_MINOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f2) ; \ DOCKER_MINOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f2) ; \
if [ $$DOCKER_MAJOR -eq 1 ] && [ $$DOCKER_MINOR -lt 10 ] ; then \ if [ $$DOCKER_MAJOR -eq 1 ] && [ $$DOCKER_MINOR -lt 10 ] ; then \
......
release=0.11.2 release=0.11.3
tag=ska_tango_base-0.11.2 tag=ska-tango-base-0.11.3
# Use SKA python image as base image # Use SKA python image as base image
FROM nexus.engageska-portugal.pt/ska-tango-images/pytango-builder:9.3.3.3 AS buildenv FROM artefact.skao.int/ska-tango-images-pytango-builder:9.3.10 AS buildenv
FROM nexus.engageska-portugal.pt/ska-tango-images/pytango-runtime:9.3.3.3 AS runtime FROM artefact.skao.int/ska-tango-images-pytango-runtime:9.3.10 AS runtime
ARG IMAGE_VERSION=0.0.1 ARG IMAGE_VERSION=0.0.1
......
# #
# Project makefile for a SKA Tango Base project. You should normally only need to modify # Project makefile for a SKA Tango Base project. You should normally only need to modify
# DOCKER_REGISTRY_USER and PROJECT below. # PROJECT below.
# Use bash shell with pipefail option enabled so that the return status of a # Use bash shell with pipefail option enabled so that the return status of a
# piped command is the value of the last (rightmost) command to exit with a # piped command is the value of the last (rightmost) command to exit with a
...@@ -9,15 +9,12 @@ ...@@ -9,15 +9,12 @@
SHELL = /bin/bash SHELL = /bin/bash
.SHELLFLAGS = -o pipefail -c .SHELLFLAGS = -o pipefail -c
# DOCKER_REGISTRY_HOST, DOCKER_REGISTRY_USER and PROJECT are combined to define # CAR_OCI_REGISTRY_HOST, and PROJECT are combined to define
# the Docker tag for this project. The definition below inherits the standard # the Docker tag for this project. The definition below inherits the standard
# value for DOCKER_REGISTRY_HOST (=rnexus.engageska-portugal.pt) and overwrites # value for CAR_OCI_REGISTRY_HOST (=artefact.skao.int) and overwrites
# DOCKER_REGISTRY_USER and PROJECT to give a final Docker tag of # PROJECT to give a final Docker tag of artefact.skao.int/ska-tango-base
# nexus.engageska-portugal.pt/ska-telescope/ska_tango_base PROJECT = ska-tango-base
# IMAGE_FOR_DIAGRAMS = artefact.skao.int/ska-tango-images-pytango-builder:9.3.10
DOCKER_REGISTRY_USER:=ska-telescope
PROJECT = ska_tango_base
IMAGE_FOR_DIAGRAMS = nexus.engageska-portugal.pt/ska-tango-images/pytango-builder:9.3.3.3
# import some standard Make targets e.g. `make build` (for building # import some standard Make targets e.g. `make build` (for building
......
...@@ -41,7 +41,7 @@ The requirements for testing are: ...@@ -41,7 +41,7 @@ The requirements for testing are:
#### Installation steps #### Installation steps
1. Clone the repository on local machine. 1. Clone the repository on local machine.
2. Navigate to the root directory of the repository from terminal 2. Navigate to the root directory of the repository from terminal
3. Run 'python3 -m pip install . --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple' 3. Run 'python3 -m pip install . --extra-index-url https://artefact.skao.int/repository/pypi/simple'
### Testing ### Testing
The project can be tested locally my invoking *make CI_JOB_ID=some_id test* command. This invokes a chain of commands from the makefile which builds the project's python package, creates a docker image with the project, instantiates separate container for each of the base class and runs unit test cases of each class. Additionally, code analysis is also done and code coverage report is prepared. After testing is done, the containers are taken down. The project can be tested locally my invoking *make CI_JOB_ID=some_id test* command. This invokes a chain of commands from the makefile which builds the project's python package, creates a docker image with the project, instantiates separate container for each of the base class and runs unit test cases of each class. Additionally, code analysis is also done and code coverage report is prepared. After testing is done, the containers are taken down.
...@@ -61,7 +61,7 @@ class DishLeafNode(SKABaseDevice): ...@@ -61,7 +61,7 @@ class DishLeafNode(SKABaseDevice):
#### PyCharm #### PyCharm
The Docker integration is recommended. For development, use the `nexus.engageska-portugal.pt/ska-telescope/ska_tango_base:latest` image as the Python Interpreter for the project. Note that if `make` is run with targets like `build`, `up`, or `test`, that image will be rebuilt by Docker using the local code, and tagged as `latest`. The Docker integration is recommended. For development, use the `artefact.skao.int/ska-tango-base:latest` image as the Python Interpreter for the project. Note that if `make` is run with targets like `build`, `up`, or `test`, that image will be rebuilt by Docker using the local code, and tagged as `latest`.
As this project uses a `src` [folder structure](https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure), so under _Preferences > Project Structure_, the `src` folder needs to be marked as "Sources". That will allow the interpreter to be aware of the package from folders like `tests` that are outside of `src`. When adding Run/Debug configurations, make sure "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH" are checked. As this project uses a `src` [folder structure](https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure), so under _Preferences > Project Structure_, the `src` folder needs to be marked as "Sources". That will allow the interpreter to be aware of the package from folders like `tests` that are outside of `src`. When adding Run/Debug configurations, make sure "Add content roots to PYTHONPATH" and "Add source roots to PYTHONPATH" are checked.
...@@ -247,6 +247,9 @@ Tango devices can be launched with a `-v` parameter to set the logging level. Fo ...@@ -247,6 +247,9 @@ Tango devices can be launched with a `-v` parameter to set the logging level. Fo
## Version History ## Version History
#### 0.11.3
- No change, moving artefacts to a new repository https://artefact.skao.int/.
#### 0.11.2 #### 0.11.2
- Update docstrings for 100% coverage and PEP257 compliance - Update docstrings for 100% coverage and PEP257 compliance
......
...@@ -12,7 +12,7 @@ installed from the EngageSKA Nexus repository: ...@@ -12,7 +12,7 @@ installed from the EngageSKA Nexus repository:
.. code-block:: shell-session .. code-block:: shell-session
me@local:~$ python3 -m pip install --extra-index-url https://nexus.engageska-portugal.pt/repository/pypi/simple ska-tango-base me@local:~$ python3 -m pip install --extra-index-url https://artefact.skao.int/repository/pypi/simple ska-tango-base
Basic steps Basic steps
----------- -----------
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
"""Release information for ska_tango_base Python Package.""" """Release information for ska_tango_base Python Package."""
name = """ska_tango_base""" name = """ska_tango_base"""
version = "0.11.2" version = "0.11.3"
version_info = version.split(".") version_info = version.split(".")
description = """A set of generic base devices for SKA Telescope.""" description = """A set of generic base devices for SKA Telescope."""
author = "SKA India and SARAO and CSIRO and INAF" author = "SKA India and SARAO and CSIRO and INAF"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment