Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Output python-versions, containing all Python versions, for cache-busting #611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Output python-versions for cache-busting
Closes #606
  • Loading branch information
kurtmckee committed Oct 10, 2023
commit 2d235cd86880843a58490816bcb6e9ab5776a802
2 changes: 2 additions & 0 deletions 2 action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions 5 dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70208,18 +70208,21 @@ 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');
for (const version of versions) {
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 {
Expand All @@ -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()) {
Expand Down
7 changes: 7 additions & 0 deletions 7 src/setup-python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -108,6 +109,9 @@ async function run() {
allowPreReleases
);
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
pythonVersions.push(
`${installed.resolvedPythonVersion}-pypy${installed.resolvedPyPyVersion}`
);
Comment on lines +112 to +114
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to change pypy and python version parts order ?

Copy link
Contributor Author

@kurtmckee kurtmckee Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with either order.

I did it this way for potential parsing purposes later in the workflow. It seemed like if someone wanted to determine all of the Python versions (regardless of CPython vs PyPy implementation), it would be easier if the Python version appeared at the beginning of the string. If -pypy appeared later in the string it could be stripped off or extracted out as needed.

However, I don't view the ordering as a critical need, and can change the order if desired.

core.info(
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
);
Expand All @@ -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')) {
Expand All @@ -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(','));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to sort versions ?

Copy link
Contributor Author

@kurtmckee kurtmckee Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sorted it to help stabilize the cache key. If one developer writes their workflow YAML file as:

- uses: actions/setup-python@v4
  with:
    python-version: |
      3.11
      3.10
      3.9
      3.8
      3.7

and the versions are later rearranged to:

- uses: actions/setup-python@v4
  with:
    python-version: |
      3.7
      3.8
      3.9
      3.10
      3.11

sorting the versions will provide stability to the cache key.

I currently think this is beneficial behavior, but can remove the sorting if desired.

core.endGroup();
const cache = core.getInput('cache');
if (cache && isCacheFeatureAvailable()) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.