From 1881eae639b4f6d821457f0eaf951b27ea6aea6b Mon Sep 17 00:00:00 2001
From: vtexier <vit@free.fr>
Date: Sat, 7 Mar 2020 10:25:27 +0100
Subject: [PATCH] [enh] enhance .gitlab-ci.yml and Makefile

Remove tests (not ready yet)
Add PyPI-test release
---
 .gitlab-ci.yml                                | 60 ++++++++++++-------
 Makefile                                      |  4 +-
 .../{g1_license.html => g1_licence.html}      |  0
 3 files changed, 43 insertions(+), 21 deletions(-)
 rename src/sakia/{g1_license.html => g1_licence.html} (100%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b5ef70a5..81a9e4fe 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,6 +1,6 @@
 stages:
   - github-sync
-  - build_and_test
+  - build
   - release
 
 variables:
@@ -8,7 +8,7 @@ variables:
 
 image: registry.duniter.org/docker/python3/duniterpy-builder:0.0.7
 
-push_to_github:
+.push_to_github:
   stage: github-sync
   variables:
     GIT_STRATEGY: none
@@ -26,7 +26,7 @@ push_to_github:
     - mv packed-refs-new packed-refs
     - bash -c "git push --force --mirror github 2>&1 | grep -v duniter-gitlab; echo $?"
 
-.env: &env
+.env:
   tags:
     - redshift-docker-python
   before_script:
@@ -37,28 +37,48 @@ push_to_github:
     - export PATH=/opt/qt/5.9/5.9.4/gcc_64/bin:$PATH
     - export DISPLAY=:99
 
+.changes:
+  only:
+    changes:
+      - sakia/**/*.py
+      - .gitlab-ci.yml
+      - Makefile
+      - requirements_dev.txt
+      - requirements.txt
+      - setup.py
+      - tests/**/*.py
 
-build_and_test: &build_and_test
-  <<: *env
-  stage: build_and_test
+build:
+  extends:
+    - .env
+    - .changes
+  stage: build
   script:
-    - pip install wheel
-    - pip install pytest-cov
     - pip install -r requirements.txt
-    - python gen_resources.py
-    - python gen_translations.py --lrelease
-    - python setup.py bdist_wheel
-    - py.test --cov=sakia tests/
+    - pip install -r requirements_deploy.txt
+    - make build
 
-releases:
-  <<: *env
+release:
+  extends:
+    - .env
+    - .push_to_github
   stage: release
   when: manual
   script:
     - pip install -r requirements.txt
-    - pip install wheel
-    - pip install twine
-    - python gen_resources.py
-    - python gen_translations.py --lrelease
-    - python setup.py bdist_wheel
-    - twine upload dist/* --username duniter --password $PYPI_PASSWORD
+    - pip install -r requirements_deploy.txt
+    - make build
+    - make deploy PYPI_LOGIN=${PYPI_LOGIN} PYPI_PASSWORD=${PYPI_PASSWORD}
+  only:
+    - tags
+    - master
+
+release_test:
+  extends: .env
+  stage: release
+  when: manual
+  script:
+    - pip install -r requirements.txt
+    - pip install -r requirements_deploy.txt
+    - make build
+    - make deploy_test PYPI_TEST_LOGIN=${PYPI_TEST_LOGIN} PYPI_TEST_PASSWORD=${PYPI_TEST_PASSWORD}
diff --git a/Makefile b/Makefile
index 07837ec6..a0b2c6f7 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,9 @@ format:
 build:
 	if [ -d "./build" ]; then rm -r build/*; fi
 	if [ -d "./dist" ]; then rm -r dist/*; fi
-	python setup.py sdist bdist_wheel
+	python3 gen_resources.py
+	python3 gen_translations.py --lrelease
+	python3 setup.py sdist bdist_wheel
 
 # upload on PyPi repository
 deploy:
diff --git a/src/sakia/g1_license.html b/src/sakia/g1_licence.html
similarity index 100%
rename from src/sakia/g1_license.html
rename to src/sakia/g1_licence.html
-- 
GitLab