|
70 | 70 | MATRIX_PYTHON_VERSION: ${{ matrix.python-version }} |
71 | 71 | OUTPUT_PYTHON_VERSION: ${{ steps.setup-python.outputs.python-version }} |
72 | 72 |
|
| 73 | + test_setup_python_default_python_version: |
| 74 | + name: Test setup-python (default python-version) |
| 75 | + runs-on: ${{ matrix.os }} |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 79 | + steps: |
| 80 | + - name: Check out repo |
| 81 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 82 | + with: |
| 83 | + persist-credentials: false |
| 84 | + - name: Set up Python |
| 85 | + id: setup-python |
| 86 | + uses: $/setup-python |
| 87 | + - name: Check Python version |
| 88 | + run: | |
| 89 | + import sys, sysconfig, re, os |
| 90 | +
|
| 91 | + expected_python_version = os.environ["EXPECTED_PYTHON_VERSION"] |
| 92 | + output_python_version = os.environ["OUTPUT_PYTHON_VERSION"] |
| 93 | +
|
| 94 | + match = re.search(r"(\d+)\.(\d+)(?:\.(\d+))?", expected_python_version) |
| 95 | + expected_version = tuple(int(g) for g in match.groups() if g is not None) |
| 96 | + version = sys.version_info[:len(expected_version)] |
| 97 | + if version != expected_version: |
| 98 | + print(f"::error title=Test Failure::The Python version does not match. Got {version}, expected {expected_version}.") |
| 99 | + sys.exit(1) |
| 100 | + match = re.search(r"(\d+)\.(\d+)(?:\.(\d+))?", output_python_version) |
| 101 | + output_version = tuple(int(g) for g in match.groups() if g is not None)[:len(expected_version)] |
| 102 | + if output_version != expected_version: |
| 103 | + print(f"::error title=Test Failure::The outputs.python-version version does not match. Got {output_version}, expected {expected_version}.") |
| 104 | + sys.exit(1) |
| 105 | + shell: python |
| 106 | + env: |
| 107 | + EXPECTED_PYTHON_VERSION: 3.13.17 |
| 108 | + OUTPUT_PYTHON_VERSION: ${{ steps.setup-python.outputs.python-version }} |
| 109 | + |
73 | 110 | test_setup_poetry: |
74 | 111 | name: Test setup-poetry |
75 | 112 | runs-on: ${{ matrix.os }} |
@@ -509,6 +546,7 @@ jobs: |
509 | 546 | runs-on: ubuntu-latest |
510 | 547 | needs: [ |
511 | 548 | test_setup_python, |
| 549 | + test_setup_python_default_python_version, |
512 | 550 | test_setup_poetry, |
513 | 551 | test_setup_poetry_cache_hit, |
514 | 552 | test_setup_poetry_no_cache, |
|
0 commit comments