Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent failing on duplicate pushes to TestPyPI @ GHA #857

Merged
merged 3 commits into from
Jun 30, 2020

Conversation

webknjaz
Copy link
Member

This change addresses the case when there's two workflow runs
for the same commit triggered via different events. Like push
and create. In this case, publishing to PyPI may fail because
both would generate dists with the same version causing a
conflict on upload.

@ssbarnea
Copy link
Member

@ssbarnea ssbarnea added the skip-changelog Can be missed from the changelog. label Jun 30, 2020
webknjaz added 2 commits June 30, 2020 15:32
This change addresses the case when there's two workflow runs
for the same commit triggered via different events. Like `push`
and `create`. In this case, publishing to PyPI may fail because
both would generate dists with the same version causing a
conflict on upload.
@webknjaz webknjaz force-pushed the testing/gha-testpypi-publ-race-condition branch from 1ccdcc0 to 1f1d561 Compare June 30, 2020 13:51
This change will produce versions that equal to tags only on tag
creation events while all other events won't take that tag into
account.

Such an approach allows us to avoid race conditions arising from
pushing Git tags around the same time as pushing the corresponding
commits to master. Both workflows will then have access to the tag
on the current commit and setuptools-scm would generate the same
version which would explode during publishing to TestPyPI.

Non-tag-creation workflows remove any tags from HEAD after checkout
making the generated version for those builds be based on the previous
tag in the branch.
@webknjaz webknjaz force-pushed the testing/gha-testpypi-publ-race-condition branch from 1f1d561 to 9576b58 Compare June 30, 2020 14:15
@webknjaz webknjaz changed the title Don't fail on duplicate pushes to TestPyPI @ GHA Prevent failing on duplicate pushes to TestPyPI @ GHA Jun 30, 2020
@webknjaz webknjaz merged commit 5f51572 into master Jun 30, 2020
webknjaz added a commit that referenced this pull request Jun 30, 2020
This is needed to address a regression introduced by #857.

Doing `git fetch --depth=1` makes the repo shallow again and
combined with all tags removed from `HEAD` it tricks
`setuptools_scm` to return v0.1.
webknjaz added a commit that referenced this pull request Jun 30, 2020
@webknjaz webknjaz deleted the testing/gha-testpypi-publ-race-condition branch July 2, 2020 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Can be missed from the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use an API token for uploading to PyPI from Travis CI instead of account creds
2 participants