From 3d009a5143b6f3c3dfa05b9adaf126d479ac6c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Ifr=C3=A1n?= Date: Wed, 18 Jan 2023 08:21:22 -0300 Subject: [PATCH] Fix suggestios done in code review Rollback a not abot advanced usage on how to use the file and not use the GITHUB_WORKSPACE since it was removed in a previous PR --- docs/advanced-usage.md | 2 +- src/setup-python.ts | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index 718a4f5..9bdd456 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -242,7 +242,7 @@ jobs: The python-version-file input accepts a path to a file containing the version of Python to be used by a project, for example .python-version, or .tool-versions. If both the python-version and the python-version-file inputs are provided then the python-version input is used. -> The action will search for the python version file relative to the repository root. +> In case both `python-version` and `python-version-file` inputs are supplied, the `python-version-file` input will be ignored due to its lower priority. ```yaml steps: diff --git a/src/setup-python.ts b/src/setup-python.ts index 1ef7506..a10b751 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -37,18 +37,13 @@ function resolveVersionInput() { } if (versionFile) { - const versionFilePath = path.join( - process.env.GITHUB_WORKSPACE!, - versionFile - ); - - if (!fs.existsSync(versionFilePath)) { + if (!fs.existsSync(versionFile)) { throw new Error( - `The specified python version file at: ${versionFilePath} doesn't exist.` + `The specified python version file at: ${versionFile} doesn't exist.` ); } - const version = parsePythonVersionFile(fs.readFileSync(versionFilePath, 'utf8')); + const version = parsePythonVersionFile(fs.readFileSync(versionFile, 'utf8')); core.info(`Resolved ${versionFile} as ${version}`); return [version];