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

feat(ci): test that python wheels can be built and installed #546

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

radusuciu
Copy link
Contributor

Description

This adds a CI job that builds and installs python wheels for every platform that wheels are published to PyPI.

Motivation and Context

This should warn against issues such as #534.

How Has This Been Tested?

Please refer to GHA runs of this workflow in my fork: https://github.com/radusuciu/git-cliff/actions/workflows/ci.yml

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@radusuciu radusuciu requested a review from orhun as a code owner March 8, 2024 19:08
@radusuciu radusuciu marked this pull request as draft March 8, 2024 19:12
@codecov-commenter
Copy link

codecov-commenter commented Mar 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.14%. Comparing base (10b7ab8) to head (a50210d).

❗ Current head a50210d differs from pull request most recent head 28dd8f5. Consider uploading reports for the commit 28dd8f5 to get more accurate results

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #546   +/-   ##
=======================================
  Coverage   41.14%   41.14%           
=======================================
  Files          15       15           
  Lines        1038     1038           
=======================================
  Hits          427      427           
  Misses        611      611           
Flag Coverage Δ
unit-tests 41.14% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Some platforms fail `pip install` because they don't have maturin available on pypi and maturin is listed as a build dependency. As far as I understand it, configuring the build-system is only needed if we want to let users build the wheel from source when they run `pip install`. Since we provide pre-built wheels I think this isn't that useful..

A side effect of this change is that the maturin action will automatically use the latest version of maturin unless otherwise configured via one of its inputs.
@radusuciu
Copy link
Contributor Author

radusuciu commented Mar 8, 2024

It almost works:

https://github.com/radusuciu/git-cliff/actions/runs/8207985679/

The platforms that fail, fail because of the same reason:

Defaulting to user installation because normal site-packages is not writeable
Looking in links: pypi/wheels
Processing ./pypi/wheels/git_cliff-2.1.2.tar.gz
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  error: subprocess-exited-with-error
  
  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [3 lines of output]
      Looking in links: pypi/wheels
      ERROR: Could not find a version that satisfies the requirement maturin<2,>=1.5 (from versions: none)
      ERROR: No matching distribution found for maturin<2,>=1.5
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Error: Process completed with exit code 1.

Relevant line:

ERROR: Could not find a version that satisfies the requirement maturin<2,>=1.5 (from versions: none)

I think this may be because maturin isn't available for all of the same platforms that are listed in the matrix here. In any case, I think we don't actually need maturin to be installed.. I'll need to experiment with this more later, but I think this is a good base.

@orhun
Copy link
Owner

orhun commented Mar 8, 2024

Yup, the workflow looks good. Let's see if we need maturin installed. Also, do you think it is a good idea to test it for all the targets or testing it for each platform (Linux/MacOS/Windows) is enough?

@radusuciu
Copy link
Contributor Author

Yup, the workflow looks good. Let's see if we need maturin installed. Also, do you think it is a good idea to test it for all the targets or testing it for each platform (Linux/MacOS/Windows) is enough?

I'm not sure, it does seem like testing each platform is overkill. Maybe we can check out what other rust projects that use maturin are doing?

@orhun
Copy link
Owner

orhun commented Mar 8, 2024

Yeah, I agree. Checking out other projects is definitely a good idea.

@orhun
Copy link
Owner

orhun commented Mar 10, 2024

I looked around in GitHub a bit and some projects build for each target and some projects just test the platform. I think we can have this check running for each platform as well.

@davidhewitt
Copy link

Whenever you see the line

Processing ./pypi/wheels/git_cliff-2.1.2.tar.gz

It means that the wheel wasn't installable on the platform you're testing on, probably because you built for a different platform than the host interpreter running on GitHub actions. As a result, CI is trying to extract the source tarball and build it. You can prevent this fallback with --only-binary flag to pip if I recall correctly. Might be worth adding that flag given you're trying to check the wheel.

To match the python to test on to the wheel, you might have to use something like https://github.com/uraimo/run-on-arch-action to run your tests.

@radusuciu
Copy link
Contributor Author

Whenever you see the line

Processing ./pypi/wheels/git_cliff-2.1.2.tar.gz

It means that the wheel wasn't installable on the platform you're testing on, probably because you built for a different platform than the host interpreter running on GitHub actions. As a result, CI is trying to extract the source tarball and build it. You can prevent this fallback with --only-binary flag to pip if I recall correctly. Might be worth adding that flag given you're trying to check the wheel.

To match the python to test on to the wheel, you might have to use something like https://github.com/uraimo/run-on-arch-action to run your tests.

Thanks @davidhewitt for that insight! I think we can fix that up.

@orhun
Copy link
Owner

orhun commented Apr 20, 2024

Any chance that we get this done before the next release? 😊 @radusuciu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants