CI: Add tox build,clean environments 43/71543/1
authorAndrew Grimberg <agrimberg@linuxfoundation.org>
Wed, 12 Apr 2023 16:58:24 +0000 (09:58 -0700)
committerAndrew Grimberg <agrimberg@linuxfoundation.org>
Wed, 12 Apr 2023 16:58:24 +0000 (09:58 -0700)
* Add the tox build and clean environments
* Add additional gitignore to deal with build artifacts

Issue: RELENG-4563
Signed-off-by: Andrew Grimberg <agrimberg@linuxfoundation.org>
Change-Id: I26df479ac9f0a6177c345fd3a9bdd3dbb4bc9f49

.gitignore
tox.ini

index 3a98244..4a6931e 100644 (file)
@@ -30,8 +30,15 @@ anonymous-cli-metrics.json
 __pycache__/
 *.egg-info/
 *.pyc
-docs/_build/
-dist/
+
+# Build and docs folder/files
+build/*
+dist/*
+sdist/*
+docs/api/*
+docs/_rst/*
+docs/_build/*
+cover/*
 MANIFEST
 
 # PBR
diff --git a/tox.ini b/tox.ini
index 656311e..7985935 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -21,6 +21,26 @@ deps = -r{toxinidir}/requirements-test.txt
 commands = pytest
 usedevelop = true
 
+
+[testenv:{build,clean}]
+description =
+    build: Build the package in isolation according to PEP517, see https://github.com/pypa/build
+    clean: Remove old distribution files and temporary build artifacts (./build and ./dist)
+# https://setuptools.pypa.io/en/stable/build_meta.html#how-to-use-it
+skip_install = True
+changedir = {toxinidir}
+deps =
+    build: build[virtualenv]
+passenv =
+    SETUPTOOLS_*
+commands =
+    clean: python -c 'import shutil; [shutil.rmtree(p, True) for p in ("build", "dist", "docs/_build")]'
+    clean: python -c 'import pathlib, shutil; [shutil.rmtree(p, True) for p in pathlib.Path("src").glob("*.egg-info")]'
+    build: python -m build {posargs}
+# By default, both `sdist` and `wheel` are built. If your sdist is too big or you don't want
+# to make it available, consider running: `tox -e build -- --wheel`
+
+
 [testenv:docs]
 description = Build the documentation with sphinx
 basepython = python3