From 2d235cd86880843a58490816bcb6e9ab5776a802 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Thu, 9 Feb 2023 21:41:05 -0600 Subject: [PATCH] Output `python-versions` for cache-busting Closes #606 --- action.yml | 2 ++ dist/setup/index.js | 5 +++++ src/setup-python.ts | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/action.yml b/action.yml index 3a6531c8..8b332665 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,8 @@ inputs: outputs: python-version: description: "The installed Python or PyPy version. Useful when given a version range as input." + python-versions: + description: "A comma-separated list of all installed Python implementations and versions. Useful for cache-busting." cache-hit: description: "A boolean value to indicate a cache entry was found" python-path: diff --git a/dist/setup/index.js b/dist/setup/index.js index 4f9ca50c..ef6ff23f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -70208,6 +70208,7 @@ function run() { const allowPreReleases = core.getBooleanInput('allow-prereleases'); if (versions.length) { let pythonVersion = ''; + const pythonVersions = []; const arch = core.getInput('architecture') || os.arch(); const updateEnvironment = core.getBooleanInput('update-environment'); core.startGroup('Installed versions'); @@ -70215,11 +70216,13 @@ function run() { if (isPyPyVersion(version)) { const installed = yield finderPyPy.findPyPyVersion(version, arch, updateEnvironment, checkLatest, allowPreReleases); pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`; + pythonVersions.push(`${installed.resolvedPythonVersion}-pypy${installed.resolvedPyPyVersion}`); core.info(`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`); } else if (isGraalPyVersion(version)) { const installed = yield finderGraalPy.findGraalPyVersion(version, arch, updateEnvironment, checkLatest, allowPreReleases); pythonVersion = `${installed}`; + pythonVersions.push(`graalpy${installed}`); core.info(`Successfully set up GraalPy ${installed}`); } else { @@ -70228,9 +70231,11 @@ function run() { } const installed = yield finder.useCpythonVersion(version, arch, updateEnvironment, checkLatest, allowPreReleases); pythonVersion = installed.version; + pythonVersions.push(installed.version); core.info(`Successfully set up ${installed.impl} (${pythonVersion})`); } } + core.setOutput('python-versions', pythonVersions.sort().join(',')); core.endGroup(); const cache = core.getInput('cache'); if (cache && utils_1.isCacheFeatureAvailable()) { diff --git a/src/setup-python.ts b/src/setup-python.ts index 05db90cb..7a99ddd5 100644 --- a/src/setup-python.ts +++ b/src/setup-python.ts @@ -95,6 +95,7 @@ async function run() { if (versions.length) { let pythonVersion = ''; + const pythonVersions: string[] = []; const arch: string = core.getInput('architecture') || os.arch(); const updateEnvironment = core.getBooleanInput('update-environment'); core.startGroup('Installed versions'); @@ -108,6 +109,9 @@ async function run() { allowPreReleases ); pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`; + pythonVersions.push( + `${installed.resolvedPythonVersion}-pypy${installed.resolvedPyPyVersion}` + ); core.info( `Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})` ); @@ -120,6 +124,7 @@ async function run() { allowPreReleases ); pythonVersion = `${installed}`; + pythonVersions.push(`graalpy${installed}`); core.info(`Successfully set up GraalPy ${installed}`); } else { if (version.startsWith('2')) { @@ -135,9 +140,11 @@ async function run() { allowPreReleases ); pythonVersion = installed.version; + pythonVersions.push(installed.version); core.info(`Successfully set up ${installed.impl} (${pythonVersion})`); } } + core.setOutput('python-versions', pythonVersions.sort().join(',')); core.endGroup(); const cache = core.getInput('cache'); if (cache && isCacheFeatureAvailable()) {