MapReader icon indicating copy to clipboard operation
MapReader copied to clipboard

Deployment to test.pypi.org fails in some cases

Open andrewphilipsmith opened this issue 2 years ago • 1 comments
trafficstars

Describe the bug In certain conditions, the deployment to test.pypi.org fails with the error:

 ERROR    HTTPError: 400 Bad Request from https://test.pypi.org/legacy/          
         File already exists. See https://test.pypi.org/help/#file-name-reuse   
         for more information.  

See https://github.com/Living-with-machines/MapReader/actions/runs/5507232734/jobs/10036922341 for a specific example.

To Reproduce Steps to reproduce the behaviour:

(in theory - please don't attempt to recreate this necessarily!)

  1. Create a tagged commit on the main branch as push (as described in the developer's guide)

2.1 Locally create a new branch (branching off main):

git checkout -b deployment_issue_a

2.2 Create a change and commit in branch deployment_issue_a 2.3 Push to GitHub and create a pull request. 2.4 Check test.pypi.org - In the "Release history" there should be a version number <tagname>.post0.dev1, where <tagname> is the tag from step 1.

  1. Locally switch back to the main branch
git checkout main

4.1 Locally create another new branch, again branching off main):

git checkout -b deployment_issue_b

4.2 Create a change and commit in branch deployment_issue_b 4.3 Push to GitHub and create a pull request. 4.4 Check the logs of the relevant Github action for this second PR.

Actual behaviour The relevant Github action for the second PR will fail, with this error:

 ERROR    HTTPError: 400 Bad Request from https://test.pypi.org/legacy/          
         File already exists. See https://test.pypi.org/help/#file-name-reuse   
         for more information.  

Expected behaviour A uniquely numbered version should deploy to test.pypi.org for every non-tagged commit.

Additional context Currently, MapReader uses versioneer to generate the version number, using git as the single-source of information.

For development versions, the distance parameter is used. This counts the number of commits since the last tagged commit. When there are two separate branches downstream of the tagged commit, both of which have an open PR, this gives the possibility of there being identical distance values between the branches. This in turn leads to non-unique version numbers.

andrewphilipsmith avatar Jul 12 '23 19:07 andrewphilipsmith

To solve this we will need either:

  • A way of including the branch name/ or PR-id in addition to the distance in the version string. Whilst still complying with PyPI's rules.
  • A way that uses an ID that is unique across branches for the devX part for the version number. GITHUB_RUN_NUMBER might be a suitable source, but this has the disadvantage of being non-deterministic (as it will depend of the timing of the commits / queue in the GH Actions system).

andrewphilipsmith avatar Jul 12 '23 19:07 andrewphilipsmith