mirror of
				https://github.com/astral-sh/setup-uv.git
				synced 2025-10-30 22:46:46 +00:00 
			
		
		
		
	Fallback if toml file parsing failed (#246)
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							b5f58b2abc
						
					
				
				
					commit
					14dc0be27c
				
			
							
								
								
									
										12
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								.github/workflows/test.yml
									
									
									
									
										vendored
									
									
								
							| @@ -200,3 +200,15 @@ jobs: | |||||||
|             exit 1 |             exit 1 | ||||||
|           fi |           fi | ||||||
|         shell: bash |         shell: bash | ||||||
|  |  | ||||||
|  |   test-malformed-pyproject-file-fallback: | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     steps: | ||||||
|  |       - uses: actions/checkout@v4 | ||||||
|  |       - name: Install using malformed pyproject.toml | ||||||
|  |         id: setup-uv | ||||||
|  |         uses: ./ | ||||||
|  |         with: | ||||||
|  |           pyproject-file: "__tests__/fixtures/malformed-pyproject-toml-project/pyproject.toml" | ||||||
|  |       - run: uv sync | ||||||
|  |         working-directory: __tests__/fixtures/uv-project | ||||||
|   | |||||||
| @@ -0,0 +1 @@ | |||||||
|  | 3.11 | ||||||
| @@ -0,0 +1,6 @@ | |||||||
|  | def main(): | ||||||
|  |     print("Hello from malformed-pyproject-toml-project!") | ||||||
|  |  | ||||||
|  |  | ||||||
|  | if __name__ == "__main__": | ||||||
|  |     main() | ||||||
| @@ -0,0 +1,9 @@ | |||||||
|  | [project] | ||||||
|  | name = "malformed-pyproject-toml-project" | ||||||
|  | version = "0.1.0" | ||||||
|  | description = "Add your description here" | ||||||
|  | readme = "README.md" | ||||||
|  | requires-python = ">=3.11" | ||||||
|  | dependencies = [] | ||||||
|  |  | ||||||
|  | [malformed-toml | ||||||
							
								
								
									
										10
									
								
								dist/setup/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								dist/setup/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -99655,7 +99655,15 @@ function getUvVersionFromConfigFile(filePath) { | |||||||
|         core.warning(`Could not find file: ${filePath}`); |         core.warning(`Could not find file: ${filePath}`); | ||||||
|         return undefined; |         return undefined; | ||||||
|     } |     } | ||||||
|     let requiredVersion = getRequiredVersion(filePath); |     let requiredVersion; | ||||||
|  |     try { | ||||||
|  |         requiredVersion = getRequiredVersion(filePath); | ||||||
|  |     } | ||||||
|  |     catch (err) { | ||||||
|  |         const message = err.message; | ||||||
|  |         core.warning(`Error while parsing ${filePath}: ${message}`); | ||||||
|  |         return undefined; | ||||||
|  |     } | ||||||
|     if (requiredVersion?.startsWith("==")) { |     if (requiredVersion?.startsWith("==")) { | ||||||
|         requiredVersion = requiredVersion.slice(2); |         requiredVersion = requiredVersion.slice(2); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -9,7 +9,14 @@ export function getUvVersionFromConfigFile( | |||||||
|     core.warning(`Could not find file: ${filePath}`); |     core.warning(`Could not find file: ${filePath}`); | ||||||
|     return undefined; |     return undefined; | ||||||
|   } |   } | ||||||
|   let requiredVersion = getRequiredVersion(filePath); |   let requiredVersion: string | undefined; | ||||||
|  |   try { | ||||||
|  |     requiredVersion = getRequiredVersion(filePath); | ||||||
|  |   } catch (err) { | ||||||
|  |     const message = (err as Error).message; | ||||||
|  |     core.warning(`Error while parsing ${filePath}: ${message}`); | ||||||
|  |     return undefined; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   if (requiredVersion?.startsWith("==")) { |   if (requiredVersion?.startsWith("==")) { | ||||||
|     requiredVersion = requiredVersion.slice(2); |     requiredVersion = requiredVersion.slice(2); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user