pypa / gh-action-pypi-publish

The blessed :octocat: GitHub Action, for publishing your :package: distribution files to PyPI, the tokenless way: https://github.com/marketplace/actions/pypi-publish
https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
BSD 3-Clause "New" or "Revised" License
929 stars 87 forks source link

Disable the progress bar when exec `twine upload` #231

Closed shenxianpeng closed 5 months ago

shenxianpeng commented 6 months ago

Closes #229. I looked at twine's help and added a new input no-color for this action.

twine --help
usage: twine [-h] [--version] [--no-color] {check,upload,register}

positional arguments:
  {check,upload,register}

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --no-color            disable colored output
webknjaz commented 6 months ago

The CI doesn't test this case, which is necessary to ensure this keeps working over time. Also, it might make sense to just do this unconditionally.

webknjaz commented 6 months ago

So let's see if the output is good enough to avoid exposing another API toggle to the end-users.

shenxianpeng commented 6 months ago

Also, it might make sense to just do this unconditionally.

OK. I'll leave it on by default, this time could be as a test.

webknjaz commented 6 months ago

The CI run is now approved, let's see..

webknjaz commented 6 months ago

Looks like the lockfile needs updating.

shenxianpeng commented 6 months ago

I retried the option --no-color from my local, the right command should be twine --no-color upload dist/* not twine upload --no-color dist/*, I hope I can adjust --no-color before upload.

shenxianpeng commented 6 months ago

I have moved the position of --no-color before upload when no-color=true. could you approve to run CI again? thank you.

webknjaz commented 6 months ago

Sure. Though, I'm not sure anymore if disabling color altogether is good. I'd rather disable progress bars but not the colorizarion. Perhaps, the Twine upstream needs to be consulted..

shenxianpeng commented 6 months ago

I have tested the following commands to upload to testpypi, and both work with Python 3.11. and Python 3.12.

twine --no-color upload dist/* --repository testpypi
twine upload dist/* --repository testpypi
root@eca5ed1e5006:/src# twine --no-color upload dist/* --repository testpypi
Uploading distributions to https://test.pypi.org/legacy/
WARNING  Error getting password from keyring
         Traceback (most recent call last):
           File "/usr/local/lib/python3.12/site-packages/twine/auth.py", line 81, in get_password_from_keyring
             return cast(str, keyring.get_password(system, username))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "/usr/local/lib/python3.12/site-packages/keyring/core.py", line 56, in get_password
             return get_keyring().get_password(service_name, username)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           File "/usr/local/lib/python3.12/site-packages/keyring/backends/fail.py", line 28, in get_password
             raise NoKeyringError(msg)
         keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the
         keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.
Enter your API token:
Uploading clang_tools-0.11.1.post1.dev5-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 19.9/19.9 kB • 00:00 • 19.3 MB/s
Uploading clang_tools-0.11.1.post1.dev5.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.1/79.1 kB • 00:00 • 171.3 MB/s

View at:
https://test.pypi.org/project/clang-tools/0.11.1.post1.dev5/
root@eca5ed1e5006:/src# python3 -V
Python 3.12.3
root@eca5ed1e5006:/src#

I'll try again soon to find the cause.

webknjaz commented 6 months ago

I still think that it's best to get Twine to implement something like --no-animation instead and keep the color on.

shenxianpeng commented 6 months ago

Thanks for the hint. twine upload supports --disable-progress-bar, which I hadn't realized before. this should be what you need.

shenxianpeng commented 6 months ago

pre-commit.ci works in my local environment. 🤔

~/r/s/gh-action-pypi-publish (feature/support-no-color)> pre-commit run --all-files
Add trailing commas.......................................................Passed
isort.....................................................................Passed
Tabs remover..............................................................Passed
Validate GitHub Actions...................................................Passed
Validate GitHub Workflows.................................................Passed
Check GitHub Workflows set timeout-minutes................................Passed
Validate ReadTheDocs Config...........................(no files to check)Skipped
fix end of files..........................................................Passed
trim trailing whitespace..................................................Passed
mixed line ending.........................................................Passed
python tests naming...................................(no files to check)Skipped
check for added large files...............................................Passed
check BOM - deprecated: use fix-byte-order-marker.........................Passed
check for case conflicts..................................................Passed
check that executables have shebangs......................................Passed
check for merge conflicts.................................................Passed
check json............................................(no files to check)Skipped
check for broken symlinks.............................(no files to check)Skipped
check yaml................................................................Passed
detect private key........................................................Passed
check python ast..........................................................Passed
debug statements (python).................................................Passed
codespell.................................................................Passed
yamllint..................................................................Passed
flake8 WPS-excluded.......................................................Passed
flake8 WPS-only...........................................................Passed
pylint....................................................................Passed
Verify that enforced flake8 version stays unchanged.......................Passed
webknjaz commented 6 months ago

pre-commit.ci works in my local environment. 🤔

pre-commit.ci upgraded their runtime to Python 3.12 yesterday which is incompatible with some linting configuration present. I'll address that separately.

shenxianpeng commented 6 months ago

pre-commit.ci upgraded their runtime to Python 3.12 yesterday which is incompatible with some linting configuration present. I'll address that separately.

Maybe can use default_language_version to pin the runtime version to the previous version. for example:

default_language_version:
    python: python3.11
webknjaz commented 6 months ago

That's what I used elsewhere. But it's not something that's in the scope of this PR so let's keep it atomic.

shenxianpeng commented 6 months ago

Yes. I rebased my commits and it's ready to run CI and your review.