Under v4, not specifying a python-version results in a failure to run

Description:

In jobs which use the setup-python action without specifying a version, the change in #336 (python-version-file) causes a failure.
There's no value for python-version, so it attempts to read python-version-file with the default value. Because that file does not exist, the action fails.

Action version:

v4

Platform:

  • Ubuntu
  • macOS
  • Windows

(Probably impacts all, I haven't tested.)

Runner type:

  • Hosted
  • Self-hosted

(Again, presumably impacts both.)

Tools version:
N/A

Repro steps:
A job like this should reproduce:

jobs:
  repro-python-version-bug:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
      - run: python -V

In case it does not, here's one of my original jobs:

jobs:
  pylint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
      - run: python -m pip install -U tox
      - run: tox -e pylint

Expected behavior:

The action should install one of the currently supported cpython versions.
For a job like this, the user is stating that they don't care which version is used, so long as it's a current version.

Actual behavior:

Crashfail with this message:

> Run actions/setup-python@v4
Error: The specified python version file at: /home/runner/work/globus-sdk-python/globus-sdk-python/.python-version does not exist

Quick fix for future readers

If you're reading this and not sure how to get the old behavior, change any job like so

 jobs:
   foo-job:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v3
       - uses: actions/setup-python@v4
+        with:
+          python-version: '3.x'
       - run: python -V

I recommend doing this over creating a .python-version file if you are not already using one. .python-version is used by pyenv, so putting 3.x into it would not be appropriate. You'll get errors like:

pyenv: version `3.x' is not installed (set by /.../.python-version)