]> kaliko git repositories - python-musicpd.git/blobdiff - .gitlab-ci.yml
ci: s/only/changes/
[python-musicpd.git] / .gitlab-ci.yml
index 6aa06570aaeeeecc3a8847063ef42d3ad99943df..4d7f68d6de1961f3c3e95c296f00a78c3dc6539a 100644 (file)
@@ -8,45 +8,77 @@ stages:
   - test
   - build
 
+.cache_python:
+  variables:
+    FF_USE_FASTZIP: 1  # enable faster caching/artifacting
+    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
+  cache:
+    key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    paths:  # cache the venv and pip cache (you may opt to use just 1 of these)
+      - $PIP_CACHE_DIR
+      #- venv
+
 .test:
   stage: test
   script:
+    - python -m venv venv
+    - source venv/bin/activate
     - pip install pytest-cov
     - py.test -q --cov=musicpd test.py
-  only:
-    - pushes
+  rules:
+    - changes:
+      - musicpd.py
+      - test.py
+    - if: $MUSICPD_TEST
 
 test-py3.11:
-  extends: ".test"
+  extends:
+    - .cache_python
+    - .test
   image: "python:3.11"
 
 test-py3.10:
-  extends: ".test"
+  extends:
+    - .cache_python
+    - .test
   image: "python:3.10"
   coverage: '/musicpd.py\s+\d+\s+\d+\s+(\d+)%/'
 
 test-py3.9:
-  extends: ".test"
+  extends:
+    - .cache_python
+    - .test
   image: "python:3.9"
 
 test-py3.8:
-  extends: ".test"
+  extends:
+    - .cache_python
+    - .test
   image: "python:3.8"
 
 test-py3.7:
-  extends: ".test"
+  extends:
+    - .cache_python
+    - .test
   image: "python:3.7"
 
 test-py3.6:
-  extends: ".test"
+  extends:
+    - .cache_python
+    - .test
   image: "python:3.6"
 
 
 build:
   stage: build
+  extends:
+    - .cache_python
   script:
+    - python -m venv venv
+    - source venv/bin/activate
+    - pip install build
     # packaging test
-    - python setup.py bdist_wheel sdist
+    - python3 -m build -s -w
     - pip install dist/*.whl
     - pip install twine
     - twine check dist/*
@@ -56,21 +88,26 @@ build:
       - dist/*.whl
       - dist/*.tar.gz
       - dist/*.zip
-  only:
-    - pushes
+  rules:
+    - if: $CI_PIPELINE_SOURCE == "push"
 
 tag_release:
   stage: build
+  extends:
+    - .cache_python
   script:
-    - python setup.py bdist_wheel sdist
+    - python -m venv venv
+    - source venv/bin/activate
+    - pip install build
+    - python3 -m build -s -w
   artifacts:
     paths:
       - dist/*.whl
       - dist/*.tar.gz
       - dist/*.zip
     name: "$CI_PROJECT_NAME-$CI_COMMIT_TAG"
-  only:
-    - tags
+  rules:
+    - if: $CI_COMMIT_TAG
 
 pages:
   stage: build
@@ -80,5 +117,5 @@ pages:
   artifacts:
     paths:
       - public
-  only:
-    - master
+  rules:
+    - if: $CI_COMMIT_BRANCH == "master"