Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/publish-to-pypi-testpypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish distributions to PyPI (releases only) and TestPyPI (all commits)

on: push

jobs:
build-n-publish:
name: Build and publish distributions to PyPI (releases only) and TestPyPI (all commits)
if: github.repository == 'pvlib/pvlib-python'
runs-on: ubuntu-latest
steps:
# fetch all commits and tags so versioneer works
- uses: actions/checkout@v2
with:
fetch-depth: 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetching all of history seems a little overkill -- is it worth it to copy metpy's approach? Or maybe fetching is cheap so let's not worry about it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't take more than a few seconds for this to run so I think we should keep it simple for now.


- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install build tools
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel

- name: Build packages
run: python setup.py sdist bdist_wheel

- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be tagged to a version of the action instead of tracking the master branch?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering the same thing when I copied it from the PyPA guide. That guide also used master for the other actions that we're now pinning (in part copying metpy and other examples). Either way is fine with me.

with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Test PyPI server is new to me. The PyPI guides I'm reading all suggest using it, but don't say why -- will it fail for a malformed distribution or something? Should it be followed with a quick pip install from the test server to verify that the installation works?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link raises a good point about race conditions when the actions for multiple PRs are running in parallel -- I'm not saying one way or the other that we should use skip_existing here, but just something to be aware of if we get mysterious failures someday.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best reason to use Test PyPI is to ensure that your distribution workflow (manual or automated) works as you expect it to.

It's hard for me to imagine a situation in which we'd run into the race condition and not want to be alerted to a problem for manual fixes. The action only works on pushes to pvlib/pvlib-python - it doesn't run on PRs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I mistakenly thought that push included pushes to PRs. I'm not 100% satisfied with the documentation on this, but it seems that you are correct that it has to be a push to pvlib/pvlib-python specifically: https://developer.github.com/v3/activity/event_types/#pushevent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the action does run on pushes to forks, but it stops before doing anything meaningful. See screen shot below for a recent history of the actions on my fork.

Screen Shot 2020-08-31 at 7 47 03 PM

Unfortunately it does not seem that there is a way for us to disable actions on forks, but forks may choose to disable actions in https://github.com/{username}/pvlib-python/settings/actions


- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ matrix:
env:
- CONDA_ENV=py36
- TASK="coverage"
- DEPLOY_ENV="true"
# not needed as of GH1038. deploy block cannot run without this.
# - DEPLOY_ENV="true"
- python: 3.6
env: CONDA_ENV=py37

Expand Down
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ Testing
* Add wrappers around the pandas assert_X_equal functions to accommodate the
changed API and default precision thresholds in pandas 1.1.0
(:issue:`1018`, :pull:`1021`)
* Add github action for publishing all commits to
`test.pypi.org <https://test.pypi.org/project/pvlib/>`_ and tags to
`pypi.org <https://pypi.org/project/pvlib/>`_.

Documentation
~~~~~~~~~~~~~
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ test=pytest
[flake8]
max-line-length = 79
ignore = E201, E241, E226, W503, W504
exclude = pvlib/_version.py docs dist
exclude = pvlib/_version.py docs dist

[tool:pytest]
junit_family=xunit2