From 2d8911a409d50d58b8db36bc054329d443c20fb6 Mon Sep 17 00:00:00 2001
From: "Saralegui Vallejo, Unai" <unai.saralegui@tecnalia.com>
Date: Fri, 26 Mar 2021 11:21:02 +0000
Subject: [PATCH] Master

---
 python-packages/.gitkeep        |  0
 python-packages/artifactory.yml | 16 ++++++++++++++++
 python-packages/pages.yml       | 19 +++++++++++++++++++
 python-packages/test.yml        | 12 ++++++++++++
 python-packages/virtualenv.yml  | 19 +++++++++++++++++++
 5 files changed, 66 insertions(+)
 create mode 100644 python-packages/.gitkeep
 create mode 100644 python-packages/artifactory.yml
 create mode 100644 python-packages/pages.yml
 create mode 100644 python-packages/test.yml
 create mode 100644 python-packages/virtualenv.yml

diff --git a/python-packages/.gitkeep b/python-packages/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/python-packages/artifactory.yml b/python-packages/artifactory.yml
new file mode 100644
index 0000000..0bdbc8a
--- /dev/null
+++ b/python-packages/artifactory.yml
@@ -0,0 +1,16 @@
+artifactory:
+  stage: artifactory
+  tags:
+    - docker
+  variables:
+    TWINE_USERNAME: $ACR_USERNAME
+    TWINE_PASSWORD: $ACR_PASSWORD
+  script:
+    - source $VIRTUALENV_NAME/bin/activate
+    - pip install twine
+    - python setup.py sdist bdist_wheel
+    - twine upload --repository-url $ACR_PYPI_URL dist/*
+  only:
+    refs:
+      # run only when new tag is published or changes pushed to master
+      - tags
diff --git a/python-packages/pages.yml b/python-packages/pages.yml
new file mode 100644
index 0000000..c9618d1
--- /dev/null
+++ b/python-packages/pages.yml
@@ -0,0 +1,19 @@
+pages:    
+    tags:
+        - docker
+    stage: pages
+    script:
+        - source $VIRTUALENV_NAME/bin/activate
+        - pip install -U sphinx
+        - pip install -U sphinx_glpi_theme
+        - cd docs
+        - sphinx-build -b html . ../public
+    allow_failure: true
+    artifacts:
+        paths:
+        - public
+    only:
+        refs:
+        # run only when new tag is published or changes pushed to master
+        - tags
+        - master
diff --git a/python-packages/test.yml b/python-packages/test.yml
new file mode 100644
index 0000000..c60bbf6
--- /dev/null
+++ b/python-packages/test.yml
@@ -0,0 +1,12 @@
+test:
+    tags:
+    - docker  # this is necessary to execute the Gitlab Runner in a docker container
+    only:
+        refs:
+        # run only when new tag is published or changes pushed to master
+        - tags
+        - master
+    script:
+        # run test files in tests folder
+        - source $VIRTUALENV_NAME/bin/activate
+        - python -m unittest discover tests
diff --git a/python-packages/virtualenv.yml b/python-packages/virtualenv.yml
new file mode 100644
index 0000000..a766e51
--- /dev/null
+++ b/python-packages/virtualenv.yml
@@ -0,0 +1,19 @@
+variables:
+  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
+  VIRTUALENV_NAME: "venv"
+
+cache:
+  paths:
+    - .cache/pip
+    - $VIRTUALENV_NAME/
+
+virtualenv:
+  stage: virtualenv
+  tags:
+    - docker
+  script:
+    - pip install virtualenv  # install virtualenv to create a virtual environment to install required packages
+    - virtualenv $VIRTUALENV_NAME  # create a virtualenvironment
+    - source $VIRTUALENV_NAME/bin/activate  # activate the virtualenvironment
+    - python -V  # print python version for debugging
+    - pip install -r requirements.txt  # install required packages
-- 
GitLab