]> kaliko git repositories - python-musicpd.git/blob - .gitlab-ci.yml
ci: Scheduled pipeline runs test/build
[python-musicpd.git] / .gitlab-ci.yml
1 ---
2 image: python:latest
3
4 before_script:
5   - python -V      # Print out python version for debugging
6
7 stages:
8   - test
9   - build
10
11 .cache_python:
12   variables:
13     FF_USE_FASTZIP: 1  # enable faster caching/artifacting
14     PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
15   cache:
16     key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
17     paths:  # cache the venv and pip cache (you may opt to use just 1 of these)
18       - $PIP_CACHE_DIR
19
20 .test:
21   stage: test
22   script:
23     - python -m venv venv
24     - source venv/bin/activate
25     - pip install pytest-cov
26     - py.test -q --cov=musicpd test.py
27   rules:
28     - changes:
29         - musicpd.py
30         - test.py
31     - if: $CI_PIPELINE_SOURCE == "schedule"
32
33 test-py3.11:
34   extends:
35     - .cache_python
36     - .test
37   image: "python:3.11"
38
39 test-py3.10:
40   extends:
41     - .cache_python
42     - .test
43   image: "python:3.10"
44   coverage: '/musicpd.py\s+\d+\s+\d+\s+(\d+)%/'
45
46 test-py3.9:
47   extends:
48     - .cache_python
49     - .test
50   image: "python:3.9"
51
52 test-py3.8:
53   extends:
54     - .cache_python
55     - .test
56   image: "python:3.8"
57
58 test-py3.7:
59   extends:
60     - .cache_python
61     - .test
62   image: "python:3.7"
63
64 test-py3.6:
65   extends:
66     - .cache_python
67     - .test
68   image: "python:3.6"
69
70
71 build:
72   stage: build
73   extends:
74     - .cache_python
75   script:
76     - python -m venv venv
77     - source venv/bin/activate
78     - pip install build
79     # packaging test
80     - python3 -m build -s -w
81     - pip install dist/*.whl
82     - pip install twine
83     - twine check dist/*
84   artifacts:
85     expire_in: 1 week
86     paths:
87       - dist/*.*
88   rules:
89     - if: $CI_PIPELINE_SOURCE == "push"
90       changes:
91         - .gitlab-ci.yml
92         - musicpd.py
93         - test.py
94     - if: $CI_PIPELINE_SOURCE == "schedule"
95
96 tag_release:
97   stage: build
98   extends:
99     - .cache_python
100   script:
101     - python -m venv venv
102     - source venv/bin/activate
103     - pip install build
104     - python3 -m build -s -w
105   artifacts:
106     paths:
107       - dist/*.*
108     name: "$CI_PROJECT_NAME-$CI_COMMIT_TAG"
109   rules:
110     - if: $CI_COMMIT_TAG
111
112 # Documentation
113 build_doc:
114   stage: build
115   script:
116     - pip install sphinx sphinx_rtd_theme
117     - sphinx-build doc/source -b html ./html -D html_theme=sphinx_rtd_theme
118   rules:
119     - if: $CI_PIPELINE_SOURCE == "push"
120       changes:
121         - doc/source/*
122     - if: $CI_PIPELINE_SOURCE == "schedule"
123
124 pages:
125   stage: build
126   script:
127     - pip install sphinx sphinx_rtd_theme
128     - sphinx-build -d ./build/doctrees doc/source -b html ./public -D html_theme=sphinx_rtd_theme
129   artifacts:
130     paths:
131       - public
132   rules:
133     - if: $CI_COMMIT_BRANCH == "master"