https://pantsbuild.org/ logo
#general
Title
# general
l

lemon-oxygen-72498

12/06/2022, 9:29 PM
I want to show my client a PoC how to test its python libraries with different python versions in the CI (GitHub actions), so I tried: 1. Make the CI a matrix on the desired python versions. But then I need to filter pants targets, to only test the targets for the only interpreter in scope. Clunky 😕 2. Have multiple python interpreters in scope in the CI, so that a single
./pants test ::
command tests all versions. Sounds cool on paper. But getting
pyenv
work fast in the CI is a job in itself. How do you people do that smartly on GitHub actions? Any pointer?
1
e

enough-analyst-54434

12/06/2022, 9:37 PM
I test in the second style for Pex. I happen to use tox and not Pants, but that should be irrelevant for your purposes. I use this action to get me a bunch of Pythons fast: https://github.com/pantsbuild/actions/blob/main/expose-pythons/action.yml
❤️ 1
👀 1
See here for example and expand the "Exposing Pythons" node: https://github.com/pantsbuild/pex/actions/runs/3595388275/jobs/6054817062#step:5:1
❤️ 1
That's 2.7, 3.{7,8,9,10,11} in 1s
l

lemon-oxygen-72498

12/06/2022, 9:40 PM
Awesome, looks like it's exactly what I need!
e

enough-analyst-54434

12/06/2022, 9:43 PM
That said, I think newer versions of the standard GitHub python-setup action can do the same.
l

lemon-oxygen-72498

12/06/2022, 9:44 PM
Is there a way to declare the versions I need with
Exposing Pythons
? I see I could
skip
some, but I only need a few actually.
e

enough-analyst-54434

12/06/2022, 9:45 PM
Did you try just using 1 https://github.com/actions/setup-python per version?
I think that works.
l

lemon-oxygen-72498

12/06/2022, 9:46 PM
No I didn't, that would be super simple if it works.
e

enough-analyst-54434

12/06/2022, 9:47 PM
Yeah, pretty sure it does. Only one (maybe last) will be "default", but they'll all be on PATH.
l

lemon-oxygen-72498

12/06/2022, 9:48 PM
Trying that now 🙂
e

enough-analyst-54434

12/06/2022, 9:49 PM
You can look in that 1st job setup step and expand the image node to get a link and see which versions are "fast": https://github.com/actions/runner-images/blob/macOS-11/20221127.7/images/macos/macos-11-Readme.md
There are tables for ~pre-installed versions of CPython and PyPy there.
l

lemon-oxygen-72498

12/06/2022, 9:51 PM
Yep multiple
setup-python
is working at first sight (still need to fix some things later in my pipeline, but first
pants
steps work now) 👍
You have been super helpful John, thank you very much!
4 Views