From b28afb68725db2c570e4c219624d7b8feab3ae04 Mon Sep 17 00:00:00 2001
From: softir <elisabetta.giani@inaf.it>
Date: Thu, 21 May 2020 09:02:14 +0200
Subject: [PATCH] publish_python_package: publish the python package under
 nexus repo.

---
 .gitlab-ci.yml            | 38 ++++++++++++++++++++++++++++++++++++--
 tests/test_se_master.py   |  3 ---
 tests/test_se_subarray.py |  2 --
 3 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4bbc1e0..9152b0e 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -16,7 +16,9 @@ before_script:
 stages:
   - test
   - linting
-  - deploy
+  - build
+  - publish
+  - pages 
 
 # The YAML file defines a set of jobs with constraints stating when they should be run. 
 # You can specify an unlimited number of jobs which are defined as top-level elements with an arbitrary name and always
@@ -66,8 +68,40 @@ linting:
     paths:
       - ./build
 
+build_dev_package:
+  stage: build
+  tags:
+    - docker-executor
+  script:
+    - python3 setup.py egg_info -b+dev.$CI_COMMIT_SHORT_SHA sdist bdist_wheel
+  artifacts:
+    path:
+      - ./dist
+
+build_package:
+  stage: build
+  tags:
+    - docker-executor
+  script:
+    - python setup.py egg_info -b.$CI_COMMIT_SHORT_SHA sdist bdist_wheel
+  only: [master]
+  artifacts:
+    path:
+      - ./dist
+
+publish:        
+   stage: publish
+   tags:
+     - docker-executor
+   variables:
+    TWINE_USERNAME: $TWINE_USERNAME
+    TWINE_PASSWORD: $TWINE_PASSWORD
+  script:
+    - pip3 install twine
+    - twine upload --repository-url $PYPI_REPOSITORY_URL dist/*
+
 pages:
-  stage: deploy
+  stage: pages 
   tags:
    - docker-executor
   dependencies:
diff --git a/tests/test_se_master.py b/tests/test_se_master.py
index f24cffd..e18d5d2 100644
--- a/tests/test_se_master.py
+++ b/tests/test_se_master.py
@@ -155,7 +155,6 @@ class TestCspSubElementMaster(object):
         # reinitialize the device to return to
         # adminMode =ONLINE and State=INIT
         tango_context.device.Init()
-        time.sleep(2)
         assert tango_context.device.adminMode == AdminMode.ONLINE
         assert tango_context.device.State() == DevState.INIT
         with pytest.raises(DevFailed) as df:
@@ -257,8 +256,6 @@ class TestCspSubElementMaster(object):
         tango_context.device.onCmdDurationExpected = 20
         tango_context.device.offCmdDurationExpected = 20
         tango_context.device.standbyCmdDurationExpected = 20
-        # wait to let the polling thread update the attrs value
-        time.sleep(3)
         assert tango_context.device.onCmdDurationExpected == 20
         assert tango_context.device.offCmdDurationExpected == 20
         assert tango_context.device.standbyCmdDurationExpected == 20
diff --git a/tests/test_se_subarray.py b/tests/test_se_subarray.py
index 786d2d7..985b2b6 100644
--- a/tests/test_se_subarray.py
+++ b/tests/test_se_subarray.py
@@ -190,8 +190,6 @@ class TestCspSubElementSubarray(object):
     def test_set_command_duration_expected(self, tango_context):
         """Test xxxCmdDurationExpected attributes"""
         tango_context.device.goToIdleDurationExpected = 20
-        # wait to let the polling thread update the attrs value
-        time.sleep(3)
         assert tango_context.device.goToIdleDurationExpected == 20
 
 
-- 
GitLab