-
Notifications
You must be signed in to change notification settings - Fork 594
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
Cannot test matrix.python-version in a if
statement if version is dynamic (eg, *, 3.12-dev, 3.x)
#644
Comments
Maybe there is a way around but I did not find any such info in the documentation nor on internet (I guess dynamic versions aren't very popular), or maybe I'm dumb, please let me know if I missed something. |
The version you specify in the matrix is just a string that you can use anywhere, an action cannot modify it. However, this action does provide the actual resolved Python version in an output that you can use instead: https://github.com/actions/setup-python/blob/main/docs/advanced-usage.md#python-version |
@nulano Perfect, this is exactly what I needed! But I see why I missed it, there are words missing in the description, and the example is misleading (why set the id to "cp310" which clearly refers to CPython 3.10, but here it has nothing to do with that as it refers to setup-python action!). |
PS: Sorry the comment button was hit inadvertently. I will make a PR to fix this. Thank you very much for pointing this resource! |
Hello @lrq3000. I've took a look on your pull request and I'd not like to recommend using of |
@dmitry-shibanov Thank you for reviewing my PR and for your feedback. Ok I understand your reasoning, I have removed the example involving About the
It will keep on failing with a syntax error. Whereas to check Python versions, the following works fine:
This is because python-version can be specified as either a float or a string literal. The problem is that for pypy, only a string literal is possible since it must include the characters 'pypy' to signal the version refers to pypy. But now where things get muddy is that in the definition of python-version, string literals can be specified without single-quotes, as shown in the Specifying multiple Python/PyPy version section! So then it's very expectable that users will try to simply copy/paste their definition in the if expression, and then the issue will arise. Then they will try double quotes, and again it will fail. Until they stumble on the Expression manual page of GitHub workflows, and see in a footnote that only single quotes are a valid syntax for string literals... All that is to say, with this one-line addition of an example if statement, a lot of frustration and GitHub Workflow know-how prerequisites can be avoided. |
Description:
When using a dynamic (x-range) version such as *, 3.12-dev or 3.x, then the usual method of doing conditional steps (by testing in matrix.python-version >= 3.7 for example) does not work.
Action version:
1.5
Platform:
Runner type:
Tools version:
Dynamic versions.
Repro steps:
See for example the github action config file I used which caused this error:
https://github.com/lrq3000/pyFileFixity/blob/ea3ce6564a145687ca6519e8f5422c38ec88c2a1/.github/workflows/ci-build.yml
And the run:
https://github.com/lrq3000/pyFileFixity/actions/runs/4639718475
Expected behavior:
The dynamic version should resolve to a fixed version after instanciation.
Actual behavior:
Dynamic version remains as-is. If fails.
The text was updated successfully, but these errors were encountered: