From 632a5f6f702c53ad5ef027a45ec4c1192807d125 Mon Sep 17 00:00:00 2001 From: Kurt von Laven Date: Sun, 12 Jun 2022 13:28:57 -0700 Subject: [PATCH 1/2] Bump setup-python in lock file: 3.1.1 --> 4.0.0. --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5354897b3..d009e435c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "setup-python", - "version": "3.1.1", + "version": "4.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "setup-python", - "version": "3.1.1", + "version": "4.0.0", "license": "MIT", "dependencies": { "@actions/cache": "^2.0.2", From c3247d24b5b2b7edbd32a43dfc111453928d4790 Mon Sep 17 00:00:00 2001 From: Kurt von Laven Date: Sat, 11 Jun 2022 17:45:39 -0700 Subject: [PATCH 2/2] Allow python-version-file to be a relative path Don't assume that it is safe to prepend the GITHUB_WORKSPACE environment variable to the given path since the path may already be absolute. --- dist/setup/index.js | 10 +++++----- src/setup-python.ts | 13 +++++-------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 0d98b66f4..3c417588f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -64546,18 +64546,18 @@ function cacheDependencies(cache, pythonVersion) { } function resolveVersionInput() { let version = core.getInput('python-version'); - const versionFile = core.getInput('python-version-file'); + let versionFile = core.getInput('python-version-file'); if (version && versionFile) { core.warning('Both python-version and python-version-file inputs are specified, only python-version will be used'); } if (version) { return version; } - const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFile || '.python-version'); - if (!fs_1.default.existsSync(versionFilePath)) { - throw new Error(`The specified python version file at: ${versionFilePath} does not exist`); + versionFile = versionFile || '.python-version'; + if (!fs_1.default.existsSync(versionFile)) { + throw new Error(`The specified python version file at: ${versionFile} does not exist`); } - version = fs_1.default.readFileSync(versionFilePath, 'utf8'); + version = fs_1.default.readFileSync(versionFile, 'utf8'); core.info(`Resolved ${versionFile} as ${version}`); return version; } diff --git a/src/setup-python.ts b/src/setup-python.ts index f5f8c919d..2ffeb1ade 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -24,7 +24,7 @@ async function cacheDependencies(cache: string, pythonVersion: string) { function resolveVersionInput(): string { let version = core.getInput('python-version'); - const versionFile = core.getInput('python-version-file'); + let versionFile = core.getInput('python-version-file'); if (version && versionFile) { core.warning( @@ -36,16 +36,13 @@ function resolveVersionInput(): string { return version; } - const versionFilePath = path.join( - process.env.GITHUB_WORKSPACE!, - versionFile || '.python-version' - ); - if (!fs.existsSync(versionFilePath)) { + versionFile = versionFile || '.python-version'; + if (!fs.existsSync(versionFile)) { throw new Error( - `The specified python version file at: ${versionFilePath} does not exist` + `The specified python version file at: ${versionFile} does not exist` ); } - version = fs.readFileSync(versionFilePath, 'utf8'); + version = fs.readFileSync(versionFile, 'utf8'); core.info(`Resolved ${versionFile} as ${version}`); return version;