mirror of
https://github.com/actions/setup-python.git
synced 2026-06-24 21:38:25 +01:00
Compare commits
9 Commits
dependabot
...
v6.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ece7cb06ca | ||
|
|
1d18d7af5f | ||
|
|
d2b357a6a3 | ||
|
|
8f639b1e75 | ||
|
|
6731c2ba87 | ||
|
|
0cb1a84326 | ||
|
|
dc6eab6194 | ||
|
|
6f4b74bfa2 | ||
|
|
fa8bde1a9c |
7
.github/workflows/e2e-cache.yml
vendored
7
.github/workflows/e2e-cache.yml
vendored
@@ -145,7 +145,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Install poetry
|
||||
run: pipx install poetry
|
||||
run: |
|
||||
pipx install poetry
|
||||
- name: Init pyproject.toml
|
||||
run: mv ./__tests__/data/pyproject.toml .
|
||||
- name: Setup Python
|
||||
@@ -153,6 +154,10 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
cache: 'poetry'
|
||||
- name: Bootstrap packaging
|
||||
run: |
|
||||
python -m ensurepip --upgrade
|
||||
python -m pip install --upgrade pip setuptools wheel packaging
|
||||
- name: Install dependencies
|
||||
run: poetry install --no-root
|
||||
|
||||
|
||||
4
.github/workflows/test-pypy.yml
vendored
4
.github/workflows/test-pypy.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
||||
- 'pypy-3.10-v7.3.x'
|
||||
- 'pypy-3.10-v7.x'
|
||||
- 'pypy-2.7-v7.3.12rc1'
|
||||
- 'pypy-3.10-nightly'
|
||||
- 'pypy-3.11-nightly'
|
||||
- 'pypy3.10-v7.3.17'
|
||||
- 'pypy3.11-v7.3.19'
|
||||
|
||||
@@ -146,7 +146,7 @@ jobs:
|
||||
ubuntu-latest,
|
||||
macos-15-intel
|
||||
]
|
||||
pypy: ['pypy2.7', 'pypy3.9', 'pypy3.10-nightly', 'pypy3.11']
|
||||
pypy: ['pypy2.7', 'pypy3.9', 'pypy3.11-nightly', 'pypy3.11']
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
2
.licenses/npm/@actions/cache.dep.yml
generated
2
.licenses/npm/@actions/cache.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: "@actions/cache"
|
||||
version: 5.0.5
|
||||
version: 5.1.0
|
||||
type: npm
|
||||
summary: Actions cache lib
|
||||
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
||||
|
||||
11
.licenses/npm/@nodable/entities.dep.yml
generated
Normal file
11
.licenses/npm/@nodable/entities.dep.yml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
name: "@nodable/entities"
|
||||
version: 2.2.0
|
||||
type: npm
|
||||
summary: Entity parser for XML, HTML, External entites with security and NCR control
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
35
.licenses/npm/anynum.dep.yml
generated
Normal file
35
.licenses/npm/anynum.dep.yml
generated
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
name: anynum
|
||||
version: 1.0.1
|
||||
type: npm
|
||||
summary: Normalize all Unicode decimal digits (Devanagari, Arabic, Thai, etc.) to
|
||||
ASCII numerals. Zero dependencies, performance-first.
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Natural Intelligence
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
2
.licenses/npm/fast-xml-builder.dep.yml
generated
2
.licenses/npm/fast-xml-builder.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: fast-xml-builder
|
||||
version: 1.1.4
|
||||
version: 1.2.0
|
||||
type: npm
|
||||
summary: Build XML from JSON without C/C++ based libraries
|
||||
homepage:
|
||||
|
||||
2
.licenses/npm/fast-xml-parser.dep.yml
generated
2
.licenses/npm/fast-xml-parser.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: fast-xml-parser
|
||||
version: 5.5.10
|
||||
version: 5.9.2
|
||||
type: npm
|
||||
summary: Validate XML, Parse XML, Build XML without C/C++ based libraries
|
||||
homepage:
|
||||
|
||||
35
.licenses/npm/is-unsafe.dep.yml
generated
Normal file
35
.licenses/npm/is-unsafe.dep.yml
generated
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
name: is-unsafe
|
||||
version: 1.0.1
|
||||
type: npm
|
||||
summary: Zero-dependency, DOM-free, pure predicate for detecting unsafe strings across
|
||||
HTML, XML, SVG, SQL, SHELL, and REGEX contexts
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: LICENSE
|
||||
text: |
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Natural Intelligence
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
2
.licenses/npm/path-expression-matcher.dep.yml
generated
2
.licenses/npm/path-expression-matcher.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: path-expression-matcher
|
||||
version: 1.4.0
|
||||
version: 1.5.0
|
||||
type: npm
|
||||
summary: Efficient path tracking and pattern matching for XML/JSON parsers
|
||||
homepage: https://github.com/NaturalIntelligence/path-expression-matcher#readme
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: semver
|
||||
version: 7.7.3
|
||||
version: 7.8.5
|
||||
type: npm
|
||||
summary: The semantic version parser used by npm.
|
||||
homepage:
|
||||
2
.licenses/npm/strnum.dep.yml
generated
2
.licenses/npm/strnum.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: strnum
|
||||
version: 2.2.3
|
||||
version: 2.4.1
|
||||
type: npm
|
||||
summary: Parse String to Number based on configuration
|
||||
homepage:
|
||||
|
||||
2
.licenses/npm/undici.dep.yml
generated
2
.licenses/npm/undici.dep.yml
generated
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: undici
|
||||
version: 6.24.1
|
||||
version: 6.27.0
|
||||
type: npm
|
||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||
homepage: https://undici.nodejs.org
|
||||
|
||||
12
.licenses/npm/xml-naming.dep.yml
generated
Normal file
12
.licenses/npm/xml-naming.dep.yml
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
name: xml-naming
|
||||
version: 0.1.0
|
||||
type: npm
|
||||
summary: Validates XML name productions — Name, NCName, QName, NMToken, NMTokens —
|
||||
for XML 1.0 and 1.1
|
||||
homepage:
|
||||
license: mit
|
||||
licenses:
|
||||
- sources: README.md
|
||||
text: MIT
|
||||
notices: []
|
||||
@@ -190,19 +190,12 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
||||
|
||||
restoredKeys.forEach(restoredKey => {
|
||||
if (restoredKey) {
|
||||
if (process.platform === 'linux' && packageManager === 'pip') {
|
||||
const osSegment =
|
||||
process.platform === 'linux' ? '-20.04-Ubuntu' : '';
|
||||
const versionSuffix = packageManager === 'poetry' ? '-v2' : '';
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-${process.arch}-20.04-Ubuntu-python-${pythonVersion}-${packageManager}-${fileHash}`
|
||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-${process.arch}${osSegment}-python-${pythonVersion}-${packageManager}${versionSuffix}-${fileHash}`
|
||||
);
|
||||
} else if (packageManager === 'poetry') {
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-${process.arch}-python-${pythonVersion}-${packageManager}-v2-${fileHash}`
|
||||
);
|
||||
} else {
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-${process.arch}-python-${pythonVersion}-${packageManager}-${fileHash}`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`${packageManager} cache is not found`
|
||||
|
||||
@@ -9,6 +9,7 @@ python = ">=3.9,<3.14"
|
||||
flake8 = "^4.0.1"
|
||||
pyinstaller = "6.10.0"
|
||||
setuptools = ">=78.1.1"
|
||||
packaging = ">=22.0,<26"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
certifi==2020.6.20
|
||||
chardet==3.0.4
|
||||
docutils==0.16
|
||||
idna==3.7
|
||||
idna==3.15
|
||||
Kivy==2.0.0rc3
|
||||
Kivy-Garden==0.1.4
|
||||
packaging==20.7
|
||||
pdf2image==1.12.1
|
||||
Pygments==2.6.1
|
||||
requests==2.32.4
|
||||
urllib3==2.6.3
|
||||
Pygments==2.20.0
|
||||
requests==2.33.0
|
||||
urllib3==2.7.0
|
||||
xlrd==1.2.0
|
||||
@@ -8,7 +8,7 @@ docutils==0.16
|
||||
|
||||
future==0.18.2; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'
|
||||
|
||||
idna==3.7
|
||||
idna==3.15
|
||||
|
||||
itsdangerous==1.1.0
|
||||
|
||||
@@ -32,7 +32,7 @@ pefile==2021.9.3; python_full_version >= '3.6.0'
|
||||
|
||||
pillow>=10.2.0
|
||||
|
||||
pygments==2.6.1
|
||||
pygments==2.20.0
|
||||
|
||||
pyinstaller==6.10.0
|
||||
|
||||
@@ -40,8 +40,8 @@ pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3
|
||||
|
||||
pywin32-ctypes==0.2.0
|
||||
|
||||
requests==2.32.4
|
||||
requests==2.33.0
|
||||
|
||||
urllib3==2.6.3
|
||||
urllib3==2.7.0
|
||||
|
||||
xlrd==1.2.0
|
||||
5869
dist/cache-save/index.js
vendored
5869
dist/cache-save/index.js
vendored
File diff suppressed because one or more lines are too long
693
dist/setup/index.js
vendored
693
dist/setup/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -555,8 +555,8 @@ GitHub hosted runners have a tool cache that comes with a few versions of Python
|
||||
|**PyPy tool cache**|`RUNNER_TOOL_CACHE/PyPy/*`|
|
||||
|
||||
GitHub runner images are set up in [actions/runner-images](https://github.com/actions/runner-images). During the setup, the available versions of Python and PyPy are automatically downloaded, set up and documented.
|
||||
- Tool cache setup for Ubuntu: [Install-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/linux/scripts/installers/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/linux/scripts/installers/Configure-Toolset.ps1)
|
||||
- Tool cache setup for Windows: [Install-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/win/scripts/Installers/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/win/scripts/Installers/Configure-Toolset.ps1)
|
||||
- Tool cache setup for Ubuntu: [Install-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/ubuntu/scripts/build/Configure-Toolset.ps1)
|
||||
- Tool cache setup for Windows: [Install-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Install-Toolset.ps1) [Configure-Toolset.ps1](https://github.com/actions/runner-images/blob/main/images/windows/scripts/build/Configure-Toolset.ps1)
|
||||
|
||||
|
||||
## Using `setup-python` with a self-hosted runner
|
||||
|
||||
5882
package-lock.json
generated
5882
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setup-python",
|
||||
"version": "6.2.0",
|
||||
"version": "6.3.0",
|
||||
"private": true,
|
||||
"description": "Setup python action",
|
||||
"main": "dist/index.js",
|
||||
@@ -28,7 +28,7 @@
|
||||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^5.0.5",
|
||||
"@actions/cache": "^5.1.0",
|
||||
"@actions/core": "^2.0.3",
|
||||
"@actions/exec": "^2.0.0",
|
||||
"@actions/glob": "^0.5.1",
|
||||
@@ -39,7 +39,7 @@
|
||||
"semver": "^7.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^24.10.1",
|
||||
"@types/semver": "^7.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.54.0",
|
||||
@@ -49,10 +49,13 @@
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-plugin-jest": "^27.9.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"jest": "^30.4.2",
|
||||
"jest": "^29.7.0",
|
||||
"jest-circus": "^29.7.0",
|
||||
"prettier": "^3.6.2",
|
||||
"ts-jest": "^29.3.2",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"overrides": {
|
||||
"fast-xml-parser": "^5.9.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import {getOSInfo, IS_LINUX} from '../utils';
|
||||
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
|
||||
|
||||
export enum State {
|
||||
@@ -22,6 +23,33 @@ abstract class CacheDistributor {
|
||||
}>;
|
||||
protected async handleLoadedCache() {}
|
||||
|
||||
/**
|
||||
* Builds the Linux distro portion of a cache key (e.g. `-26.04-Ubuntu`, `-9-rhel`).
|
||||
* RHEL is keyed by major version since it ships one ABI-stable artifact per major.
|
||||
*/
|
||||
protected async getLinuxInfoKeySegment(): Promise<string> {
|
||||
if (!IS_LINUX) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const osInfo = await getOSInfo();
|
||||
if (!osInfo) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// lsb_release reports RHEL as "RedHatEnterpriseLinux" while /etc/os-release
|
||||
// reports it as "rhel"; normalize both to "rhel" so the key is consistent.
|
||||
const normalizedName = osInfo.osName.toLowerCase();
|
||||
const isRhel =
|
||||
normalizedName === 'rhel' || normalizedName.includes('redhat');
|
||||
const osName = isRhel ? 'rhel' : osInfo.osName;
|
||||
const osVersion = isRhel
|
||||
? osInfo.osVersion.split('.')[0]
|
||||
: osInfo.osVersion;
|
||||
|
||||
return `-${osVersion}-${osName}`;
|
||||
}
|
||||
|
||||
public async restoreCache() {
|
||||
const {primaryKey, restoreKey} = await this.computeKeys();
|
||||
if (primaryKey.endsWith('-')) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as path from 'path';
|
||||
import os from 'os';
|
||||
|
||||
import CacheDistributor from './cache-distributor';
|
||||
import {getLinuxInfo, IS_LINUX, IS_WINDOWS} from '../utils';
|
||||
import {IS_WINDOWS} from '../utils';
|
||||
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
|
||||
|
||||
class PipCache extends CacheDistributor {
|
||||
@@ -21,24 +21,28 @@ class PipCache extends CacheDistributor {
|
||||
}
|
||||
|
||||
protected async getCacheGlobalDirectories() {
|
||||
let exitCode = 1;
|
||||
let exitCode = 0;
|
||||
let stdout = '';
|
||||
let stderr = '';
|
||||
|
||||
// Add temporary fix for Windows
|
||||
// On windows it is necessary to execute through an exec
|
||||
// because the getExecOutput gives a non zero code or writes to stderr for pip 22.0.2,
|
||||
// On Windows, it is necessary to execute through an exec
|
||||
// because the getExecOutput gives a non-zero code or writes to stderr for pip 22.0.2,
|
||||
// or spawn must be started with the shell option enabled for getExecOutput
|
||||
// Related issue: https://github.com/actions/setup-python/issues/328
|
||||
if (IS_WINDOWS) {
|
||||
const execPromisify = utils.promisify(child_process.exec);
|
||||
({stdout: stdout, stderr: stderr} = await execPromisify('pip cache dir'));
|
||||
try {
|
||||
({stdout, stderr} = await execPromisify('pip cache dir'));
|
||||
} catch (err) {
|
||||
// Pip outputs warnings to stderr (e.g., --no-python-version-warning flag deprecation warning), causing false failure detection
|
||||
// Related issue: https://github.com/actions/setup-python/issues/1034
|
||||
// If an error occurs, capture stderr and set exitCode to 1 to indicate failure
|
||||
stderr = (err as any).stderr ?? (err as Error).message;
|
||||
exitCode = 1;
|
||||
}
|
||||
} else {
|
||||
({
|
||||
stdout: stdout,
|
||||
stderr: stderr,
|
||||
exitCode: exitCode
|
||||
} = await exec.getExecOutput('pip cache dir'));
|
||||
({stdout, stderr, exitCode} = await exec.getExecOutput('pip cache dir'));
|
||||
}
|
||||
|
||||
if (exitCode && stderr) {
|
||||
@@ -62,17 +66,9 @@ class PipCache extends CacheDistributor {
|
||||
const hash =
|
||||
(await glob.hashFiles(this.cacheDependencyPath)) ||
|
||||
(await glob.hashFiles(this.cacheDependencyBackupPath));
|
||||
let primaryKey = '';
|
||||
let restoreKey = '';
|
||||
|
||||
if (IS_LINUX) {
|
||||
const osInfo = await getLinuxInfo();
|
||||
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${osInfo.osVersion}-${osInfo.osName}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${osInfo.osVersion}-${osInfo.osName}-python-${this.pythonVersion}-${this.packageManager}`;
|
||||
} else {
|
||||
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}`;
|
||||
}
|
||||
const osSegment = await this.getLinuxInfoKeySegment();
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}${osSegment}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
const restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}${osSegment}-python-${this.pythonVersion}-${this.packageManager}`;
|
||||
|
||||
return {
|
||||
primaryKey,
|
||||
|
||||
@@ -32,7 +32,8 @@ class PipenvCache extends CacheDistributor {
|
||||
|
||||
protected async computeKeys() {
|
||||
const hash = await glob.hashFiles(this.patterns);
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
const osSegment = await this.getLinuxInfoKeySegment();
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}${osSegment}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||
const restoreKey = undefined;
|
||||
return {
|
||||
primaryKey,
|
||||
|
||||
@@ -46,8 +46,9 @@ class PoetryCache extends CacheDistributor {
|
||||
|
||||
protected async computeKeys() {
|
||||
const hash = await glob.hashFiles(this.patterns);
|
||||
const osSegment = await this.getLinuxInfoKeySegment();
|
||||
// "v2" is here to invalidate old caches of this cache distributor, which were created broken:
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-python-${this.pythonVersion}-${this.packageManager}-v2-${hash}`;
|
||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}${osSegment}-python-${this.pythonVersion}-${this.packageManager}-v2-${hash}`;
|
||||
const restoreKey = undefined;
|
||||
return {
|
||||
primaryKey,
|
||||
|
||||
@@ -70,7 +70,11 @@ async function saveCache(packageManager: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cacheId == -1) {
|
||||
if (cacheId === -1) {
|
||||
// saveCache returns -1 without throwing when the cache was not saved, e.g.
|
||||
// a reserve collision or a read-only token (fork PR). @actions/cache has
|
||||
// already logged the reason at the appropriate severity, so just trace it.
|
||||
core.debug(`Cache was not saved for the key: ${primaryKey}`);
|
||||
return;
|
||||
}
|
||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||
|
||||
@@ -3,6 +3,8 @@ import * as core from '@actions/core';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as httpm from '@actions/http-client';
|
||||
import * as fs from 'fs';
|
||||
import * as semver from 'semver';
|
||||
import {ExecOptions} from '@actions/exec/lib/interfaces';
|
||||
import {IS_WINDOWS, IS_LINUX, getDownloadFileName} from './utils';
|
||||
import {IToolRelease} from '@actions/tool-cache';
|
||||
@@ -14,6 +16,70 @@ const MANIFEST_REPO_NAME = 'python-versions';
|
||||
const MANIFEST_REPO_BRANCH = 'main';
|
||||
export const MANIFEST_URL = `https://raw.githubusercontent.com/${MANIFEST_REPO_OWNER}/${MANIFEST_REPO_NAME}/${MANIFEST_REPO_BRANCH}/versions-manifest.json`;
|
||||
|
||||
interface LinuxOsRelease {
|
||||
id: string;
|
||||
versionId: string;
|
||||
}
|
||||
|
||||
function getLinuxOsRelease(): LinuxOsRelease | null {
|
||||
try {
|
||||
const content = fs.readFileSync('/etc/os-release', 'utf8');
|
||||
const lines = content.split('\n');
|
||||
let id = '';
|
||||
let versionId = '';
|
||||
for (const line of lines) {
|
||||
const parts = line.split('=');
|
||||
if (parts.length === 2) {
|
||||
const key = parts[0].trim();
|
||||
const value = parts[1].trim().replace(/^"/, '').replace(/"$/, '');
|
||||
if (key === 'ID') id = value;
|
||||
if (key === 'VERSION_ID') versionId = value;
|
||||
}
|
||||
}
|
||||
if (id && versionId) {
|
||||
return {id, versionId};
|
||||
}
|
||||
return null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function findRhelRelease(
|
||||
semanticVersionSpec: string,
|
||||
architecture: string,
|
||||
manifest: tc.IToolRelease[],
|
||||
osVersion: string
|
||||
): tc.IToolRelease | undefined {
|
||||
for (const candidate of manifest) {
|
||||
const version = candidate.version;
|
||||
core.debug(`check ${version} satisfies ${semanticVersionSpec}`);
|
||||
|
||||
if (!semver.satisfies(version, semanticVersionSpec)) continue;
|
||||
|
||||
const file = candidate.files.find(item => {
|
||||
core.debug(
|
||||
`${item.arch}===${architecture} && ${item.platform}===rhel && ${item.platform_version}===${osVersion}`
|
||||
);
|
||||
const archMatch = item.arch === architecture;
|
||||
const platformMatch = item.platform === 'rhel';
|
||||
const versionMatch =
|
||||
!item.platform_version ||
|
||||
item.platform_version === osVersion ||
|
||||
osVersion.startsWith(item.platform_version);
|
||||
return archMatch && platformMatch && versionMatch;
|
||||
});
|
||||
|
||||
if (file) {
|
||||
core.debug(`matched ${candidate.version}`);
|
||||
const result = Object.assign({}, candidate);
|
||||
result.files = [file];
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export async function findReleaseFromManifest(
|
||||
semanticVersionSpec: string,
|
||||
architecture: string,
|
||||
@@ -23,6 +89,23 @@ export async function findReleaseFromManifest(
|
||||
manifest = await getManifest();
|
||||
}
|
||||
|
||||
// On RHEL, tc.findFromManifest() won't match because os.platform() returns 'linux'
|
||||
// but manifest entries use platform 'rhel'. Use custom filtering for RHEL.
|
||||
if (IS_LINUX) {
|
||||
const osRelease = getLinuxOsRelease();
|
||||
if (osRelease && osRelease.id === 'rhel') {
|
||||
core.debug(
|
||||
`Detected RHEL ${osRelease.versionId}, using custom manifest filtering`
|
||||
);
|
||||
return findRhelRelease(
|
||||
semanticVersionSpec,
|
||||
architecture,
|
||||
manifest,
|
||||
osRelease.versionId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const foundRelease = await tc.findFromManifest(
|
||||
semanticVersionSpec,
|
||||
false,
|
||||
@@ -32,6 +115,7 @@ export async function findReleaseFromManifest(
|
||||
|
||||
return foundRelease;
|
||||
}
|
||||
|
||||
function isIToolRelease(obj: any): obj is IToolRelease {
|
||||
return (
|
||||
typeof obj === 'object' &&
|
||||
@@ -48,6 +132,7 @@ function isIToolRelease(obj: any): obj is IToolRelease {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export async function getManifest(): Promise<tc.IToolRelease[]> {
|
||||
try {
|
||||
const repoManifest = await getManifestFromRepo();
|
||||
|
||||
31
src/utils.ts
31
src/utils.ts
@@ -173,15 +173,38 @@ async function getMacOSInfo() {
|
||||
}
|
||||
|
||||
export async function getLinuxInfo() {
|
||||
const {stdout} = await exec.getExecOutput('lsb_release', ['-i', '-r', '-s'], {
|
||||
try {
|
||||
const {stdout} = await exec.getExecOutput(
|
||||
'lsb_release',
|
||||
['-i', '-r', '-s'],
|
||||
{
|
||||
silent: true
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
const [osName, osVersion] = stdout.trim().split('\n');
|
||||
|
||||
core.debug(`OS Name: ${osName}, Version: ${osVersion}`);
|
||||
return {osName, osVersion};
|
||||
} catch (err) {
|
||||
core.debug(
|
||||
`lsb_release failed (${(err as Error).message}). Falling back to /etc/os-release.`
|
||||
);
|
||||
|
||||
return {osName: osName, osVersion: osVersion};
|
||||
const osReleaseContent = fs.readFileSync('/etc/os-release', 'utf8');
|
||||
const osInfo: {[key: string]: string} = {};
|
||||
|
||||
osReleaseContent.split('\n').forEach(line => {
|
||||
const [key, value] = line.split('=');
|
||||
if (key && value) {
|
||||
osInfo[key.trim()] = value.trim().replace(/"/g, '');
|
||||
}
|
||||
});
|
||||
|
||||
const osName = osInfo['ID'] || 'Linux';
|
||||
const osVersion = osInfo['VERSION_ID'] || '';
|
||||
core.debug(`OS Name: ${osName}, Version: ${osVersion}`);
|
||||
return {osName, osVersion};
|
||||
}
|
||||
}
|
||||
|
||||
export async function getOSInfo() {
|
||||
|
||||
Reference in New Issue
Block a user