Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c3dd9e7e2 | ||
|
|
76bbdfadd7 | ||
|
|
1aafadcfb9 | ||
|
|
b80efd6bc5 | ||
|
|
5cddb27885 | ||
|
|
47c4a7af1d | ||
|
|
af57b64994 | ||
|
|
4818a5a153 | ||
|
|
8bcd2560e2 | ||
|
|
13ae5bb136 | ||
|
|
0c4d7b878c | ||
|
|
13a464fa11 | ||
|
|
b4fe97ecda | ||
|
|
434aeabbb4 | ||
|
|
98c991d13f | ||
|
|
397a35f988 | ||
|
|
48a0f006ff | ||
|
|
978fd06d1f | ||
|
|
050e616f66 | ||
|
|
f6795b163d | ||
|
|
2e6ca74422 | ||
|
|
aa5ddbf8fe | ||
|
|
c0abeaa470 | ||
|
|
197204a31c | ||
|
|
c96b4b55f3 | ||
|
|
9aa1c6cb27 |
@@ -21,7 +21,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Update the ${{ env.TAG_NAME }} tag
|
- name: Update the ${{ env.TAG_NAME }} tag
|
||||||
uses: actions/[email protected].0
|
uses: actions/[email protected].1
|
||||||
with:
|
with:
|
||||||
source-tag: ${{ env.TAG_NAME }}
|
source-tag: ${{ env.TAG_NAME }}
|
||||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest]
|
operating-system: [ubuntu-20.04, windows-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/cache"
|
name: "@actions/cache"
|
||||||
version: 3.0.0
|
version: 3.0.4
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions cache lib
|
summary: Actions cache lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.7.0
|
version: 1.10.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions core lib
|
summary: Actions core lib
|
||||||
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
homepage: https://github.com/actions/toolkit/tree/main/packages/core
|
||||||
|
|||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: minimatch
|
name: minimatch
|
||||||
version: 3.0.4
|
version: 3.1.2
|
||||||
type: npm
|
type: npm
|
||||||
summary: a glob matcher in javascript
|
summary: a glob matcher in javascript
|
||||||
homepage: https://github.com/isaacs/minimatch#readme
|
homepage: https://github.com/isaacs/minimatch#readme
|
||||||
|
|||||||
@@ -33,11 +33,11 @@ steps:
|
|||||||
python-version: 'pypy3.9'
|
python-version: 'pypy3.9'
|
||||||
- run: python my_script.py
|
- run: python my_script.py
|
||||||
```
|
```
|
||||||
The `python-version` input is optional. If not supplied, the action will try to resolve the version from the default `.python-version` file. If the `.python-version` file doesn't exist Python or PyPy version from the PATH will be used. The default version of Python or PyPy in PATH varies between runners and can be changed unexpectedly so we recommend always using `setup-python`.
|
The `python-version` input is optional. If not supplied, the action will try to resolve the version from the default `.python-version` file. If the `.python-version` file doesn't exist Python or PyPy version from the PATH will be used. The default version of Python or PyPy in PATH varies between runners and can be changed unexpectedly so we recommend always setting Python version explicitly using the `python-version` or `python-version-file` inputs.
|
||||||
|
|
||||||
The action will first check the local [tool cache](docs/advanced-usage.md#hosted-tool-cache) for a [semver](https://github.com/npm/node-semver#versions) match. If unable to find a specific version in the tool cache, the action will attempt to download a version of Python from [GitHub Releases](https://github.com/actions/python-versions/releases) and for PyPy from the official [PyPy's dist](https://downloads.python.org/pypy/).
|
The action will first check the local [tool cache](docs/advanced-usage.md#hosted-tool-cache) for a [semver](https://github.com/npm/node-semver#versions) match. If unable to find a specific version in the tool cache, the action will attempt to download a version of Python from [GitHub Releases](https://github.com/actions/python-versions/releases) and for PyPy from the official [PyPy's dist](https://downloads.python.org/pypy/).
|
||||||
|
|
||||||
For information regarding locally cached versions of Python or PyPy on GitHub hosted runners, check out [GitHub Actions Virtual Environments](https://github.com/actions/virtual-environments).
|
For information regarding locally cached versions of Python or PyPy on GitHub hosted runners, check out [GitHub Actions Runner Images](https://github.com/actions/runner-images).
|
||||||
|
|
||||||
## Supported version syntax
|
## Supported version syntax
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||||||
let saveSatetSpy: jest.SpyInstance;
|
let saveSatetSpy: jest.SpyInstance;
|
||||||
let getStateSpy: jest.SpyInstance;
|
let getStateSpy: jest.SpyInstance;
|
||||||
let setOutputSpy: jest.SpyInstance;
|
let setOutputSpy: jest.SpyInstance;
|
||||||
let getLinuxOSReleaseInfoSpy: jest.SpyInstance;
|
|
||||||
|
|
||||||
// cache spy
|
// cache spy
|
||||||
let restoreCacheSpy: jest.SpyInstance;
|
let restoreCacheSpy: jest.SpyInstance;
|
||||||
@@ -67,6 +66,9 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||||||
if (input.includes('poetry')) {
|
if (input.includes('poetry')) {
|
||||||
return {stdout: poetryConfigOutput, stderr: '', exitCode: 0};
|
return {stdout: poetryConfigOutput, stderr: '', exitCode: 0};
|
||||||
}
|
}
|
||||||
|
if (input.includes('lsb_release')) {
|
||||||
|
return {stdout: 'Ubuntu\n20.04', stderr: '', exitCode: 0};
|
||||||
|
}
|
||||||
|
|
||||||
return {stdout: '', stderr: 'Error occured', exitCode: 2};
|
return {stdout: '', stderr: 'Error occured', exitCode: 2};
|
||||||
});
|
});
|
||||||
@@ -83,7 +85,6 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||||||
|
|
||||||
whichSpy = jest.spyOn(io, 'which');
|
whichSpy = jest.spyOn(io, 'which');
|
||||||
whichSpy.mockImplementation(() => '/path/to/python');
|
whichSpy.mockImplementation(() => '/path/to/python');
|
||||||
getLinuxOSReleaseInfoSpy = jest.spyOn(utils, 'getLinuxOSReleaseInfo');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Validate provided package manager', () => {
|
describe('Validate provided package manager', () => {
|
||||||
@@ -120,17 +121,11 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||||||
dependencyFile
|
dependencyFile
|
||||||
);
|
);
|
||||||
|
|
||||||
if (process.platform === 'linux') {
|
|
||||||
getLinuxOSReleaseInfoSpy.mockImplementation(() =>
|
|
||||||
Promise.resolve('Ubuntu-20.4')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await cacheDistributor.restoreCache();
|
await cacheDistributor.restoreCache();
|
||||||
|
|
||||||
if (process.platform === 'linux' && packageManager === 'pip') {
|
if (process.platform === 'linux' && packageManager === 'pip') {
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-Ubuntu-20.4-python-${pythonVersion}-${packageManager}-${fileHash}`
|
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-20.04-Ubuntu-python-${pythonVersion}-${packageManager}-${fileHash}`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
expect(infoSpy).toHaveBeenCalledWith(
|
expect(infoSpy).toHaveBeenCalledWith(
|
||||||
|
|||||||
+2
-2
@@ -16,8 +16,8 @@ inputs:
|
|||||||
description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
|
description: "Set this option if you want the action to check for the latest available version that satisfies the version spec."
|
||||||
default: false
|
default: false
|
||||||
token:
|
token:
|
||||||
description: "Used to pull python distributions from actions/python-versions. Since there's a default, this is typically not supplied by the user."
|
description: "The token used to authenticate when fetching Python distributions from https://github.com/actions/python-versions. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting."
|
||||||
default: ${{ github.token }}
|
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||||
cache-dependency-path:
|
cache-dependency-path:
|
||||||
description: "Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies."
|
description: "Used to specify the path to dependency files. Supports wildcards or a list of file names for caching multiple dependencies."
|
||||||
update-environment:
|
update-environment:
|
||||||
|
|||||||
Vendored
+1994
-1094
File diff suppressed because it is too large
Load Diff
Vendored
+2140
-542
File diff suppressed because it is too large
Load Diff
+45
-8
File diff suppressed because one or more lines are too long
+97
-21
File diff suppressed because one or more lines are too long
Generated
+55
-22
@@ -9,8 +9,8 @@
|
|||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.0",
|
"@actions/cache": "^3.0.4",
|
||||||
"@actions/core": "^1.7.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
@@ -31,9 +31,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache": {
|
"node_modules/@actions/cache": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
|
||||||
"integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
|
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
@@ -72,11 +72,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.7.0",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": "^1.0.11"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/core/node_modules/@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@actions/core/node_modules/uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||||
|
"bin": {
|
||||||
|
"uuid": "dist/bin/uuid"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/exec": {
|
"node_modules/@actions/exec": {
|
||||||
@@ -10160,9 +10177,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
},
|
},
|
||||||
@@ -11340,9 +11357,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": {
|
"@actions/cache": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz",
|
||||||
"integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
|
"integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
@@ -11380,11 +11397,27 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.7.0",
|
"version": "1.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz",
|
||||||
"integrity": "sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ==",
|
"integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^1.0.11"
|
"@actions/http-client": "^2.0.1",
|
||||||
|
"uuid": "^8.3.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
|
"requires": {
|
||||||
|
"tunnel": "^0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "8.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
|
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/exec": {
|
"@actions/exec": {
|
||||||
@@ -19457,9 +19490,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -23,8 +23,8 @@
|
|||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^3.0.0",
|
"@actions/cache": "^3.0.4",
|
||||||
"@actions/core": "^1.7.0",
|
"@actions/core": "^1.10.0",
|
||||||
"@actions/exec": "^1.1.0",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/glob": "^0.2.0",
|
"@actions/glob": "^0.2.0",
|
||||||
"@actions/io": "^1.0.2",
|
"@actions/io": "^1.0.2",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import * as path from 'path';
|
|||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
import CacheDistributor from './cache-distributor';
|
import CacheDistributor from './cache-distributor';
|
||||||
import {getLinuxOSReleaseInfo, IS_LINUX, IS_WINDOWS} from '../utils';
|
import {getLinuxInfo, IS_LINUX, IS_WINDOWS} from '../utils';
|
||||||
|
|
||||||
class PipCache extends CacheDistributor {
|
class PipCache extends CacheDistributor {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -61,9 +61,9 @@ class PipCache extends CacheDistributor {
|
|||||||
let restoreKey = '';
|
let restoreKey = '';
|
||||||
|
|
||||||
if (IS_LINUX) {
|
if (IS_LINUX) {
|
||||||
const osRelease = await getLinuxOSReleaseInfo();
|
const osInfo = await getLinuxInfo();
|
||||||
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osInfo.osVersion}-${osInfo.osName}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}`;
|
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osInfo.osVersion}-${osInfo.osName}-python-${this.pythonVersion}-${this.packageManager}`;
|
||||||
} else {
|
} else {
|
||||||
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`;
|
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`;
|
||||||
|
|||||||
+7
-2
@@ -1,6 +1,6 @@
|
|||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import {IS_WINDOWS, IS_LINUX} from './utils';
|
import {IS_WINDOWS, IS_LINUX, getOSInfo} from './utils';
|
||||||
|
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
|
||||||
@@ -85,9 +85,14 @@ export async function useCpythonVersion(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!installDir) {
|
if (!installDir) {
|
||||||
|
const osInfo = await getOSInfo();
|
||||||
throw new Error(
|
throw new Error(
|
||||||
[
|
[
|
||||||
`Version ${version} with arch ${architecture} not found`,
|
`The version '${version}' with architecture '${architecture}' was not found for ${
|
||||||
|
osInfo
|
||||||
|
? `${osInfo.osName} ${osInfo.osVersion}`
|
||||||
|
: 'this operating system'
|
||||||
|
}.`,
|
||||||
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
`The list of all available versions can be found here: ${installer.MANIFEST_URL}`
|
||||||
].join(os.EOL)
|
].join(os.EOL)
|
||||||
);
|
);
|
||||||
|
|||||||
+66
-38
@@ -8,7 +8,6 @@ import fs from 'fs';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
IS_WINDOWS,
|
IS_WINDOWS,
|
||||||
WINDOWS_ARCHS,
|
|
||||||
WINDOWS_PLATFORMS,
|
WINDOWS_PLATFORMS,
|
||||||
IPyPyManifestRelease,
|
IPyPyManifestRelease,
|
||||||
createSymlinkInFolder,
|
createSymlinkInFolder,
|
||||||
@@ -47,37 +46,58 @@ export async function installPyPy(
|
|||||||
let downloadUrl = `${foundAsset.download_url}`;
|
let downloadUrl = `${foundAsset.download_url}`;
|
||||||
|
|
||||||
core.info(`Downloading PyPy from "${downloadUrl}" ...`);
|
core.info(`Downloading PyPy from "${downloadUrl}" ...`);
|
||||||
const pypyPath = await tc.downloadTool(downloadUrl);
|
|
||||||
|
|
||||||
core.info('Extracting downloaded archive...');
|
try {
|
||||||
if (IS_WINDOWS) {
|
const pypyPath = await tc.downloadTool(downloadUrl);
|
||||||
downloadDir = await tc.extractZip(pypyPath);
|
|
||||||
} else {
|
core.info('Extracting downloaded archive...');
|
||||||
downloadDir = await tc.extractTar(pypyPath, undefined, 'x');
|
if (IS_WINDOWS) {
|
||||||
|
downloadDir = await tc.extractZip(pypyPath);
|
||||||
|
} else {
|
||||||
|
downloadDir = await tc.extractTar(pypyPath, undefined, 'x');
|
||||||
|
}
|
||||||
|
|
||||||
|
// root folder in archive can have unpredictable name so just take the first folder
|
||||||
|
// downloadDir is unique folder under TEMP and can't contain any other folders
|
||||||
|
const archiveName = fs.readdirSync(downloadDir)[0];
|
||||||
|
|
||||||
|
const toolDir = path.join(downloadDir, archiveName);
|
||||||
|
let installDir = toolDir;
|
||||||
|
if (!isNightlyKeyword(resolvedPyPyVersion)) {
|
||||||
|
installDir = await tc.cacheDir(
|
||||||
|
toolDir,
|
||||||
|
'PyPy',
|
||||||
|
resolvedPythonVersion,
|
||||||
|
architecture
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
|
||||||
|
|
||||||
|
const binaryPath = getPyPyBinaryPath(installDir);
|
||||||
|
await createPyPySymlink(binaryPath, resolvedPythonVersion);
|
||||||
|
await installPip(binaryPath);
|
||||||
|
|
||||||
|
return {installDir, resolvedPythonVersion, resolvedPyPyVersion};
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error) {
|
||||||
|
// Rate limit?
|
||||||
|
if (
|
||||||
|
err instanceof tc.HTTPError &&
|
||||||
|
(err.httpStatusCode === 403 || err.httpStatusCode === 429)
|
||||||
|
) {
|
||||||
|
core.info(
|
||||||
|
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.info(err.message);
|
||||||
|
}
|
||||||
|
if (err.stack !== undefined) {
|
||||||
|
core.debug(err.stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
// root folder in archive can have unpredictable name so just take the first folder
|
|
||||||
// downloadDir is unique folder under TEMP and can't contain any other folders
|
|
||||||
const archiveName = fs.readdirSync(downloadDir)[0];
|
|
||||||
|
|
||||||
const toolDir = path.join(downloadDir, archiveName);
|
|
||||||
let installDir = toolDir;
|
|
||||||
if (!isNightlyKeyword(resolvedPyPyVersion)) {
|
|
||||||
installDir = await tc.cacheDir(
|
|
||||||
toolDir,
|
|
||||||
'PyPy',
|
|
||||||
resolvedPythonVersion,
|
|
||||||
architecture
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
writeExactPyPyVersionFile(installDir, resolvedPyPyVersion);
|
|
||||||
|
|
||||||
const binaryPath = getPyPyBinaryPath(installDir);
|
|
||||||
await createPyPySymlink(binaryPath, resolvedPythonVersion);
|
|
||||||
await installPip(binaryPath);
|
|
||||||
|
|
||||||
return {installDir, resolvedPythonVersion, resolvedPyPyVersion};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAvailablePyPyVersions() {
|
export async function getAvailablePyPyVersions() {
|
||||||
@@ -157,7 +177,7 @@ export function findRelease(
|
|||||||
const isArchPresent =
|
const isArchPresent =
|
||||||
item.files &&
|
item.files &&
|
||||||
(IS_WINDOWS
|
(IS_WINDOWS
|
||||||
? isArchPresentForWindows(item)
|
? isArchPresentForWindows(item, architecture)
|
||||||
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
: isArchPresentForMacOrLinux(item, architecture, process.platform));
|
||||||
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
return isPythonVersionSatisfied && isPyPyVersionSatisfied && isArchPresent;
|
||||||
});
|
});
|
||||||
@@ -181,7 +201,7 @@ export function findRelease(
|
|||||||
|
|
||||||
const foundRelease = sortedReleases[0];
|
const foundRelease = sortedReleases[0];
|
||||||
const foundAsset = IS_WINDOWS
|
const foundAsset = IS_WINDOWS
|
||||||
? findAssetForWindows(foundRelease)
|
? findAssetForWindows(foundRelease, architecture)
|
||||||
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
: findAssetForMacOrLinux(foundRelease, architecture, process.platform);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -205,11 +225,11 @@ export function pypyVersionToSemantic(versionSpec: string) {
|
|||||||
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
return versionSpec.replace(prereleaseVersion, '$1-$2.$3');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isArchPresentForWindows(item: any) {
|
export function isArchPresentForWindows(item: any, architecture: string) {
|
||||||
|
architecture = replaceX32toX86(architecture);
|
||||||
return item.files.some(
|
return item.files.some(
|
||||||
(file: any) =>
|
(file: any) =>
|
||||||
WINDOWS_ARCHS.includes(file.arch) &&
|
WINDOWS_PLATFORMS.includes(file.platform) && file.arch === architecture
|
||||||
WINDOWS_PLATFORMS.includes(file.platform)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,11 +243,11 @@ export function isArchPresentForMacOrLinux(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findAssetForWindows(releases: any) {
|
export function findAssetForWindows(releases: any, architecture: string) {
|
||||||
|
architecture = replaceX32toX86(architecture);
|
||||||
return releases.files.find(
|
return releases.files.find(
|
||||||
(item: any) =>
|
(item: any) =>
|
||||||
WINDOWS_ARCHS.includes(item.arch) &&
|
WINDOWS_PLATFORMS.includes(item.platform) && item.arch === architecture
|
||||||
WINDOWS_PLATFORMS.includes(item.platform)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,3 +260,11 @@ export function findAssetForMacOrLinux(
|
|||||||
(item: any) => item.arch === architecture && item.platform === platform
|
(item: any) => item.arch === architecture && item.platform === platform
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceX32toX86(architecture: string): string {
|
||||||
|
// convert x32 to x86 because os.arch() returns x32 for 32-bit systems but PyPy releases json has x86 arch value.
|
||||||
|
if (architecture === 'x32') {
|
||||||
|
architecture = 'x86';
|
||||||
|
}
|
||||||
|
return architecture;
|
||||||
|
}
|
||||||
|
|||||||
+30
-12
@@ -3,10 +3,10 @@ import * as core from '@actions/core';
|
|||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import {ExecOptions} from '@actions/exec/lib/interfaces';
|
import {ExecOptions} from '@actions/exec/lib/interfaces';
|
||||||
import {IS_WINDOWS, IS_LINUX, isGhes} from './utils';
|
import {IS_WINDOWS, IS_LINUX} from './utils';
|
||||||
|
|
||||||
const TOKEN = core.getInput('token');
|
const TOKEN = core.getInput('token');
|
||||||
const AUTH = !TOKEN || isGhes() ? undefined : `token ${TOKEN}`;
|
const AUTH = !TOKEN ? undefined : `token ${TOKEN}`;
|
||||||
const MANIFEST_REPO_OWNER = 'actions';
|
const MANIFEST_REPO_OWNER = 'actions';
|
||||||
const MANIFEST_REPO_NAME = 'python-versions';
|
const MANIFEST_REPO_NAME = 'python-versions';
|
||||||
const MANIFEST_REPO_BRANCH = 'main';
|
const MANIFEST_REPO_BRANCH = 'main';
|
||||||
@@ -72,15 +72,33 @@ export async function installCpythonFromRelease(release: tc.IToolRelease) {
|
|||||||
const downloadUrl = release.files[0].download_url;
|
const downloadUrl = release.files[0].download_url;
|
||||||
|
|
||||||
core.info(`Download from "${downloadUrl}"`);
|
core.info(`Download from "${downloadUrl}"`);
|
||||||
const pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
let pythonPath = '';
|
||||||
core.info('Extract downloaded archive');
|
try {
|
||||||
let pythonExtractedFolder;
|
pythonPath = await tc.downloadTool(downloadUrl, undefined, AUTH);
|
||||||
if (IS_WINDOWS) {
|
core.info('Extract downloaded archive');
|
||||||
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
let pythonExtractedFolder;
|
||||||
} else {
|
if (IS_WINDOWS) {
|
||||||
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
pythonExtractedFolder = await tc.extractZip(pythonPath);
|
||||||
}
|
} else {
|
||||||
|
pythonExtractedFolder = await tc.extractTar(pythonPath);
|
||||||
|
}
|
||||||
|
|
||||||
core.info('Execute installation script');
|
core.info('Execute installation script');
|
||||||
await installPython(pythonExtractedFolder);
|
await installPython(pythonExtractedFolder);
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof tc.HTTPError) {
|
||||||
|
// Rate limit?
|
||||||
|
if (err.httpStatusCode === 403 || err.httpStatusCode === 429) {
|
||||||
|
core.info(
|
||||||
|
`Received HTTP status code ${err.httpStatusCode}. This usually indicates the rate limit has been exceeded`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
core.info(err.message);
|
||||||
|
}
|
||||||
|
if (err.stack) {
|
||||||
|
core.debug(err.stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+49
-11
@@ -122,23 +122,61 @@ export function isCacheFeatureAvailable(): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getLinuxOSReleaseInfo() {
|
export function logWarning(message: string): void {
|
||||||
const {stdout, stderr, exitCode} = await exec.getExecOutput(
|
const warningPrefix = '[warning]';
|
||||||
'lsb_release',
|
core.info(`${warningPrefix}${message}`);
|
||||||
['-i', '-r', '-s'],
|
}
|
||||||
|
|
||||||
|
async function getWindowsInfo() {
|
||||||
|
const {stdout} = await exec.getExecOutput(
|
||||||
|
'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"',
|
||||||
|
undefined,
|
||||||
{
|
{
|
||||||
silent: true
|
silent: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const [osRelease, osVersion] = stdout.trim().split('\n');
|
const windowsVersion = stdout.trim().split(' ')[3];
|
||||||
|
|
||||||
core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`);
|
return {osName: 'Windows', osVersion: windowsVersion};
|
||||||
|
|
||||||
return `${osVersion}-${osRelease}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logWarning(message: string): void {
|
async function getMacOSInfo() {
|
||||||
const warningPrefix = '[warning]';
|
const {stdout} = await exec.getExecOutput('sw_vers', ['-productVersion'], {
|
||||||
core.info(`${warningPrefix}${message}`);
|
silent: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const macOSVersion = stdout.trim();
|
||||||
|
|
||||||
|
return {osName: 'macOS', osVersion: macOSVersion};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getLinuxInfo() {
|
||||||
|
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: osName, osVersion: osVersion};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getOSInfo() {
|
||||||
|
let osInfo;
|
||||||
|
try {
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
osInfo = await getWindowsInfo();
|
||||||
|
} else if (IS_LINUX) {
|
||||||
|
osInfo = await getLinuxInfo();
|
||||||
|
} else if (IS_MAC) {
|
||||||
|
osInfo = await getMacOSInfo();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
const error = err as Error;
|
||||||
|
core.debug(error.message);
|
||||||
|
} finally {
|
||||||
|
return osInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user