CI: Add tox publish environment
[releng/lftools.git] / tox.ini
1 [tox]
2 envlist =
3     docs,
4     docs-linkcheck,
5     license,
6     pre-commit,
7     py36,
8     py37,
9     py38
10 minversion = 3.7
11 skip_missing_interpreters = true
12 ignore_basepython_conflict = true
13
14 [pytest]
15 markers = datafiles
16 addopts = -p no:warnings
17
18 [testenv]
19 basepython = python3
20 deps = -r{toxinidir}/requirements-test.txt
21 commands = pytest
22 usedevelop = true
23
24
25 [testenv:{build,clean}]
26 description =
27     build: Build the package in isolation according to PEP517, see https://github.com/pypa/build
28     clean: Remove old distribution files and temporary build artifacts (./build and ./dist)
29 # https://setuptools.pypa.io/en/stable/build_meta.html#how-to-use-it
30 skip_install = True
31 changedir = {toxinidir}
32 deps =
33     build: build[virtualenv]
34 passenv =
35     SETUPTOOLS_*
36 commands =
37     clean: python -c 'import shutil; [shutil.rmtree(p, True) for p in ("build", "dist", "docs/_build")]'
38     clean: python -c 'import pathlib, shutil; [shutil.rmtree(p, True) for p in pathlib.Path("src").glob("*.egg-info")]'
39     build: python -m build {posargs}
40 # By default, both `sdist` and `wheel` are built. If your sdist is too big or you don't want
41 # to make it available, consider running: `tox -e build -- --wheel`
42
43
44 [testenv:docs]
45 description = Build the documentation with sphinx
46 basepython = python3
47 deps = -rrequirements-docs.txt
48 extras = openstack
49 commands = sphinx-build -W -b html -n -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/html
50
51 [testenv:docs-linkcheck]
52 description = Check the documentation links with sphinx
53 basepython = python3
54 deps = -rrequirements-docs.txt
55 extras = openstack
56 commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinidir}/docs/_build/linkcheck
57
58 [testenv:latest-upstream]
59 description = Latest upstream test. Used for what exactly?
60 basepython = python3
61 deps = -r{toxinidir}/requirements-test.txt
62 commands =
63     pip install -U python-jenkins requests
64     pytest
65
66 [testenv:license]
67 description = Check all files for license header
68 basepython = python3
69 deps = lftools
70 commands =
71     lftools license check-dir lftools
72     lftools license check-dir -r '.+' shell
73
74 [testenv:pre-commit]
75 description = Precommit checks for black, gitlint, etc.
76 basepython = python3.7
77 allowlist_externals =
78     /bin/sh
79 deps =
80     pre-commit
81 passenv = HOME
82 commands =
83     pre-commit run --all-files --show-diff-on-failure
84     /bin/sh -c 'if ! git config --get user.name > /dev/null; then \
85         git config --global --add user.name "CI"; \
86         touch .git/REMOVE_USERNAME; fi'
87     /bin/sh -c 'if ! git config --get user.email > /dev/null; then \
88         git config --global --add user.email "ci@example.org"; \
89         touch .git/REMOVE_USEREMAIL; fi'
90     /bin/sh -c "if [ -f .git/COMMIT_EDITMSG ]; then \
91         cp .git/COMMIT_EDITMSG .git/COMMIT_MSGTOX; else \
92         git log HEAD -n1 --pretty=%B > .git/COMMIT_MSGTOX; fi"
93     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_MSGTOX
94     /bin/sh -c "rm -f .git/COMMIT_MSGTOX"
95     /bin/sh -c "if [ -f .git/REMOVE_USERNAME ]; then \
96         git config --global --unset user.name; \
97         rm -f .git/REMOVE_USERNAME; fi"
98     /bin/sh -c "if [ -f .git/REMOVE_USEREMAIL ]; then \
99         git config --global --unset user.email; \
100         rm -f .git/REMOVE_USEREMAIL; fi"
101
102
103 [testenv:publish]
104 description =
105     Publish the package you have been developing to a package index server.
106     By default, it uses testpypi. If you really want to publish your package
107     to be publicly accessible in PyPI, use the `-- --repository pypi` option.
108 skip_install = True
109 changedir = {toxinidir}
110 passenv =
111     # See: https://twine.readthedocs.io/en/latest/
112     TWINE_USERNAME
113     TWINE_PASSWORD
114     TWINE_REPOSITORY
115     TWINE_REPOSITORY_URL
116 deps = twine
117 commands =
118     python -m twine check dist/*
119     python -m twine upload {posargs:--repository {env:TWINE_REPOSITORY:testpypi}} dist/*
120
121
122 [testenv:reno]
123 description = OpenStack Reno checks
124 basepython = python3
125 deps = reno
126 commands = reno {posargs:--help}