From 298a9ff25071dfd048220586fda683fd909764ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Sun, 6 Dec 2020 02:51:55 +0100 Subject: [PATCH] Check python package when we don't publish it --- c2cciutils/publish.py | 13 +++++++++---- c2cciutils/scripts/publish.py | 5 +++-- ci/config.yaml | 4 ++++ test/pkg/setup.py | 6 ++++++ 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 test/pkg/setup.py diff --git a/c2cciutils/publish.py b/c2cciutils/publish.py index b4db0b501..bb6dc17ee 100644 --- a/c2cciutils/publish.py +++ b/c2cciutils/publish.py @@ -7,12 +7,13 @@ import sys -def pip(config, version, version_type): +def pip(config, version, version_type, publish): """ Publish to pypi version_type: Describe the kind of release we do: rebuild (specified using --type), version_tag, version_branch, feature_branch, feature_tag (for pull request) + publish: If False only check the package config is like: packages: - path: . # the root foder of the package @@ -45,9 +46,13 @@ def pip(config, version, version_type): subprocess.check_call( ["python3", "./setup.py", "egg_info", "--no-date", "bdist_wheel"], cwd=cwd, env=env ) - subprocess.check_call( - ["twine", "upload", "--verbose", "--disable-progress-bar"] + glob.glob("dist/*.whl"), cwd=cwd - ) + pkg_publish = publish + if "versions" in pkg: + pkg_publish &= version_type in pkg["versions"] + cmd = ["twine"] + cmd += ["upload", "--verbose", "--disable-progress-bar"] if pkg_publish else ["check"] + cmd += glob.glob(os.path.join(cwd, "dist/*.whl")) + subprocess.check_call(cmd) print("::endgroup::") except subprocess.CalledProcessError as exception: print("Error: {}".format(exception)) diff --git a/c2cciutils/scripts/publish.py b/c2cciutils/scripts/publish.py index 8f6bf4cb1..6007628f9 100644 --- a/c2cciutils/scripts/publish.py +++ b/c2cciutils/scripts/publish.py @@ -114,8 +114,9 @@ def main() -> None: success = True pypi_config = config.get("publish", {}).get("pypi", {}) - if version_type in pypi_config.get("versions", []): - success &= c2cciutils.publish.pip(pypi_config, version, version_type) + success &= c2cciutils.publish.pip( + pypi_config, version, version_type, version_type in pypi_config.get("versions", []) + ) docker_config = config.get("publish", {}).get("docker", {}) diff --git a/ci/config.yaml b/ci/config.yaml index 89cec3466..bcb1da32a 100644 --- a/ci/config.yaml +++ b/ci/config.yaml @@ -17,6 +17,10 @@ audit: publish: pypi: + packages: + - path: . + - path: test/pkg + versions: [] versions: - version_tag - version_branch diff --git a/test/pkg/setup.py b/test/pkg/setup.py new file mode 100644 index 000000000..f17e87039 --- /dev/null +++ b/test/pkg/setup.py @@ -0,0 +1,6 @@ +from setuptools import setup + +setup( + name="test", + version="1.0.0", +)