mirror of
				https://gitea.com/actions/setup-python.git
				synced 2025-10-31 03:38:56 +08:00 
			
		
		
		
	Compare commits
	
		
			14 Commits
		
	
	
		
			dependabot
			...
			test-macos
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 09262e015b | ||
|   | 06417d4504 | ||
|   | d1bb3a8c04 | ||
|   | ade6528851 | ||
|   | 3c6f142cc0 | ||
|   | 88ffd4d597 | ||
|   | 532b046aaf | ||
|   | 1264885983 | ||
|   | e9c40fbc2b | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 5fa0ee6f38 | ||
|   | 5db1cf9a59 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | a26af69be9 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 30eafe9548 | ||
| ![dependabot[bot]](/assets/img/avatar_default.png)  | 5d95bc16d4 | 
							
								
								
									
										91
									
								
								.github/workflows/e2e-cache-freethreaded.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										91
									
								
								.github/workflows/e2e-cache-freethreaded.yml
									
									
									
									
										vendored
									
									
								
							| @@ -6,7 +6,7 @@ on: | ||||
|       - '**.md' | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|       - test-macos-x64-runner | ||||
|       - releases/* | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
| @@ -23,13 +23,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
| @@ -50,15 +44,9 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|         python-version: [3.13.1t, 3.13.2t, 3.13.5t] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Python | ||||
| @@ -80,13 +68,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13.0, 3.13.1, 3.13.2] | ||||
|     steps: | ||||
| @@ -112,13 +94,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
| @@ -140,15 +116,9 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|         python-version: [3.13.1t, 3.13.2t, 3.13.5t] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Python | ||||
| @@ -162,3 +132,48 @@ jobs: | ||||
|         run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python | ||||
|       - name: Install dependencies | ||||
|         run: pipenv install requests | ||||
|  | ||||
|   python-pip-dependencies-caching-with-pip-version: | ||||
|     name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}) | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Python | ||||
|         uses: ./ | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
|           cache: 'pip' | ||||
|           pip-version: '25.0.1' | ||||
|       - name: Install dependencies | ||||
|         run: pip install numpy pandas requests | ||||
|  | ||||
|   python-pip-dependencies-caching-path-with-pip-version: | ||||
|     name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path) | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Python | ||||
|         uses: ./ | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
|           cache: 'pip' | ||||
|           cache-dependency-path: __tests__/data/requirements.txt | ||||
|           pip-version: '25.0.1' | ||||
|       - name: Install dependencies | ||||
|         run: pip install numpy pandas requests | ||||
|   | ||||
							
								
								
									
										87
									
								
								.github/workflows/e2e-cache.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										87
									
								
								.github/workflows/e2e-cache.yml
									
									
									
									
										vendored
									
									
								
							| @@ -6,7 +6,7 @@ on: | ||||
|       - '**.md' | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|       - test-macos-x64-runner | ||||
|       - releases/* | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
| @@ -23,13 +23,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: | ||||
|           [ | ||||
| @@ -63,13 +57,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: | ||||
|           ['3.10', 'pypy-3.10-v7.x', '3.11', 'pypy-3.11-v7.x', '3.12', '3.13'] | ||||
| @@ -120,13 +108,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: | ||||
|           [ | ||||
| @@ -161,13 +143,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: | ||||
|           [ | ||||
| @@ -202,13 +178,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             windows-latest, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: | ||||
|           ['3.10', 'pypy-3.10-v7.x', '3.11', 'pypy-3.11-v7.x', '3.12', '3.13'] | ||||
| @@ -249,3 +219,48 @@ jobs: | ||||
|           } | ||||
|       - name: Run Python Script | ||||
|         run: pipenv run python test-pipenv.py | ||||
|  | ||||
|   python-pip-dependencies-caching-with-pip-version: | ||||
|     name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}) | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Python | ||||
|         uses: ./ | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
|           cache: 'pip' | ||||
|           pip-version: '25.0.1' | ||||
|       - name: Install dependencies | ||||
|         run: pip install numpy pandas requests | ||||
|  | ||||
|   python-pip-dependencies-caching-path-with-pip-version: | ||||
|     name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path) | ||||
|     runs-on: ${{ matrix.os }} | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup Python | ||||
|         uses: ./ | ||||
|         with: | ||||
|           python-version: ${{ matrix.python-version }} | ||||
|           cache: 'pip' | ||||
|           cache-dependency-path: __tests__/data/requirements.txt | ||||
|           pip-version: '25.0.1' | ||||
|       - name: Install dependencies | ||||
|         run: pip install numpy pandas requests | ||||
|   | ||||
							
								
								
									
										13
									
								
								.github/workflows/e2e-tests.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/e2e-tests.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ name: e2e tests | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|       - test-macos-x64-runner | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
|   pull_request: | ||||
| @@ -19,13 +19,7 @@ jobs: | ||||
|       matrix: | ||||
|         operating-system: | ||||
|           [ | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm, | ||||
|             macos-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
| @@ -38,7 +32,7 @@ jobs: | ||||
|       - name: Verify 3.9.13 | ||||
|         run: python __tests__/verify-python.py 3.9.13 | ||||
|  | ||||
|       - name: Run with setup-python 3.9.13 | ||||
|       - name: Run with setup-python 3.10.11 | ||||
|         uses: ./ | ||||
|         with: | ||||
|           python-version: 3.10.11 | ||||
| @@ -89,6 +83,7 @@ jobs: | ||||
|           python-version: '<3.13' | ||||
|       - name: Verify <3.13 | ||||
|         run: python __tests__/verify-python.py 3.12 | ||||
|  | ||||
|       - name: Test Raw Endpoint Access | ||||
|         run: | | ||||
|           curl -L https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json | jq empty | ||||
|   | ||||
							
								
								
									
										18
									
								
								.github/workflows/test-graalpy.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								.github/workflows/test-graalpy.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ name: Validate GraalPy e2e | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|       - test-macos-x64-runner | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
|   pull_request: | ||||
| @@ -20,12 +20,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         graalpy: | ||||
|           - 'graalpy-22.3' | ||||
| @@ -75,12 +70,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         graalpy: ['graalpy22.3', 'graalpy23.0', 'graalpy23.1', 'graalpy24.1'] | ||||
|  | ||||
| @@ -106,7 +96,7 @@ jobs: | ||||
|     strategy: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: [ubuntu-latest, macos-latest, macos-13] | ||||
|         os: [macos-14-large] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Setup GraalPy and check latest | ||||
|   | ||||
							
								
								
									
										45
									
								
								.github/workflows/test-pypy.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								.github/workflows/test-pypy.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ name: Validate PyPy e2e | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|       - test-macos-x64-runner | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
|   pull_request: | ||||
| @@ -22,13 +22,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         pypy: | ||||
|           - 'pypy-2.7' | ||||
| @@ -85,16 +79,7 @@ jobs: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: | ||||
|           - macos-13 | ||||
|           - macos-14 | ||||
|           - macos-15 | ||||
|           - windows-2019 | ||||
|           - windows-2022 | ||||
|           - windows-2025 | ||||
|           - ubuntu-22.04 | ||||
|           - ubuntu-24.04 | ||||
|           - ubuntu-22.04-arm | ||||
|           - ubuntu-24.04-arm | ||||
|           - macos-14-large | ||||
|         pypy: ['pypy-2.7', 'pypy-3.10', 'pypy-3.11'] | ||||
|  | ||||
|     steps: | ||||
| @@ -139,13 +124,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         pypy: ['pypy2.7', 'pypy3.9', 'pypy3.10-nightly', 'pypy3.11'] | ||||
|  | ||||
| @@ -173,13 +152,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
| @@ -215,13 +188,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|   | ||||
							
								
								
									
										115
									
								
								.github/workflows/test-python-freethreaded.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										115
									
								
								.github/workflows/test-python-freethreaded.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ name: Validate Python e2e freethread | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|       - test-macos-x64-runner | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
|   pull_request: | ||||
| @@ -22,14 +22,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
| @@ -60,14 +53,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
| @@ -101,14 +87,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
| @@ -140,14 +119,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.0, 3.13.1, 3.13.2] | ||||
|     steps: | ||||
| @@ -182,14 +154,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.0, 3.13.1, 3.13.2] | ||||
|     steps: | ||||
| @@ -224,14 +189,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.0t, 3.13.1t, 3.13.2t, 3.14t-dev] | ||||
|     steps: | ||||
| @@ -256,14 +214,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
| @@ -294,13 +245,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
| @@ -331,13 +276,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
| @@ -369,14 +308,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.0t, 3.13.1t, 3.13.2t] | ||||
|     steps: | ||||
| @@ -403,13 +335,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: [3.13t, 3.14t-dev] | ||||
|     steps: | ||||
| @@ -430,13 +356,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
| @@ -459,14 +379,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-20.04, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.13.1, 3.13.2, 3.14-dev, 3.14.0-alpha.6] | ||||
|     steps: | ||||
|   | ||||
							
								
								
									
										100
									
								
								.github/workflows/test-python.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										100
									
								
								.github/workflows/test-python.yml
									
									
									
									
										vendored
									
									
								
							| @@ -3,7 +3,7 @@ name: Validate Python e2e | ||||
| on: | ||||
|   push: | ||||
|     branches: | ||||
|       - main | ||||
|       - test-macos-x64-runner | ||||
|     paths-ignore: | ||||
|       - '**.md' | ||||
|   pull_request: | ||||
| @@ -22,13 +22,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.9.13, 3.10.11, 3.11.9, 3.12.3, 3.13.2] | ||||
|     steps: | ||||
| @@ -66,13 +60,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.9.13, 3.10.11, 3.11.9, 3.12.3, 3.13.2] | ||||
|     steps: | ||||
| @@ -113,13 +101,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.9.13, 3.10.11, 3.11.9, 3.12.3, 3.13.2] | ||||
|     steps: | ||||
| @@ -158,13 +140,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.9.13, 3.10.11, 3.11.9, '==3.12.3', 3.13.2] | ||||
|     steps: | ||||
| @@ -208,13 +184,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [3.9.13, 3.10.11, 3.11.9, 3.12.3, 3.13.2] | ||||
|     steps: | ||||
| @@ -258,13 +228,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: [pypy3.11-7.3.18, graalpy-24.1.2, 3.13.2, 3.14-dev] | ||||
|         exclude: | ||||
| @@ -292,13 +256,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
| @@ -335,13 +293,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
| @@ -372,13 +324,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - name: Checkout | ||||
| @@ -410,13 +356,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             macos-13, | ||||
|             ubuntu-latest, | ||||
|             ubuntu-24.04-arm | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python: ['3.9', '3.10', '3.11', '3.12', '3.13'] | ||||
|     steps: | ||||
| @@ -443,13 +383,7 @@ jobs: | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|             macos-14-large | ||||
|           ] | ||||
|         python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] | ||||
|     steps: | ||||
| @@ -475,14 +409,8 @@ jobs: | ||||
|       fail-fast: false | ||||
|       matrix: | ||||
|         os: | ||||
|           [ | ||||
|             macos-latest, | ||||
|             windows-latest, | ||||
|             ubuntu-22.04, | ||||
|             ubuntu-22.04-arm, | ||||
|             ubuntu-24.04-arm, | ||||
|             ubuntu-latest, | ||||
|             macos-13 | ||||
|          [ | ||||
|             macos-14-large | ||||
|           ] | ||||
|     steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|   | ||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/tool-cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/tool-cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/tool-cache" | ||||
| version: 2.0.1 | ||||
| version: 2.0.2 | ||||
| type: npm | ||||
| summary: Actions tool-cache lib | ||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/tool-cache | ||||
|   | ||||
							
								
								
									
										26
									
								
								.licenses/npm/lru-cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										26
									
								
								.licenses/npm/lru-cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,26 +0,0 @@ | ||||
| --- | ||||
| name: lru-cache | ||||
| version: 6.0.0 | ||||
| type: npm | ||||
| summary: A cache object that deletes the least-recently-used items. | ||||
| homepage:  | ||||
| license: isc | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|   text: | | ||||
|     The ISC License | ||||
| 
 | ||||
|     Copyright (c) Isaac Z. Schlueter and Contributors | ||||
| 
 | ||||
|     Permission to use, copy, modify, and/or distribute this software for any | ||||
|     purpose with or without fee is hereby granted, provided that the above | ||||
|     copyright notice and this permission notice appear in all copies. | ||||
| 
 | ||||
|     THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
|     WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
|     MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
|     ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
|     WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
|     ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||||
|     IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| notices: [] | ||||
| @@ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: semver | ||||
| version: 7.6.0 | ||||
| version: 7.7.1 | ||||
| type: npm | ||||
| summary: The semantic version parser used by npm. | ||||
| homepage: | ||||
							
								
								
									
										39
									
								
								.licenses/npm/uuid-3.4.0.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										39
									
								
								.licenses/npm/uuid-3.4.0.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,39 +0,0 @@ | ||||
| --- | ||||
| name: uuid | ||||
| version: 3.4.0 | ||||
| type: npm | ||||
| summary: RFC4122 (v1, v4, and v5) UUIDs | ||||
| homepage: https://github.com/uuidjs/uuid#readme | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: LICENSE.md | ||||
|   text: | | ||||
|     The MIT License (MIT) | ||||
| 
 | ||||
|     Copyright (c) 2010-2016 Robert Kieffer and other contributors | ||||
| 
 | ||||
|     Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|     of this software and associated documentation files (the "Software"), to deal | ||||
|     in the Software without restriction, including without limitation the rights | ||||
|     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|     copies of the Software, and to permit persons to whom the Software is | ||||
|     furnished to do so, subject to the following conditions: | ||||
| 
 | ||||
|     The above copyright notice and this permission notice shall be included in all | ||||
|     copies or substantial portions of the Software. | ||||
| 
 | ||||
|     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||||
|     SOFTWARE. | ||||
| notices: | ||||
| - sources: AUTHORS | ||||
|   text: |- | ||||
|     Robert Kieffer <robert@broofa.com> | ||||
|     Christoph Tavan <dev@tavan.de> | ||||
|     AJ ONeal <coolaj86@gmail.com> | ||||
|     Vincent Voyer <vincent@zeroload.net> | ||||
|     Roman Shtylman <shtylman@gmail.com> | ||||
| @@ -3,7 +3,7 @@ name: uuid | ||||
| version: 8.3.2 | ||||
| type: npm | ||||
| summary: RFC4122 (v1, v4, and v5) UUIDs | ||||
| homepage: https://github.com/uuidjs/uuid#readme | ||||
| homepage: | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: LICENSE.md | ||||
							
								
								
									
										26
									
								
								.licenses/npm/yallist.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										26
									
								
								.licenses/npm/yallist.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,26 +0,0 @@ | ||||
| --- | ||||
| name: yallist | ||||
| version: 4.0.0 | ||||
| type: npm | ||||
| summary: Yet Another Linked List | ||||
| homepage:  | ||||
| license: isc | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|   text: | | ||||
|     The ISC License | ||||
| 
 | ||||
|     Copyright (c) Isaac Z. Schlueter and Contributors | ||||
| 
 | ||||
|     Permission to use, copy, modify, and/or distribute this software for any | ||||
|     purpose with or without fee is hereby granted, provided that the above | ||||
|     copyright notice and this permission notice appear in all copies. | ||||
| 
 | ||||
|     THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
|     WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
|     MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
|     ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
|     WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
|     ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR | ||||
|     IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| notices: [] | ||||
| @@ -94,6 +94,8 @@ steps: | ||||
|  | ||||
| >The requirements file format allows for specifying dependency versions using logical operators (for example chardet>=3.0.4) or specifying dependencies without any versions. In this case the pip install -r requirements.txt command will always try to install the latest available package version. To be sure that the cache will be used, please stick to a specific dependency version and update it manually if necessary. | ||||
|  | ||||
| >The `setup-python` action does not handle authentication for pip when installing packages from private repositories. For help, refer [pip’s VCS support documentation](https://pip.pypa.io/en/stable/topics/vcs-support/) or visit the [pip repository](https://github.com/pypa/pip). | ||||
|  | ||||
| See examples of using `cache` and `cache-dependency-path` for `pipenv` and `poetry` in the section: [Caching packages](docs/advanced-usage.md#caching-packages) of the [Advanced usage](docs/advanced-usage.md) guide. | ||||
|  | ||||
| ## Advanced usage | ||||
| @@ -108,6 +110,7 @@ See examples of using `cache` and `cache-dependency-path` for `pipenv` and `poet | ||||
| - [Using `setup-python` with a self-hosted runner](docs/advanced-usage.md#using-setup-python-with-a-self-hosted-runner) | ||||
| - [Using `setup-python` on GHES](docs/advanced-usage.md#using-setup-python-on-ghes) | ||||
| - [Allow pre-releases](docs/advanced-usage.md#allow-pre-releases) | ||||
| - [Using the pip-version input](docs/advanced-usage.md#using-the-pip-version-input) | ||||
|  | ||||
| ## Recommended permissions | ||||
|  | ||||
|   | ||||
							
								
								
									
										149
									
								
								__tests__/setup-python.test.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										149
									
								
								__tests__/setup-python.test.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,149 @@ | ||||
| import * as core from '@actions/core'; | ||||
| import * as fs from 'fs'; | ||||
| import * as path from 'path'; | ||||
| import {cacheDependencies} from '../src/setup-python'; | ||||
| import {getCacheDistributor} from '../src/cache-distributions/cache-factory'; | ||||
|  | ||||
| jest.mock('fs', () => { | ||||
|   const actualFs = jest.requireActual('fs'); | ||||
|   return { | ||||
|     ...actualFs, | ||||
|     promises: { | ||||
|       access: jest.fn(), | ||||
|       mkdir: jest.fn(), | ||||
|       copyFile: jest.fn(), | ||||
|       writeFile: jest.fn(), | ||||
|       appendFile: jest.fn() | ||||
|     } | ||||
|   }; | ||||
| }); | ||||
| jest.mock('@actions/core'); | ||||
| jest.mock('../src/cache-distributions/cache-factory'); | ||||
|  | ||||
| const mockedFsPromises = fs.promises as jest.Mocked<typeof fs.promises>; | ||||
| const mockedCore = core as jest.Mocked<typeof core>; | ||||
| const mockedGetCacheDistributor = getCacheDistributor as jest.Mock; | ||||
|  | ||||
| describe('cacheDependencies', () => { | ||||
|   const mockRestoreCache = jest.fn(); | ||||
|  | ||||
|   beforeEach(() => { | ||||
|     jest.clearAllMocks(); | ||||
|     process.env.GITHUB_ACTION_PATH = '/github/action'; | ||||
|     process.env.GITHUB_WORKSPACE = '/github/workspace'; | ||||
|  | ||||
|     mockedCore.getInput.mockReturnValue('nested/deps.lock'); | ||||
|  | ||||
|     // Simulate file exists by resolving access without error | ||||
|     mockedFsPromises.access.mockImplementation(async p => { | ||||
|       const pathStr = typeof p === 'string' ? p : p.toString(); | ||||
|       if (pathStr === '/github/action/nested/deps.lock') { | ||||
|         return Promise.resolve(); | ||||
|       } | ||||
|       // Simulate directory doesn't exist to test mkdir | ||||
|       if (pathStr === path.dirname('/github/workspace/nested/deps.lock')) { | ||||
|         return Promise.reject(new Error('no dir')); | ||||
|       } | ||||
|       return Promise.resolve(); | ||||
|     }); | ||||
|  | ||||
|     // Simulate mkdir success | ||||
|     mockedFsPromises.mkdir.mockResolvedValue(undefined); | ||||
|  | ||||
|     // Simulate copyFile success | ||||
|     mockedFsPromises.copyFile.mockResolvedValue(undefined); | ||||
|  | ||||
|     mockedGetCacheDistributor.mockReturnValue({restoreCache: mockRestoreCache}); | ||||
|   }); | ||||
|  | ||||
|   it('copies the dependency file and resolves the path with directory structure', async () => { | ||||
|     await cacheDependencies('pip', '3.12'); | ||||
|  | ||||
|     const sourcePath = path.resolve('/github/action', 'nested/deps.lock'); | ||||
|     const targetPath = path.resolve('/github/workspace', 'nested/deps.lock'); | ||||
|  | ||||
|     expect(mockedFsPromises.access).toHaveBeenCalledWith( | ||||
|       sourcePath, | ||||
|       fs.constants.F_OK | ||||
|     ); | ||||
|     expect(mockedFsPromises.mkdir).toHaveBeenCalledWith( | ||||
|       path.dirname(targetPath), | ||||
|       { | ||||
|         recursive: true | ||||
|       } | ||||
|     ); | ||||
|     expect(mockedFsPromises.copyFile).toHaveBeenCalledWith( | ||||
|       sourcePath, | ||||
|       targetPath | ||||
|     ); | ||||
|     expect(mockedCore.info).toHaveBeenCalledWith( | ||||
|       `Copied ${sourcePath} to ${targetPath}` | ||||
|     ); | ||||
|     expect(mockedCore.info).toHaveBeenCalledWith( | ||||
|       `Resolved cache-dependency-path: nested/deps.lock` | ||||
|     ); | ||||
|     expect(mockRestoreCache).toHaveBeenCalled(); | ||||
|   }); | ||||
|  | ||||
|   it('warns if the dependency file does not exist', async () => { | ||||
|     // Simulate file does not exist by rejecting access | ||||
|     mockedFsPromises.access.mockRejectedValue(new Error('file not found')); | ||||
|  | ||||
|     await cacheDependencies('pip', '3.12'); | ||||
|  | ||||
|     expect(mockedCore.warning).toHaveBeenCalledWith( | ||||
|       expect.stringContaining('does not exist') | ||||
|     ); | ||||
|     expect(mockedFsPromises.copyFile).not.toHaveBeenCalled(); | ||||
|     expect(mockRestoreCache).toHaveBeenCalled(); | ||||
|   }); | ||||
|  | ||||
|   it('warns if file copy fails', async () => { | ||||
|     // Simulate copyFile failure | ||||
|     mockedFsPromises.copyFile.mockRejectedValue(new Error('copy failed')); | ||||
|  | ||||
|     await cacheDependencies('pip', '3.12'); | ||||
|  | ||||
|     expect(mockedCore.warning).toHaveBeenCalledWith( | ||||
|       expect.stringContaining('Failed to copy file') | ||||
|     ); | ||||
|     expect(mockRestoreCache).toHaveBeenCalled(); | ||||
|   }); | ||||
|  | ||||
|   it('skips path logic if no input is provided', async () => { | ||||
|     mockedCore.getInput.mockReturnValue(''); | ||||
|  | ||||
|     await cacheDependencies('pip', '3.12'); | ||||
|  | ||||
|     expect(mockedFsPromises.copyFile).not.toHaveBeenCalled(); | ||||
|     expect(mockedCore.warning).not.toHaveBeenCalled(); | ||||
|     expect(mockRestoreCache).toHaveBeenCalled(); | ||||
|   }); | ||||
|  | ||||
|   it('does not copy if dependency file is already inside the workspace but still sets resolved path', async () => { | ||||
|     // Simulate cacheDependencyPath inside workspace | ||||
|     mockedCore.getInput.mockReturnValue('deps.lock'); | ||||
|  | ||||
|     // Override sourcePath and targetPath to be equal | ||||
|     const actionPath = '/github/workspace'; // same path for action and workspace | ||||
|     process.env.GITHUB_ACTION_PATH = actionPath; | ||||
|     process.env.GITHUB_WORKSPACE = actionPath; | ||||
|  | ||||
|     // access resolves to simulate file exists | ||||
|     mockedFsPromises.access.mockResolvedValue(); | ||||
|  | ||||
|     await cacheDependencies('pip', '3.12'); | ||||
|  | ||||
|     const sourcePath = path.resolve(actionPath, 'deps.lock'); | ||||
|     const targetPath = sourcePath; // same path | ||||
|  | ||||
|     expect(mockedFsPromises.copyFile).not.toHaveBeenCalled(); | ||||
|     expect(mockedCore.info).toHaveBeenCalledWith( | ||||
|       `Dependency file is already inside the workspace: ${sourcePath}` | ||||
|     ); | ||||
|     expect(mockedCore.info).toHaveBeenCalledWith( | ||||
|       `Resolved cache-dependency-path: deps.lock` | ||||
|     ); | ||||
|     expect(mockRestoreCache).toHaveBeenCalled(); | ||||
|   }); | ||||
| }); | ||||
| @@ -10,7 +10,7 @@ import { | ||||
|   validatePythonVersionFormatForPyPy, | ||||
|   isCacheFeatureAvailable, | ||||
|   getVersionInputFromFile, | ||||
|   getVersionInputFromPlainFile, | ||||
|   getVersionsInputFromPlainFile, | ||||
|   getVersionInputFromTomlFile, | ||||
|   getNextPageUrl, | ||||
|   isGhes, | ||||
| @@ -24,10 +24,10 @@ jest.mock('@actions/core'); | ||||
|  | ||||
| describe('validatePythonVersionFormatForPyPy', () => { | ||||
|   it.each([ | ||||
|     ['3.6', true], | ||||
|     ['3.7', true], | ||||
|     ['3.6.x', false], | ||||
|     ['3.7.x', false], | ||||
|     ['3.12', true], | ||||
|     ['3.13', true], | ||||
|     ['3.12.x', false], | ||||
|     ['3.13.x', false], | ||||
|     ['3.x', false], | ||||
|     ['3', false] | ||||
|   ])('%s -> %s', (input, expected) => { | ||||
| @@ -95,24 +95,52 @@ const tempDir = path.join( | ||||
| ); | ||||
|  | ||||
| describe('Version from file test', () => { | ||||
|   it.each([getVersionInputFromPlainFile, getVersionInputFromFile])( | ||||
|   it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])( | ||||
|     'Version from plain file test', | ||||
|     async _fn => { | ||||
|       await io.mkdirP(tempDir); | ||||
|       const pythonVersionFileName = 'python-version.file'; | ||||
|       const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); | ||||
|       const pythonVersionFileContent = '3.7'; | ||||
|       const pythonVersionFileContent = '3.13'; | ||||
|       fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); | ||||
|       expect(_fn(pythonVersionFilePath)).toEqual([pythonVersionFileContent]); | ||||
|     } | ||||
|   ); | ||||
|   it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])( | ||||
|     'Versions from multiline plain file test', | ||||
|     async _fn => { | ||||
|       await io.mkdirP(tempDir); | ||||
|       const pythonVersionFileName = 'python-version.file'; | ||||
|       const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); | ||||
|       const pythonVersionFileContent = '3.13\r\n3.12'; | ||||
|       fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); | ||||
|       expect(_fn(pythonVersionFilePath)).toEqual(['3.13', '3.12']); | ||||
|     } | ||||
|   ); | ||||
|   it.each([getVersionsInputFromPlainFile, getVersionInputFromFile])( | ||||
|     'Version from complex plain file test', | ||||
|     async _fn => { | ||||
|       await io.mkdirP(tempDir); | ||||
|       const pythonVersionFileName = 'python-version.file'; | ||||
|       const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); | ||||
|       const pythonVersionFileContent = | ||||
|         '3.13/envs/virtualenv\r# 3.12\n3.11\r\n3.10\r\n 3.9 \r\n'; | ||||
|       fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); | ||||
|       expect(_fn(pythonVersionFilePath)).toEqual([ | ||||
|         '3.13', | ||||
|         '3.11', | ||||
|         '3.10', | ||||
|         '3.9' | ||||
|       ]); | ||||
|     } | ||||
|   ); | ||||
|   it.each([getVersionInputFromTomlFile, getVersionInputFromFile])( | ||||
|     'Version from standard pyproject.toml test', | ||||
|     async _fn => { | ||||
|       await io.mkdirP(tempDir); | ||||
|       const pythonVersionFileName = 'pyproject.toml'; | ||||
|       const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); | ||||
|       const pythonVersion = '>=3.7.0'; | ||||
|       const pythonVersion = '>=3.13.0'; | ||||
|       const pythonVersionFileContent = `[project]\nrequires-python = "${pythonVersion}"`; | ||||
|       fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); | ||||
|       expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]); | ||||
| @@ -124,7 +152,7 @@ describe('Version from file test', () => { | ||||
|       await io.mkdirP(tempDir); | ||||
|       const pythonVersionFileName = 'pyproject.toml'; | ||||
|       const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName); | ||||
|       const pythonVersion = '>=3.7.0'; | ||||
|       const pythonVersion = '>=3.13.0'; | ||||
|       const pythonVersionFileContent = `[tool.poetry.dependencies]\npython = "${pythonVersion}"`; | ||||
|       fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent); | ||||
|       expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]); | ||||
| @@ -145,9 +173,9 @@ describe('Version from file test', () => { | ||||
|     async _fn => { | ||||
|       const toolVersionFileName = '.tool-versions'; | ||||
|       const toolVersionFilePath = path.join(tempDir, toolVersionFileName); | ||||
|       const toolVersionContent = 'python 3.9.10\nnodejs 16'; | ||||
|       const toolVersionContent = 'python 3.13.2\nnodejs 16'; | ||||
|       fs.writeFileSync(toolVersionFilePath, toolVersionContent); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.9.10']); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.13.2']); | ||||
|     } | ||||
|   ); | ||||
|  | ||||
| @@ -156,9 +184,9 @@ describe('Version from file test', () => { | ||||
|     async _fn => { | ||||
|       const toolVersionFileName = '.tool-versions'; | ||||
|       const toolVersionFilePath = path.join(tempDir, toolVersionFileName); | ||||
|       const toolVersionContent = '# python 3.8\npython 3.9'; | ||||
|       const toolVersionContent = '# python 3.13\npython 3.12'; | ||||
|       fs.writeFileSync(toolVersionFilePath, toolVersionContent); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.9']); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.12']); | ||||
|     } | ||||
|   ); | ||||
|  | ||||
| @@ -167,9 +195,9 @@ describe('Version from file test', () => { | ||||
|     async _fn => { | ||||
|       const toolVersionFileName = '.tool-versions'; | ||||
|       const toolVersionFilePath = path.join(tempDir, toolVersionFileName); | ||||
|       const toolVersionContent = '  python   3.10  '; | ||||
|       const toolVersionContent = '  python   3.13  '; | ||||
|       fs.writeFileSync(toolVersionFilePath, toolVersionContent); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.10']); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.13']); | ||||
|     } | ||||
|   ); | ||||
|  | ||||
| @@ -178,9 +206,9 @@ describe('Version from file test', () => { | ||||
|     async _fn => { | ||||
|       const toolVersionFileName = '.tool-versions'; | ||||
|       const toolVersionFilePath = path.join(tempDir, toolVersionFileName); | ||||
|       const toolVersionContent = 'python v3.9.10'; | ||||
|       const toolVersionContent = 'python v3.13.2'; | ||||
|       fs.writeFileSync(toolVersionFilePath, toolVersionContent); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.9.10']); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['3.13.2']); | ||||
|     } | ||||
|   ); | ||||
|  | ||||
| @@ -189,9 +217,9 @@ describe('Version from file test', () => { | ||||
|     async _fn => { | ||||
|       const toolVersionFileName = '.tool-versions'; | ||||
|       const toolVersionFilePath = path.join(tempDir, toolVersionFileName); | ||||
|       const toolVersionContent = 'python pypy3.10-7.3.14'; | ||||
|       const toolVersionContent = 'python pypy3.10-7.3.19'; | ||||
|       fs.writeFileSync(toolVersionFilePath, toolVersionContent); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['pypy3.10-7.3.14']); | ||||
|       expect(_fn(toolVersionFilePath)).toEqual(['pypy3.10-7.3.19']); | ||||
|     } | ||||
|   ); | ||||
|  | ||||
|   | ||||
| @@ -29,6 +29,8 @@ inputs: | ||||
|   freethreaded: | ||||
|     description: "When 'true', use the freethreaded version of Python." | ||||
|     default: false | ||||
|   pip-version: | ||||
|     description: "Used to specify the version of pip to install with the Python. Supported format: major[.minor][.patch]." | ||||
| outputs: | ||||
|   python-version: | ||||
|     description: "The installed Python or PyPy version. Useful when given a version range as input." | ||||
|   | ||||
							
								
								
									
										1209
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1209
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -22,6 +22,7 @@ | ||||
|     - [macOS](advanced-usage.md#macos) | ||||
| - [Using `setup-python` on GHES](advanced-usage.md#using-setup-python-on-ghes) | ||||
| - [Allow pre-releases](advanced-usage.md#allow-pre-releases) | ||||
| - [Using the pip-version input](advanced-usage.md#using-the-pip-version-input) | ||||
|  | ||||
| ## Using the `python-version` input | ||||
|  | ||||
| @@ -411,7 +412,7 @@ steps: | ||||
| - run: pip install -e . | ||||
|   # Or pip install -e '.[test]' to install test dependencies | ||||
| ``` | ||||
|  | ||||
| Note: cache-dependency-path supports files located outside the workspace root by copying them into the workspace to enable proper caching. | ||||
| # Outputs and environment variables | ||||
|  | ||||
| ## Outputs | ||||
| @@ -643,3 +644,22 @@ jobs: | ||||
|       - run: pipx run nox --error-on-missing-interpreters -s tests-${{ matrix.python_version }} | ||||
| ``` | ||||
|  | ||||
| ## Using the pip-version input | ||||
|  | ||||
| The `pip-version` input allows you to specify the desired version of **Pip** to use with the standard Python version. | ||||
| The version of Pip should be specified in the format `major`, `major.minor`, or `major.minor.patch` (for example: 25, 25.1, or 25.0.1). | ||||
|  | ||||
| ```yaml | ||||
|       steps: | ||||
|       - uses: actions/checkout@v4 | ||||
|       - name: Set up Python | ||||
|         uses: actions/setup-python@v5 | ||||
|         with: | ||||
|           python-version: '3.13' | ||||
|           pip-version: '25.0.1' | ||||
|       - name: Display Pip version | ||||
|         run: pip --version | ||||
| ``` | ||||
| > The `pip-version` input is supported only with standard Python versions. It is not available when using PyPy or GraalPy. | ||||
|  | ||||
| > Using a specific or outdated version of pip may result in compatibility or security issues and can cause job failures. For best practices and guidance, refer to the official [pip documentation](https://pip.pypa.io/en/stable/). | ||||
							
								
								
									
										65
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										65
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -15,14 +15,14 @@ | ||||
|         "@actions/glob": "^0.5.0", | ||||
|         "@actions/http-client": "^2.2.3", | ||||
|         "@actions/io": "^1.0.2", | ||||
|         "@actions/tool-cache": "^2.0.1", | ||||
|         "@actions/tool-cache": "^2.0.2", | ||||
|         "@iarna/toml": "^3.0.0", | ||||
|         "semver": "^7.6.0" | ||||
|         "semver": "^7.7.1" | ||||
|       }, | ||||
|       "devDependencies": { | ||||
|         "@types/jest": "^29.5.12", | ||||
|         "@types/node": "^20.11.25", | ||||
|         "@types/semver": "^7.5.8", | ||||
|         "@types/semver": "^7.7.0", | ||||
|         "@typescript-eslint/eslint-plugin": "^5.54.0", | ||||
|         "@typescript-eslint/parser": "^5.54.0", | ||||
|         "@vercel/ncc": "^0.38.3", | ||||
| @@ -32,8 +32,8 @@ | ||||
|         "eslint-plugin-node": "^11.1.0", | ||||
|         "jest": "^29.7.0", | ||||
|         "jest-circus": "^29.7.0", | ||||
|         "prettier": "^2.8.4", | ||||
|         "ts-jest": "^29.3.0", | ||||
|         "prettier": "^3.5.3", | ||||
|         "ts-jest": "^29.3.2", | ||||
|         "typescript": "^5.4.2" | ||||
|       } | ||||
|     }, | ||||
| @@ -123,16 +123,16 @@ | ||||
|       "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==" | ||||
|     }, | ||||
|     "node_modules/@actions/tool-cache": { | ||||
|       "version": "2.0.1", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz", | ||||
|       "integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==", | ||||
|       "version": "2.0.2", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz", | ||||
|       "integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==", | ||||
|       "license": "MIT", | ||||
|       "dependencies": { | ||||
|         "@actions/core": "^1.2.6", | ||||
|         "@actions/core": "^1.11.1", | ||||
|         "@actions/exec": "^1.0.0", | ||||
|         "@actions/http-client": "^2.0.1", | ||||
|         "@actions/io": "^1.1.1", | ||||
|         "semver": "^6.1.0", | ||||
|         "uuid": "^3.3.2" | ||||
|         "semver": "^6.1.0" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/tool-cache/node_modules/semver": { | ||||
| @@ -1620,10 +1620,11 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@types/semver": { | ||||
|       "version": "7.5.8", | ||||
|       "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", | ||||
|       "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", | ||||
|       "dev": true | ||||
|       "version": "7.7.0", | ||||
|       "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.7.0.tgz", | ||||
|       "integrity": "sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA==", | ||||
|       "dev": true, | ||||
|       "license": "MIT" | ||||
|     }, | ||||
|     "node_modules/@types/stack-utils": { | ||||
|       "version": "2.0.3", | ||||
| @@ -4644,15 +4645,16 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/prettier": { | ||||
|       "version": "2.8.8", | ||||
|       "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", | ||||
|       "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", | ||||
|       "version": "3.5.3", | ||||
|       "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", | ||||
|       "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", | ||||
|       "dev": true, | ||||
|       "license": "MIT", | ||||
|       "bin": { | ||||
|         "prettier": "bin-prettier.js" | ||||
|         "prettier": "bin/prettier.cjs" | ||||
|       }, | ||||
|       "engines": { | ||||
|         "node": ">=10.13.0" | ||||
|         "node": ">=14" | ||||
|       }, | ||||
|       "funding": { | ||||
|         "url": "https://github.com/prettier/prettier?sponsor=1" | ||||
| @@ -5123,9 +5125,9 @@ | ||||
|       "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" | ||||
|     }, | ||||
|     "node_modules/ts-jest": { | ||||
|       "version": "29.3.0", | ||||
|       "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.0.tgz", | ||||
|       "integrity": "sha512-4bfGBX7Gd1Aqz3SyeDS9O276wEU/BInZxskPrbhZLyv+c1wskDCqDFMJQJLWrIr/fKoAH4GE5dKUlrdyvo+39A==", | ||||
|       "version": "29.3.2", | ||||
|       "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.2.tgz", | ||||
|       "integrity": "sha512-bJJkrWc6PjFVz5g2DGCNUo8z7oFEYaz1xP1NpeDU7KNLMWPpEyV8Chbpkn8xjzgRDpQhnGMyvyldoL7h8JXyug==", | ||||
|       "dev": true, | ||||
|       "license": "MIT", | ||||
|       "dependencies": { | ||||
| @@ -5137,7 +5139,7 @@ | ||||
|         "lodash.memoize": "^4.1.2", | ||||
|         "make-error": "^1.3.6", | ||||
|         "semver": "^7.7.1", | ||||
|         "type-fest": "^4.37.0", | ||||
|         "type-fest": "^4.39.1", | ||||
|         "yargs-parser": "^21.1.1" | ||||
|       }, | ||||
|       "bin": { | ||||
| @@ -5173,9 +5175,9 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/ts-jest/node_modules/type-fest": { | ||||
|       "version": "4.38.0", | ||||
|       "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.38.0.tgz", | ||||
|       "integrity": "sha512-2dBz5D5ycHIoliLYLi0Q2V7KRaDlH0uWIvmk7TYlAg5slqwiPv1ezJdZm1QEM0xgk29oYWMCbIG7E6gHpvChlg==", | ||||
|       "version": "4.40.0", | ||||
|       "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.40.0.tgz", | ||||
|       "integrity": "sha512-ABHZ2/tS2JkvH1PEjxFDTUWC8dB5OsIGZP4IFLhR293GqT5Y5qB1WwL2kMPYhQW9DVgVD8Hd7I8gjwPIf5GFkw==", | ||||
|       "dev": true, | ||||
|       "license": "(MIT OR CC0-1.0)", | ||||
|       "engines": { | ||||
| @@ -5321,15 +5323,6 @@ | ||||
|         "punycode": "^2.1.0" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/uuid": { | ||||
|       "version": "3.4.0", | ||||
|       "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", | ||||
|       "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", | ||||
|       "deprecated": "Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.", | ||||
|       "bin": { | ||||
|         "uuid": "bin/uuid" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/v8-to-istanbul": { | ||||
|       "version": "9.1.3", | ||||
|       "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.3.tgz", | ||||
|   | ||||
							
								
								
									
										10
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								package.json
									
									
									
									
									
								
							| @@ -31,14 +31,14 @@ | ||||
|     "@actions/glob": "^0.5.0", | ||||
|     "@actions/http-client": "^2.2.3", | ||||
|     "@actions/io": "^1.0.2", | ||||
|     "@actions/tool-cache": "^2.0.1", | ||||
|     "@actions/tool-cache": "^2.0.2", | ||||
|     "@iarna/toml": "^3.0.0", | ||||
|     "semver": "^7.6.0" | ||||
|     "semver": "^7.7.1" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/jest": "^29.5.12", | ||||
|     "@types/node": "^20.11.25", | ||||
|     "@types/semver": "^7.5.8", | ||||
|     "@types/semver": "^7.7.0", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.54.0", | ||||
|     "@typescript-eslint/parser": "^5.54.0", | ||||
|     "@vercel/ncc": "^0.38.3", | ||||
| @@ -48,8 +48,8 @@ | ||||
|     "eslint-plugin-node": "^11.1.0", | ||||
|     "jest": "^29.7.0", | ||||
|     "jest-circus": "^29.7.0", | ||||
|     "prettier": "^2.8.4", | ||||
|     "ts-jest": "^29.3.0", | ||||
|     "prettier": "^3.5.3", | ||||
|     "ts-jest": "^29.3.2", | ||||
|     "typescript": "^5.4.2" | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -96,7 +96,10 @@ export async function findPyPyVersion( | ||||
|     core.addPath(pythonLocation); | ||||
|     core.addPath(_binDir); | ||||
|   } | ||||
|   core.setOutput('python-version', 'pypy' + resolvedPyPyVersion); | ||||
|   core.setOutput( | ||||
|     'python-version', | ||||
|     `pypy${resolvedPythonVersion}-${resolvedPyPyVersion}` | ||||
|   ); | ||||
|   core.setOutput('python-path', pythonPath); | ||||
|  | ||||
|   return {resolvedPyPyVersion, resolvedPythonVersion}; | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import * as installer from './install-python'; | ||||
|  | ||||
| import * as core from '@actions/core'; | ||||
| import * as tc from '@actions/tool-cache'; | ||||
| import * as exec from '@actions/exec'; | ||||
|  | ||||
| // Python has "scripts" or "bin" directories where command-line tools that come with packages are installed. | ||||
| // This is where pip is, along with anything that pip installs. | ||||
| @@ -30,6 +31,27 @@ function binDir(installDir: string): string { | ||||
|   } | ||||
| } | ||||
|  | ||||
| async function installPip(pythonLocation: string) { | ||||
|   const pipVersion = core.getInput('pip-version'); | ||||
|  | ||||
|   // Validate pip-version format: major[.minor][.patch] | ||||
|   const versionRegex = /^\d+(\.\d+)?(\.\d+)?$/; | ||||
|   if (pipVersion && !versionRegex.test(pipVersion)) { | ||||
|     throw new Error( | ||||
|       `Invalid pip-version "${pipVersion}". Please specify a version in the format major[.minor][.patch].` | ||||
|     ); | ||||
|   } | ||||
|  | ||||
|   if (pipVersion) { | ||||
|     core.info( | ||||
|       `pip-version input is specified. Installing pip version ${pipVersion}` | ||||
|     ); | ||||
|     await exec.exec( | ||||
|       `${pythonLocation}/python -m pip install --upgrade pip==${pipVersion} --disable-pip-version-check --no-warn-script-location` | ||||
|     ); | ||||
|   } | ||||
| } | ||||
|  | ||||
| export async function useCpythonVersion( | ||||
|   version: string, | ||||
|   architecture: string, | ||||
| @@ -49,8 +71,8 @@ export async function useCpythonVersion( | ||||
|     // Use the freethreaded version if it was specified in the input, e.g., 3.13t | ||||
|     freethreaded = true; | ||||
|   } | ||||
|   core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`); | ||||
|  | ||||
|   core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`); | ||||
|   if (freethreaded) { | ||||
|     // Free threaded versions use an architecture suffix like `x64-freethreaded` | ||||
|     core.debug(`Using freethreaded version of ${semanticVersionSpec}`); | ||||
| @@ -154,15 +176,36 @@ export async function useCpythonVersion( | ||||
|     if (IS_WINDOWS) { | ||||
|       // Add --user directory | ||||
|       // `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/ | ||||
|       // So if `findLocalTool` succeeded above, we must have a conformant `installDir` | ||||
|       // Extract version details | ||||
|       const version = path.basename(path.dirname(installDir)); | ||||
|       const major = semver.major(version); | ||||
|       const minor = semver.minor(version); | ||||
|  | ||||
|       const basePath = process.env['APPDATA'] || ''; | ||||
|       let versionSuffix = `${major}${minor}`; | ||||
|       // Append '-32' for x86 architecture if Python version is >= 3.10 | ||||
|       if ( | ||||
|         architecture === 'x86' && | ||||
|         (major > 3 || (major === 3 && minor >= 10)) | ||||
|       ) { | ||||
|         versionSuffix += '-32'; | ||||
|       } else if (architecture === 'arm64') { | ||||
|         versionSuffix += '-arm64'; | ||||
|       } | ||||
|       // Append 't' for freethreaded builds | ||||
|       if (freethreaded) { | ||||
|         versionSuffix += 't'; | ||||
|         if (architecture === 'x86-freethreaded') { | ||||
|           versionSuffix += '-32'; | ||||
|         } else if (architecture === 'arm64-freethreaded') { | ||||
|           versionSuffix += '-arm64'; | ||||
|         } | ||||
|       } | ||||
|       // Add user Scripts path | ||||
|       const userScriptsDir = path.join( | ||||
|         process.env['APPDATA'] || '', | ||||
|         basePath, | ||||
|         'Python', | ||||
|         `Python${major}${minor}`, | ||||
|         `Python${versionSuffix}`, | ||||
|         'Scripts' | ||||
|       ); | ||||
|       core.addPath(userScriptsDir); | ||||
| @@ -179,6 +222,9 @@ export async function useCpythonVersion( | ||||
|   core.setOutput('python-version', pythonVersion); | ||||
|   core.setOutput('python-path', pythonPath); | ||||
|  | ||||
|   const binaryPath = IS_WINDOWS ? installDir : _binDir; | ||||
|   await installPip(binaryPath); | ||||
|  | ||||
|   return {impl: 'CPython', version: pythonVersion}; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -11,7 +11,7 @@ import { | ||||
|   logWarning, | ||||
|   IS_MAC, | ||||
|   getVersionInputFromFile, | ||||
|   getVersionInputFromPlainFile | ||||
|   getVersionsInputFromPlainFile | ||||
| } from './utils'; | ||||
|  | ||||
| function isPyPyVersion(versionSpec: string) { | ||||
| @@ -22,20 +22,69 @@ function isGraalPyVersion(versionSpec: string) { | ||||
|   return versionSpec.startsWith('graalpy'); | ||||
| } | ||||
|  | ||||
| async function cacheDependencies(cache: string, pythonVersion: string) { | ||||
| export async function cacheDependencies(cache: string, pythonVersion: string) { | ||||
|   const cacheDependencyPath = | ||||
|     core.getInput('cache-dependency-path') || undefined; | ||||
|   let resolvedDependencyPath: string | undefined = undefined; | ||||
|  | ||||
|   if (cacheDependencyPath) { | ||||
|     const actionPath = process.env.GITHUB_ACTION_PATH || ''; | ||||
|     const workspace = process.env.GITHUB_WORKSPACE || process.cwd(); | ||||
|  | ||||
|     const sourcePath = path.resolve(actionPath, cacheDependencyPath); | ||||
|     const relativePath = path.relative(actionPath, sourcePath); | ||||
|     const targetPath = path.resolve(workspace, relativePath); | ||||
|  | ||||
|     try { | ||||
|       const sourceExists = await fs.promises | ||||
|         .access(sourcePath, fs.constants.F_OK) | ||||
|         .then(() => true) | ||||
|         .catch(() => false); | ||||
|  | ||||
|       if (!sourceExists) { | ||||
|         core.warning( | ||||
|           `The resolved cache-dependency-path does not exist: ${sourcePath}` | ||||
|         ); | ||||
|       } else { | ||||
|         if (sourcePath !== targetPath) { | ||||
|           const targetDir = path.dirname(targetPath); | ||||
|           // Create target directory if it doesn't exist | ||||
|           await fs.promises.mkdir(targetDir, {recursive: true}); | ||||
|           // Copy file asynchronously | ||||
|           await fs.promises.copyFile(sourcePath, targetPath); | ||||
|           core.info(`Copied ${sourcePath} to ${targetPath}`); | ||||
|         } else { | ||||
|           core.info( | ||||
|             `Dependency file is already inside the workspace: ${sourcePath}` | ||||
|           ); | ||||
|         } | ||||
|  | ||||
|         resolvedDependencyPath = path | ||||
|           .relative(workspace, targetPath) | ||||
|           .replace(/\\/g, '/'); | ||||
|         core.info(`Resolved cache-dependency-path: ${resolvedDependencyPath}`); | ||||
|       } | ||||
|     } catch (error) { | ||||
|       core.warning( | ||||
|         `Failed to copy file from ${sourcePath} to ${targetPath}: ${error}` | ||||
|       ); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   // Pass resolvedDependencyPath if available, else fallback to original input | ||||
|   const dependencyPathForCache = resolvedDependencyPath ?? cacheDependencyPath; | ||||
|  | ||||
|   const cacheDistributor = getCacheDistributor( | ||||
|     cache, | ||||
|     pythonVersion, | ||||
|     cacheDependencyPath | ||||
|     dependencyPathForCache | ||||
|   ); | ||||
|   await cacheDistributor.restoreCache(); | ||||
| } | ||||
|  | ||||
| function resolveVersionInputFromDefaultFile(): string[] { | ||||
|   const couples: [string, (versionFile: string) => string[]][] = [ | ||||
|     ['.python-version', getVersionInputFromPlainFile] | ||||
|     ['.python-version', getVersionsInputFromPlainFile] | ||||
|   ]; | ||||
|   for (const [versionFile, _fn] of couples) { | ||||
|     logWarning( | ||||
|   | ||||
							
								
								
									
										31
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								src/utils.ts
									
									
									
									
									
								
							| @@ -228,7 +228,7 @@ function extractValue(obj: any, keys: string[]): string | undefined { | ||||
|  * If none is present, returns an empty list. | ||||
|  */ | ||||
| export function getVersionInputFromTomlFile(versionFile: string): string[] { | ||||
|   core.debug(`Trying to resolve version form ${versionFile}`); | ||||
|   core.debug(`Trying to resolve version from ${versionFile}`); | ||||
|  | ||||
|   let pyprojectFile = fs.readFileSync(versionFile, 'utf8'); | ||||
|   // Normalize the line endings in the pyprojectFile | ||||
| @@ -269,13 +269,28 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Python version extracted from a plain text file. | ||||
|  * Python versions extracted from a plain text file. | ||||
|  * - Resolves multiple versions from multiple lines. | ||||
|  * - Handles pyenv-virtualenv pointers (e.g. `3.10/envs/virtualenv`). | ||||
|  * - Ignores empty lines and lines starting with `#` | ||||
|  * - Trims whitespace. | ||||
|  */ | ||||
| export function getVersionInputFromPlainFile(versionFile: string): string[] { | ||||
|   core.debug(`Trying to resolve version form ${versionFile}`); | ||||
|   const version = fs.readFileSync(versionFile, 'utf8').trim(); | ||||
|   core.info(`Resolved ${versionFile} as ${version}`); | ||||
|   return [version]; | ||||
| export function getVersionsInputFromPlainFile(versionFile: string): string[] { | ||||
|   core.debug(`Trying to resolve versions from ${versionFile}`); | ||||
|   const content = fs.readFileSync(versionFile, 'utf8').trim(); | ||||
|   const lines = content.split(/\r\n|\r|\n/); | ||||
|   const versions = lines | ||||
|     .map(line => { | ||||
|       if (line.startsWith('#') || line.trim() === '') { | ||||
|         return undefined; | ||||
|       } | ||||
|       let version: string = line.trim(); | ||||
|       version = version.split('/')[0]; | ||||
|       return version; | ||||
|     }) | ||||
|     .filter(version => version !== undefined) as string[]; | ||||
|   core.info(`Resolved ${versionFile} as ${versions.join(', ')}`); | ||||
|   return versions; | ||||
| } | ||||
|  | ||||
| /** | ||||
| @@ -319,7 +334,7 @@ export function getVersionInputFromFile(versionFile: string): string[] { | ||||
|   } else if (versionFile.match('.tool-versions')) { | ||||
|     return getVersionInputFromToolVersions(versionFile); | ||||
|   } else { | ||||
|     return getVersionInputFromPlainFile(versionFile); | ||||
|     return getVersionsInputFromPlainFile(versionFile); | ||||
|   } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user