Merge branch 'main' into v-dmshib/fix-poetry-version
This commit is contained in:
commit
1bf6441475
23 changed files with 3174 additions and 833 deletions
28
.github/workflows/e2e-cache.yml
vendored
28
.github/workflows/e2e-cache.yml
vendored
|
@ -39,7 +39,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
python-version: ['3.9', 'pypy-3.7-v7.x']
|
python-version: ['3.9', 'pypy-3.9-v7.x']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
|
@ -48,11 +48,17 @@ jobs:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
cache: 'pipenv'
|
cache: 'pipenv'
|
||||||
- name: Install pipenv
|
- name: Install pipenv
|
||||||
run: pipx install pipenv
|
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
cd __tests__/data
|
mv ./__tests__/data/Pipfile.lock .
|
||||||
pipenv install --verbose
|
mv ./__tests__/data/Pipfile .
|
||||||
|
if ("${{ matrix.python-version }}" -Match "pypy") {
|
||||||
|
pipenv install --keep-outdated --python pypy
|
||||||
|
} else {
|
||||||
|
pipenv install --keep-outdated --python ${{ matrix.python-version }}
|
||||||
|
}
|
||||||
|
|
||||||
python-poetry-dependencies-caching:
|
python-poetry-dependencies-caching:
|
||||||
name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }})
|
name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }})
|
||||||
|
@ -102,7 +108,7 @@ jobs:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
python-version: ['3.9', 'pypy-3.7-v7.x']
|
python-version: ['3.9', 'pypy-3.9-v7.x']
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
|
@ -112,8 +118,14 @@ jobs:
|
||||||
cache: 'pipenv'
|
cache: 'pipenv'
|
||||||
cache-dependency-path: '**/pipenv-requirements.txt'
|
cache-dependency-path: '**/pipenv-requirements.txt'
|
||||||
- name: Install pipenv
|
- name: Install pipenv
|
||||||
run: pipx install pipenv
|
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
shell: pwsh
|
||||||
run: |
|
run: |
|
||||||
cd __tests__/data
|
mv ./__tests__/data/Pipfile.lock .
|
||||||
pipenv install --verbose
|
mv ./__tests__/data/Pipfile .
|
||||||
|
if ("${{ matrix.python-version }}" -Match "pypy") {
|
||||||
|
pipenv install --keep-outdated --python pypy
|
||||||
|
} else {
|
||||||
|
pipenv install --keep-outdated --python ${{ matrix.python-version }}
|
||||||
|
}
|
26
.github/workflows/test-pypy.yml
vendored
26
.github/workflows/test-pypy.yml
vendored
|
@ -65,3 +65,29 @@ jobs:
|
||||||
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
|
EXECUTABLE=${EXECUTABLE%%-*} # remove any -* suffixe
|
||||||
${EXECUTABLE} --version
|
${EXECUTABLE} --version
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
setup-pypy-noenv:
|
||||||
|
name: Setup PyPy ${{ matrix.pypy }} ${{ matrix.os }} (noenv)
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-latest]
|
||||||
|
pypy: ['pypy2.7', 'pypy3.7', 'pypy3.8', 'pypy3.9-nightly']
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: setup-python ${{ matrix.pypy }}
|
||||||
|
id: setup-python
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.pypy }}
|
||||||
|
update-environment: false
|
||||||
|
|
||||||
|
- name: PyPy and Python version
|
||||||
|
run: ${{ steps.setup-python.outputs.python-path }} --version
|
||||||
|
|
||||||
|
- name: Run simple code
|
||||||
|
run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))'
|
||||||
|
|
25
.github/workflows/test-python.yml
vendored
25
.github/workflows/test-python.yml
vendored
|
@ -147,3 +147,28 @@ jobs:
|
||||||
|
|
||||||
- name: Run simple code
|
- name: Run simple code
|
||||||
run: python -c 'import math; print(math.factorial(5))'
|
run: python -c 'import math; print(math.factorial(5))'
|
||||||
|
|
||||||
|
setup-versions-noenv:
|
||||||
|
name: Setup ${{ matrix.python }} ${{ matrix.os }} (noenv)
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, windows-latest, ubuntu-18.04, ubuntu-20.04]
|
||||||
|
python: ["3.7", "3.8", "3.9", "3.10"]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: setup-python ${{ matrix.python }}
|
||||||
|
id: setup-python
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python }}
|
||||||
|
update-environment: false
|
||||||
|
|
||||||
|
- name: Python version
|
||||||
|
run: ${{ steps.setup-python.outputs.python-path }} --version
|
||||||
|
|
||||||
|
- name: Run simple code
|
||||||
|
run: ${{ steps.setup-python.outputs.python-path }} -c 'import math; print(math.factorial(5))'
|
||||||
|
|
2
.licenses/npm/@actions/cache.dep.yml
generated
2
.licenses/npm/@actions/cache.dep.yml
generated
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
name: "@actions/cache"
|
name: "@actions/cache"
|
||||||
version: 2.0.2
|
version: 3.0.0
|
||||||
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
|
||||||
|
|
2
.licenses/npm/@actions/core.dep.yml
generated
2
.licenses/npm/@actions/core.dep.yml
generated
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
name: "@actions/core"
|
name: "@actions/core"
|
||||||
version: 1.2.6
|
version: 1.7.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
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
name: "@actions/http-client"
|
name: "@actions/http-client"
|
||||||
version: 1.0.8
|
version: 2.0.1
|
||||||
type: npm
|
type: npm
|
||||||
summary: Actions Http Client
|
summary: Actions Http Client
|
||||||
homepage: https://github.com/actions/http-client#readme
|
homepage: https://github.com/actions/http-client#readme
|
32
.licenses/npm/@actions/http-client.dep.yml
generated
Normal file
32
.licenses/npm/@actions/http-client.dep.yml
generated
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
name: "@actions/http-client"
|
||||||
|
version: 1.0.11
|
||||||
|
type: npm
|
||||||
|
summary: Actions Http Client
|
||||||
|
homepage: https://github.com/actions/http-client#readme
|
||||||
|
license: mit
|
||||||
|
licenses:
|
||||||
|
- sources: LICENSE
|
||||||
|
text: |
|
||||||
|
Actions Http Client for Node.js
|
||||||
|
|
||||||
|
Copyright (c) GitHub, Inc.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
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.
|
||||||
|
notices: []
|
65
README.md
65
README.md
|
@ -127,6 +127,26 @@ steps:
|
||||||
- run: python my_script.py
|
- run: python my_script.py
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Download and set up the latest patch version of Python (for specified major & minor versions):
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.11-dev'
|
||||||
|
- run: python my_script.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Download and set up the latest stable version of Python (for specified major version):
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
- run: python my_script.py
|
||||||
|
```
|
||||||
|
|
||||||
Download and set up PyPy:
|
Download and set up PyPy:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -269,12 +289,12 @@ steps:
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Install pipenv
|
|
||||||
run: pipx install pipenv
|
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.9'
|
python-version: '3.9'
|
||||||
cache: 'pipenv'
|
cache: 'pipenv'
|
||||||
|
- name: Install pipenv
|
||||||
|
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
|
||||||
- run: pipenv install
|
- run: pipenv install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -308,8 +328,6 @@ steps:
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Install pipenv
|
|
||||||
run: pipx install pipenv
|
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.9'
|
python-version: '3.9'
|
||||||
|
@ -317,9 +335,46 @@ steps:
|
||||||
cache-dependency-path: |
|
cache-dependency-path: |
|
||||||
server/app/Pipfile.lock
|
server/app/Pipfile.lock
|
||||||
__test__/app/Pipfile.lock
|
__test__/app/Pipfile.lock
|
||||||
|
- name: Install pipenv
|
||||||
|
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python
|
||||||
- run: pipenv install
|
- run: pipenv install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Using a list of wildcard patterns to cache dependencies**
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
cache: 'pip'
|
||||||
|
cache-dependency-path: |
|
||||||
|
**/setup.cfg
|
||||||
|
**/requirements*.txt
|
||||||
|
- run: pip install -e . -r subdirectory/requirements-dev.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
|
||||||
|
The `update-environment` flag defaults to `true`.
|
||||||
|
With this setting, the action will add/update environment variables (e.g. `PATH`, `PKG_CONFIG_PATH`, `pythonLocation`) for `python` to just work out of the box.
|
||||||
|
|
||||||
|
If `update-environment` is set to `false`, the action will not add/update environment variables.
|
||||||
|
This can prove useful if you want the only side-effect to be to ensure python is installed and rely on the `python-path` output to run python.
|
||||||
|
Such a requirement on side-effect could be because you don't want your composite action messing with your user's workflows.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-python@v4
|
||||||
|
id: cp310
|
||||||
|
with:
|
||||||
|
python-version: '3.10'
|
||||||
|
update-environment: false
|
||||||
|
- run: ${{ steps.cp310.outputs.python-path }} my_script.py
|
||||||
|
```
|
||||||
|
|
||||||
# Using `setup-python` with a self hosted runner
|
# Using `setup-python` with a self hosted runner
|
||||||
|
|
||||||
Python distributions are only available for the same [environments](https://github.com/actions/virtual-environments#available-environments) that GitHub Actions hosted environments are available for. If you are using an unsupported version of Ubuntu such as `19.04` or another Linux distribution such as Fedora, `setup-python` will not work. If you have a supported self-hosted runner and you would like to use `setup-python`, there are a few extra things you need to make sure are set up so that new versions of Python can be downloaded and configured on your runner.
|
Python distributions are only available for the same [environments](https://github.com/actions/virtual-environments#available-environments) that GitHub Actions hosted environments are available for. If you are using an unsupported version of Ubuntu such as `19.04` or another Linux distribution such as Fedora, `setup-python` will not work. If you have a supported self-hosted runner and you would like to use `setup-python`, there are a few extra things you need to make sure are set up so that new versions of Python can be downloaded and configured on your runner.
|
||||||
|
@ -337,7 +392,7 @@ If you are experiencing problems while configuring Python on your self-hosted ru
|
||||||
### Linux
|
### Linux
|
||||||
|
|
||||||
- The Python packages that are downloaded from `actions/python-versions` are originally compiled from source in `/opt/hostedtoolcache/` with the [--enable-shared](https://github.com/actions/python-versions/blob/94f04ae6806c6633c82db94c6406a16e17decd5c/builders/ubuntu-python-builder.psm1#L35) flag, which makes them non-relocatable.
|
- The Python packages that are downloaded from `actions/python-versions` are originally compiled from source in `/opt/hostedtoolcache/` with the [--enable-shared](https://github.com/actions/python-versions/blob/94f04ae6806c6633c82db94c6406a16e17decd5c/builders/ubuntu-python-builder.psm1#L35) flag, which makes them non-relocatable.
|
||||||
- Create an environment variable called `AGENT_TOOLSDIRECTORY` and set it to `/opt/hostedtoolcache`. This controls where the runner downloads and installs tools.
|
- By default runner downloads and install the tools to `/opt/hostedtoolcache`. The environment variable called `AGENT_TOOLSDIRECTORY` can be set to change this location.
|
||||||
- In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`.
|
- In the same shell that your runner is using, type `export AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`.
|
||||||
- A more permanent way of setting the environment variable is to create a `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`. This ensures the variable is always set if your runner is configured as a service.
|
- A more permanent way of setting the environment variable is to create a `.env` file in the same directory as your runner and to add `AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache`. This ensures the variable is always set if your runner is configured as a service.
|
||||||
- Create a directory called `hostedtoolcache` inside `/opt`.
|
- Create a directory called `hostedtoolcache` inside `/opt`.
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {getCacheDistributor} from '../src/cache-distributions/cache-factory';
|
||||||
|
|
||||||
describe('restore-cache', () => {
|
describe('restore-cache', () => {
|
||||||
const pipFileLockHash =
|
const pipFileLockHash =
|
||||||
'd1dd6218299d8a6db5fc2001d988b34a8b31f1e9d0bb4534d377dde7c19f64b3';
|
'a3bdcc71289e4979ca9e051810d81999cc99823109faf6912e17ff14c8e621a6';
|
||||||
const requirementsHash =
|
const requirementsHash =
|
||||||
'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121';
|
'd8110e0006d7fb5ee76365d565eef9d37df1d11598b912d3eb66d398d57a1121';
|
||||||
const requirementsLinuxHash =
|
const requirementsLinuxHash =
|
||||||
|
|
|
@ -212,6 +212,59 @@ describe('run', () => {
|
||||||
);
|
);
|
||||||
expect(setFailedSpy).not.toHaveBeenCalled();
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('saves with -1 cacheId , should not fail workflow', async () => {
|
||||||
|
inputs['cache'] = 'poetry';
|
||||||
|
getStateSpy.mockImplementation((name: string) => {
|
||||||
|
if (name === State.STATE_CACHE_PRIMARY_KEY) {
|
||||||
|
return poetryLockHash;
|
||||||
|
} else if (name === State.CACHE_PATHS) {
|
||||||
|
return JSON.stringify([__dirname]);
|
||||||
|
} else {
|
||||||
|
return requirementsHash;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
saveCacheSpy.mockImplementation(() => {
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalled();
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).not.toHaveBeenLastCalledWith(
|
||||||
|
`Cache saved with the key: ${poetryLockHash}`
|
||||||
|
);
|
||||||
|
expect(setFailedSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('saves with error from toolkit, should fail workflow', async () => {
|
||||||
|
inputs['cache'] = 'npm';
|
||||||
|
getStateSpy.mockImplementation((name: string) => {
|
||||||
|
if (name === State.STATE_CACHE_PRIMARY_KEY) {
|
||||||
|
return poetryLockHash;
|
||||||
|
} else if (name === State.CACHE_PATHS) {
|
||||||
|
return JSON.stringify([__dirname]);
|
||||||
|
} else {
|
||||||
|
return requirementsHash;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
saveCacheSpy.mockImplementation(() => {
|
||||||
|
throw new cache.ValidationError('Validation failed');
|
||||||
|
});
|
||||||
|
|
||||||
|
await run();
|
||||||
|
|
||||||
|
expect(getInputSpy).toHaveBeenCalled();
|
||||||
|
expect(getStateSpy).toHaveBeenCalledTimes(3);
|
||||||
|
expect(infoSpy).not.toHaveBeenCalledWith();
|
||||||
|
expect(saveCacheSpy).toHaveBeenCalled();
|
||||||
|
expect(setFailedSpy).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
|
|
@ -4,8 +4,8 @@ verify_ssl = true
|
||||||
name = "pypi"
|
name = "pypi"
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
numpy = "1.22.3"
|
flake8 = "==4.0.1"
|
||||||
pandas = "1.4.2"
|
numpy = "==1.23.0"
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
||||||
|
|
115
__tests__/data/Pipfile.lock
generated
115
__tests__/data/Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "33e3640eff8b2b6c7149b85568151f39a66c544033b4b3f3f2ec9ad5ce6dfe7e"
|
"sha256": "e9c37110984955621040e2dc8548c026eb8466c23db1b8e69430289b10be8938"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -16,81 +16,64 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"default": {
|
"default": {
|
||||||
|
"flake8": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:479b1304f72536a55948cb40a32dce8bb0ffe3501e26eaf292c7e60eb5e0428d",
|
||||||
|
"sha256:806e034dda44114815e23c16ef92f95c91e4c71100ff52813adf7132a6ad870d"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==4.0.1"
|
||||||
|
},
|
||||||
|
"mccabe": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42",
|
||||||
|
"sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"
|
||||||
|
],
|
||||||
|
"version": "==0.6.1"
|
||||||
|
},
|
||||||
"numpy": {
|
"numpy": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:07a8c89a04997625236c5ecb7afe35a02af3896c8aa01890a849913a2309c676",
|
"sha256:092f5e6025813e64ad6d1b52b519165d08c730d099c114a9247c9bb635a2a450",
|
||||||
"sha256:08d9b008d0156c70dc392bb3ab3abb6e7a711383c3247b410b39962263576cd4",
|
"sha256:196cd074c3f97c4121601790955f915187736f9cf458d3ee1f1b46aff2b1ade0",
|
||||||
"sha256:201b4d0552831f7250a08d3b38de0d989d6f6e4658b709a02a73c524ccc6ffce",
|
"sha256:1c29b44905af288b3919803aceb6ec7fec77406d8b08aaa2e8b9e63d0fe2f160",
|
||||||
"sha256:2c10a93606e0b4b95c9b04b77dc349b398fdfbda382d2a39ba5a822f669a0123",
|
"sha256:2b2da66582f3a69c8ce25ed7921dcd8010d05e59ac8d89d126a299be60421171",
|
||||||
"sha256:3ca688e1b9b95d80250bca34b11a05e389b1420d00e87a0d12dc45f131f704a1",
|
"sha256:5043bcd71fcc458dfb8a0fc5509bbc979da0131b9d08e3d5f50fb0bbb36f169a",
|
||||||
"sha256:48a3aecd3b997bf452a2dedb11f4e79bc5bfd21a1d4cc760e703c31d57c84b3e",
|
"sha256:58bfd40eb478f54ff7a5710dd61c8097e169bc36cc68333d00a9bcd8def53b38",
|
||||||
"sha256:568dfd16224abddafb1cbcce2ff14f522abe037268514dd7e42c6776a1c3f8e5",
|
"sha256:79a506cacf2be3a74ead5467aee97b81fca00c9c4c8b3ba16dbab488cd99ba10",
|
||||||
"sha256:5bfb1bb598e8229c2d5d48db1860bcf4311337864ea3efdbe1171fb0c5da515d",
|
"sha256:94b170b4fa0168cd6be4becf37cb5b127bd12a795123984385b8cd4aca9857e5",
|
||||||
"sha256:639b54cdf6aa4f82fe37ebf70401bbb74b8508fddcf4797f9fe59615b8c5813a",
|
"sha256:97a76604d9b0e79f59baeca16593c711fddb44936e40310f78bfef79ee9a835f",
|
||||||
"sha256:8251ed96f38b47b4295b1ae51631de7ffa8260b5b087808ef09a39a9d66c97ab",
|
"sha256:98e8e0d8d69ff4d3fa63e6c61e8cfe2d03c29b16b58dbef1f9baa175bbed7860",
|
||||||
"sha256:92bfa69cfbdf7dfc3040978ad09a48091143cffb778ec3b03fa170c494118d75",
|
"sha256:ac86f407873b952679f5f9e6c0612687e51547af0e14ddea1eedfcb22466babd",
|
||||||
"sha256:97098b95aa4e418529099c26558eeb8486e66bd1e53a6b606d684d0c3616b168",
|
"sha256:ae8adff4172692ce56233db04b7ce5792186f179c415c37d539c25de7298d25d",
|
||||||
"sha256:a3bae1a2ed00e90b3ba5f7bd0a7c7999b55d609e0c54ceb2b076a25e345fa9f4",
|
"sha256:bd3fa4fe2e38533d5336e1272fc4e765cabbbde144309ccee8675509d5cd7b05",
|
||||||
"sha256:c34ea7e9d13a70bf2ab64a2532fe149a9aced424cd05a2c4ba662fd989e3e45f",
|
"sha256:d0d2094e8f4d760500394d77b383a1b06d3663e8892cdf5df3c592f55f3bff66",
|
||||||
"sha256:dbc7601a3b7472d559dc7b933b18b4b66f9aa7452c120e87dfb33d02008c8a18",
|
"sha256:d54b3b828d618a19779a84c3ad952e96e2c2311b16384e973e671aa5be1f6187",
|
||||||
"sha256:e7927a589df200c5e23c57970bafbd0cd322459aa7b1ff73b7c2e84d6e3eae62",
|
"sha256:d6ca8dabe696c2785d0c8c9b0d8a9b6e5fdbe4f922bde70d57fa1a2848134f95",
|
||||||
"sha256:f8c1f39caad2c896bc0018f699882b345b2a63708008be29b1f355ebf6f933fe",
|
"sha256:d8cc87bed09de55477dba9da370c1679bd534df9baa171dd01accbb09687dac3",
|
||||||
"sha256:f950f8845b480cffe522913d35567e29dd381b0dc7e4ce6a4a9f9156417d2430",
|
"sha256:f0f18804df7370571fb65db9b98bf1378172bd4e962482b857e612d1fec0f53e",
|
||||||
"sha256:fade0d4f4d292b6f39951b6836d7a3c7ef5b2347f3c420cd9820a1d90d794802",
|
"sha256:f1d88ef79e0a7fa631bb2c3dda1ea46b32b1fe614e10fedd611d3d5398447f2f",
|
||||||
"sha256:fdf3c08bce27132395d3c3ba1503cac12e17282358cb4bddc25cc46b0aca07aa"
|
"sha256:f9c3fc2adf67762c9fe1849c859942d23f8d3e0bee7b5ed3d4a9c3eeb50a2f07",
|
||||||
|
"sha256:fc431493df245f3c627c0c05c2bd134535e7929dbe2e602b80e42bf52ff760bc",
|
||||||
|
"sha256:fe8b9683eb26d2c4d5db32cd29b38fdcf8381324ab48313b5b69088e0e355379"
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==1.22.3"
|
"version": "==1.23.0"
|
||||||
},
|
},
|
||||||
"pandas": {
|
"pycodestyle": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:0010771bd9223f7afe5f051eb47c4a49534345dfa144f2f5470b27189a4dd3b5",
|
"sha256:720f8b39dde8b293825e7ff02c475f3077124006db4f440dcbc9a20b76548a20",
|
||||||
"sha256:061609334a8182ab500a90fe66d46f6f387de62d3a9cb9aa7e62e3146c712167",
|
"sha256:eddd5847ef438ea1c7870ca7eb78a9d47ce0cdb4851a5523949f2601d0cbbe7f"
|
||||||
"sha256:09d8be7dd9e1c4c98224c4dfe8abd60d145d934e9fc1f5f411266308ae683e6a",
|
|
||||||
"sha256:295872bf1a09758aba199992c3ecde455f01caf32266d50abc1a073e828a7b9d",
|
|
||||||
"sha256:3228198333dd13c90b6434ddf61aa6d57deaca98cf7b654f4ad68a2db84f8cfe",
|
|
||||||
"sha256:385c52e85aaa8ea6a4c600a9b2821181a51f8be0aee3af6f2dcb41dafc4fc1d0",
|
|
||||||
"sha256:51649ef604a945f781105a6d2ecf88db7da0f4868ac5d45c51cb66081c4d9c73",
|
|
||||||
"sha256:5586cc95692564b441f4747c47c8a9746792e87b40a4680a2feb7794defb1ce3",
|
|
||||||
"sha256:5a206afa84ed20e07603f50d22b5f0db3fb556486d8c2462d8bc364831a4b417",
|
|
||||||
"sha256:5b79af3a69e5175c6fa7b4e046b21a646c8b74e92c6581a9d825687d92071b51",
|
|
||||||
"sha256:5c54ea4ef3823108cd4ec7fb27ccba4c3a775e0f83e39c5e17f5094cb17748bc",
|
|
||||||
"sha256:8c5bf555b6b0075294b73965adaafb39cf71c312e38c5935c93d78f41c19828a",
|
|
||||||
"sha256:92bc1fc585f1463ca827b45535957815b7deb218c549b7c18402c322c7549a12",
|
|
||||||
"sha256:95c1e422ced0199cf4a34385ff124b69412c4bc912011ce895582bee620dfcaa",
|
|
||||||
"sha256:b8134651258bce418cb79c71adeff0a44090c98d955f6953168ba16cc285d9f7",
|
|
||||||
"sha256:be67c782c4f1b1f24c2f16a157e12c2693fd510f8df18e3287c77f33d124ed07",
|
|
||||||
"sha256:c072c7f06b9242c855ed8021ff970c0e8f8b10b35e2640c657d2a541c5950f59",
|
|
||||||
"sha256:d0d4f13e4be7ce89d7057a786023c461dd9370040bdb5efa0a7fe76b556867a0",
|
|
||||||
"sha256:df82739e00bb6daf4bba4479a40f38c718b598a84654cbd8bb498fd6b0aa8c16",
|
|
||||||
"sha256:f549097993744ff8c41b5e8f2f0d3cbfaabe89b4ae32c8c08ead6cc535b80139",
|
|
||||||
"sha256:ff08a14ef21d94cdf18eef7c569d66f2e24e0bc89350bcd7d243dd804e3b5eb2"
|
|
||||||
],
|
],
|
||||||
"index": "pypi",
|
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||||
"version": "==1.4.2"
|
"version": "==2.8.0"
|
||||||
},
|
},
|
||||||
"python-dateutil": {
|
"pyflakes": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
|
"sha256:05a85c2872edf37a4ed30b0cce2f6093e1d0581f8c19d7393122da7e25b2b24c",
|
||||||
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
|
"sha256:3bb3a3f256f4b7968c9c788781e4ff07dce46bdf12339dcda61053375426ee2e"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||||
"version": "==2.8.2"
|
"version": "==2.4.0"
|
||||||
},
|
|
||||||
"pytz": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7",
|
|
||||||
"sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c"
|
|
||||||
],
|
|
||||||
"version": "==2022.1"
|
|
||||||
},
|
|
||||||
"six": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
|
|
||||||
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
|
|
||||||
],
|
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
|
||||||
"version": "==1.16.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {}
|
"develop": {}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {HttpClient} from '@actions/http-client';
|
||||||
import * as ifm from '@actions/http-client/interfaces';
|
import * as ifm from '@actions/http-client/interfaces';
|
||||||
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 * as core from '@actions/core';
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
@ -148,8 +149,13 @@ describe('findPyPyVersion', () => {
|
||||||
let spyWriteExactPyPyVersionFile: jest.SpyInstance;
|
let spyWriteExactPyPyVersionFile: jest.SpyInstance;
|
||||||
let spyCacheDir: jest.SpyInstance;
|
let spyCacheDir: jest.SpyInstance;
|
||||||
let spyChmodSync: jest.SpyInstance;
|
let spyChmodSync: jest.SpyInstance;
|
||||||
|
let spyCoreAddPath: jest.SpyInstance;
|
||||||
|
let spyCoreExportVariable: jest.SpyInstance;
|
||||||
|
const env = process.env;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {...env};
|
||||||
tcFind = jest.spyOn(tc, 'find');
|
tcFind = jest.spyOn(tc, 'find');
|
||||||
tcFind.mockImplementation((tool: string, version: string) => {
|
tcFind.mockImplementation((tool: string, version: string) => {
|
||||||
const semverRange = new semver.Range(version);
|
const semverRange = new semver.Range(version);
|
||||||
|
@ -201,32 +207,46 @@ describe('findPyPyVersion', () => {
|
||||||
|
|
||||||
spyExistsSync = jest.spyOn(fs, 'existsSync');
|
spyExistsSync = jest.spyOn(fs, 'existsSync');
|
||||||
spyExistsSync.mockReturnValue(true);
|
spyExistsSync.mockReturnValue(true);
|
||||||
|
|
||||||
|
spyCoreAddPath = jest.spyOn(core, 'addPath');
|
||||||
|
|
||||||
|
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
jest.restoreAllMocks();
|
jest.restoreAllMocks();
|
||||||
|
process.env = env;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('found PyPy in toolcache', async () => {
|
it('found PyPy in toolcache', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture)
|
finder.findPyPyVersion('pypy-3.6-v7.3.x', architecture, true)
|
||||||
).resolves.toEqual({
|
).resolves.toEqual({
|
||||||
resolvedPythonVersion: '3.6.12',
|
resolvedPythonVersion: '3.6.12',
|
||||||
resolvedPyPyVersion: '7.3.3'
|
resolvedPyPyVersion: '7.3.3'
|
||||||
});
|
});
|
||||||
|
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'pythonLocation',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'PKG_CONFIG_PATH',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throw on invalid input format', async () => {
|
it('throw on invalid input format', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture)
|
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true)
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throw on invalid input format pypy3.7-7.3.x', async () => {
|
it('throw on invalid input format pypy3.7-7.3.x', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture)
|
finder.findPyPyVersion('pypy3.7-v7.3.x', architecture, true)
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -238,16 +258,42 @@ describe('findPyPyVersion', () => {
|
||||||
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||||
spyChmodSync.mockImplementation(() => undefined);
|
spyChmodSync.mockImplementation(() => undefined);
|
||||||
await expect(
|
await expect(
|
||||||
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture)
|
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture, true)
|
||||||
).resolves.toEqual({
|
).resolves.toEqual({
|
||||||
resolvedPythonVersion: '3.7.9',
|
resolvedPythonVersion: '3.7.9',
|
||||||
resolvedPyPyVersion: '7.3.3'
|
resolvedPyPyVersion: '7.3.3'
|
||||||
});
|
});
|
||||||
|
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'pythonLocation',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'PKG_CONFIG_PATH',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('found and install successfully without environment update', async () => {
|
||||||
|
spyCacheDir = jest.spyOn(tc, 'cacheDir');
|
||||||
|
spyCacheDir.mockImplementation(() =>
|
||||||
|
path.join(toolDir, 'PyPy', '3.7.7', architecture)
|
||||||
|
);
|
||||||
|
spyChmodSync = jest.spyOn(fs, 'chmodSync');
|
||||||
|
spyChmodSync.mockImplementation(() => undefined);
|
||||||
|
await expect(
|
||||||
|
finder.findPyPyVersion('pypy-3.7-v7.3.x', architecture, false)
|
||||||
|
).resolves.toEqual({
|
||||||
|
resolvedPythonVersion: '3.7.9',
|
||||||
|
resolvedPyPyVersion: '7.3.3'
|
||||||
|
});
|
||||||
|
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throw if release is not found', async () => {
|
it('throw if release is not found', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
finder.findPyPyVersion('pypy-3.7-v7.5.x', architecture)
|
finder.findPyPyVersion('pypy-3.7-v7.5.x', architecture, true)
|
||||||
).rejects.toThrowError(
|
).rejects.toThrowError(
|
||||||
`PyPy version 3.7 (v7.5.x) with arch ${architecture} not found`
|
`PyPy version 3.7 (v7.5.x) with arch ${architecture} not found`
|
||||||
);
|
);
|
||||||
|
|
|
@ -19,15 +19,29 @@ process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
||||||
process.env['RUNNER_TEMP'] = tempDir;
|
process.env['RUNNER_TEMP'] = tempDir;
|
||||||
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
|
import * as core from '@actions/core';
|
||||||
import * as finder from '../src/find-python';
|
import * as finder from '../src/find-python';
|
||||||
import * as installer from '../src/install-python';
|
import * as installer from '../src/install-python';
|
||||||
|
|
||||||
const manifestData = require('./data/versions-manifest.json');
|
const manifestData = require('./data/versions-manifest.json');
|
||||||
|
|
||||||
describe('Finder tests', () => {
|
describe('Finder tests', () => {
|
||||||
|
let spyCoreAddPath: jest.SpyInstance;
|
||||||
|
let spyCoreExportVariable: jest.SpyInstance;
|
||||||
|
const env = process.env;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
process.env = {...env};
|
||||||
|
spyCoreAddPath = jest.spyOn(core, 'addPath');
|
||||||
|
spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
process.env = env;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds Python if it is installed', async () => {
|
it('Finds Python if it is installed', async () => {
|
||||||
|
@ -35,7 +49,26 @@ describe('Finder tests', () => {
|
||||||
await io.mkdirP(pythonDir);
|
await io.mkdirP(pythonDir);
|
||||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||||
await finder.useCpythonVersion('3.x', 'x64');
|
await finder.useCpythonVersion('3.x', 'x64', true);
|
||||||
|
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'pythonLocation',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'PKG_CONFIG_PATH',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Finds Python if it is installed without environment update', async () => {
|
||||||
|
const pythonDir: string = path.join(toolDir, 'Python', '3.0.0', 'x64');
|
||||||
|
await io.mkdirP(pythonDir);
|
||||||
|
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||||
|
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||||
|
await finder.useCpythonVersion('3.x', 'x64', false);
|
||||||
|
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
|
||||||
|
@ -52,7 +85,16 @@ describe('Finder tests', () => {
|
||||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||||
});
|
});
|
||||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||||
await finder.useCpythonVersion('1.2.3', 'x64');
|
await finder.useCpythonVersion('1.2.3', 'x64', true);
|
||||||
|
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'pythonLocation',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'PKG_CONFIG_PATH',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Finds pre-release Python version in the manifest', async () => {
|
it('Finds pre-release Python version in the manifest', async () => {
|
||||||
|
@ -74,17 +116,28 @@ describe('Finder tests', () => {
|
||||||
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
fs.writeFileSync(`${pythonDir}.complete`, 'hello');
|
||||||
});
|
});
|
||||||
// This will throw if it doesn't find it in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the manifest (because no such version exists)
|
||||||
await finder.useCpythonVersion('1.2.3-beta.2', 'x64');
|
await finder.useCpythonVersion('1.2.3-beta.2', 'x64', true);
|
||||||
|
expect(spyCoreAddPath).toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'pythonLocation',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
|
expect(spyCoreExportVariable).toHaveBeenCalledWith(
|
||||||
|
'PKG_CONFIG_PATH',
|
||||||
|
expect.anything()
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Errors if Python is not installed', async () => {
|
it('Errors if Python is not installed', async () => {
|
||||||
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
// This will throw if it doesn't find it in the cache and in the manifest (because no such version exists)
|
||||||
let thrown = false;
|
let thrown = false;
|
||||||
try {
|
try {
|
||||||
await finder.useCpythonVersion('3.300000', 'x64');
|
await finder.useCpythonVersion('3.300000', 'x64', true);
|
||||||
} catch {
|
} catch {
|
||||||
thrown = true;
|
thrown = true;
|
||||||
}
|
}
|
||||||
expect(thrown).toBeTruthy();
|
expect(thrown).toBeTruthy();
|
||||||
|
expect(spyCoreAddPath).not.toHaveBeenCalled();
|
||||||
|
expect(spyCoreExportVariable).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -17,6 +17,9 @@ inputs:
|
||||||
default: ${{ github.token }}
|
default: ${{ 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:
|
||||||
|
description: 'Set this option if you want the action to update environment variables.'
|
||||||
|
default: true
|
||||||
outputs:
|
outputs:
|
||||||
python-version:
|
python-version:
|
||||||
description: "The installed python version. Useful when given a version range as input."
|
description: "The installed python version. Useful when given a version range as input."
|
||||||
|
|
1607
dist/cache-save/index.js
vendored
1607
dist/cache-save/index.js
vendored
File diff suppressed because it is too large
Load diff
1083
dist/setup/index.js
vendored
1083
dist/setup/index.js
vendored
File diff suppressed because it is too large
Load diff
66
package-lock.json
generated
66
package-lock.json
generated
|
@ -9,8 +9,8 @@
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^2.0.2",
|
"@actions/cache": "^3.0.0",
|
||||||
"@actions/core": "^1.2.3",
|
"@actions/core": "^1.7.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,14 +31,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache": {
|
"node_modules/@actions/cache": {
|
||||||
"version": "2.0.2",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
|
||||||
"integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
|
"integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/glob": "^0.1.0",
|
"@actions/glob": "^0.1.0",
|
||||||
"@actions/http-client": "^1.0.9",
|
"@actions/http-client": "^2.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
"@azure/ms-rest-js": "^2.6.0",
|
"@azure/ms-rest-js": "^2.6.0",
|
||||||
"@azure/storage-blob": "^12.8.0",
|
"@azure/storage-blob": "^12.8.0",
|
||||||
|
@ -56,11 +56,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache/node_modules/@actions/http-client": {
|
"node_modules/@actions/cache/node_modules/@actions/http-client": {
|
||||||
"version": "1.0.11",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache/node_modules/semver": {
|
"node_modules/@actions/cache/node_modules/semver": {
|
||||||
|
@ -72,9 +72,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.2.6",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.7.0.tgz",
|
||||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
"integrity": "sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@actions/http-client": "^1.0.11"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/exec": {
|
"node_modules/@actions/exec": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
|
@ -94,9 +97,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client": {
|
"node_modules/@actions/http-client": {
|
||||||
"version": "1.0.8",
|
"version": "1.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||||
"integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==",
|
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "0.0.6"
|
"tunnel": "0.0.6"
|
||||||
}
|
}
|
||||||
|
@ -11337,14 +11340,14 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": {
|
"@actions/cache": {
|
||||||
"version": "2.0.2",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.0.tgz",
|
||||||
"integrity": "sha512-K1DCaW/OtHj5mV7hI7HEXiceX3rM4Nc0iG2hfYsrkEy6GiOeqlCC/LyICrBZIRDM6+vSrS12tg1ORl4hghomBA==",
|
"integrity": "sha512-GL9CT1Fnu+pqs8TTB621q8Xa8Cilw2n9MwvbgMedetH7L1q2n6jY61gzbwGbKgtVbp3gVJ12aNMi4osSGXx3KQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.0.1",
|
||||||
"@actions/glob": "^0.1.0",
|
"@actions/glob": "^0.1.0",
|
||||||
"@actions/http-client": "^1.0.9",
|
"@actions/http-client": "^2.0.1",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.0.1",
|
||||||
"@azure/ms-rest-js": "^2.6.0",
|
"@azure/ms-rest-js": "^2.6.0",
|
||||||
"@azure/storage-blob": "^12.8.0",
|
"@azure/storage-blob": "^12.8.0",
|
||||||
|
@ -11362,11 +11365,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
"version": "1.0.11",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"tunnel": "0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
|
@ -11377,9 +11380,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/core": {
|
"@actions/core": {
|
||||||
"version": "1.2.6",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.7.0.tgz",
|
||||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
"integrity": "sha512-7fPSS7yKOhTpgLMbw7lBLc1QJWvJBBAgyTX2PEhagWcKK8t0H8AKCoPMfnrHqIm5cRYH4QFPqD1/ruhuUE7YcQ==",
|
||||||
|
"requires": {
|
||||||
|
"@actions/http-client": "^1.0.11"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"@actions/exec": {
|
"@actions/exec": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
|
@ -11399,9 +11405,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
"version": "1.0.8",
|
"version": "1.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||||
"integrity": "sha512-G4JjJ6f9Hb3Zvejj+ewLLKLf99ZC+9v+yCxoYf9vSyH+WkzPLB2LuUtRMGNkooMqdugGBFStIKXOuvH1W+EctA==",
|
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"tunnel": "0.0.6"
|
"tunnel": "0.0.6"
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
"format": "prettier --write \"{,!(node_modules)/**/}*.ts\"",
|
"format": "prettier --write \"{,!(node_modules)/**/}*.ts\"",
|
||||||
"format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"",
|
"format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"",
|
||||||
"release": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts && git add -f dist/",
|
"release": "ncc build -o dist/setup src/setup-python.ts && ncc build -o dist/cache-save src/cache-save.ts && git add -f dist/",
|
||||||
"test": "jest"
|
"test": "jest --coverage"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -23,8 +23,8 @@
|
||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/cache": "^2.0.2",
|
"@actions/cache": "^3.0.0",
|
||||||
"@actions/core": "^1.2.3",
|
"@actions/core": "^1.7.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",
|
||||||
|
|
|
@ -43,17 +43,11 @@ async function saveCache(packageManager: string) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const cacheId = await cache.saveCache(cachePaths, primaryKey);
|
||||||
await cache.saveCache(cachePaths, primaryKey);
|
if (cacheId == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
} catch (error) {
|
|
||||||
const err = error as Error;
|
|
||||||
if (err.name === cache.ReserveCacheError.name) {
|
|
||||||
core.info(err.message);
|
|
||||||
} else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCacheDirectoryExists(cacheDirectory: string[]) {
|
function isCacheDirectoryExists(cacheDirectory: string[]) {
|
||||||
|
|
|
@ -20,7 +20,8 @@ interface IPyPyVersionSpec {
|
||||||
|
|
||||||
export async function findPyPyVersion(
|
export async function findPyPyVersion(
|
||||||
versionSpec: string,
|
versionSpec: string,
|
||||||
architecture: string
|
architecture: string,
|
||||||
|
updateEnvironment: boolean
|
||||||
): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> {
|
): Promise<{resolvedPyPyVersion: string; resolvedPythonVersion: string}> {
|
||||||
let resolvedPyPyVersion = '';
|
let resolvedPyPyVersion = '';
|
||||||
let resolvedPythonVersion = '';
|
let resolvedPythonVersion = '';
|
||||||
|
@ -54,10 +55,18 @@ export async function findPyPyVersion(
|
||||||
`python${binaryExtension}`
|
`python${binaryExtension}`
|
||||||
);
|
);
|
||||||
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
|
const pythonLocation = pypyInstall.getPyPyBinaryPath(installDir);
|
||||||
|
if (updateEnvironment) {
|
||||||
core.exportVariable('pythonLocation', installDir);
|
core.exportVariable('pythonLocation', installDir);
|
||||||
|
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
|
||||||
|
core.exportVariable('Python_ROOT_DIR', installDir);
|
||||||
|
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
|
||||||
|
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||||
|
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||||
|
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||||
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
|
core.exportVariable('PKG_CONFIG_PATH', pythonLocation + '/lib/pkgconfig');
|
||||||
core.addPath(pythonLocation);
|
core.addPath(pythonLocation);
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
|
}
|
||||||
core.setOutput('python-version', 'pypy' + resolvedPyPyVersion.trim());
|
core.setOutput('python-version', 'pypy' + resolvedPyPyVersion.trim());
|
||||||
core.setOutput('python-path', pythonPath);
|
core.setOutput('python-path', pythonPath);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ function binDir(installDir: string): string {
|
||||||
|
|
||||||
export async function useCpythonVersion(
|
export async function useCpythonVersion(
|
||||||
version: string,
|
version: string,
|
||||||
architecture: string
|
architecture: string,
|
||||||
|
updateEnvironment: boolean
|
||||||
): Promise<InstalledVersion> {
|
): Promise<InstalledVersion> {
|
||||||
const desugaredVersionSpec = desugarDevVersion(version);
|
const desugaredVersionSpec = desugarDevVersion(version);
|
||||||
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
|
||||||
|
@ -69,8 +70,23 @@ export async function useCpythonVersion(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const _binDir = binDir(installDir);
|
||||||
|
const binaryExtension = IS_WINDOWS ? '.exe' : '';
|
||||||
|
const pythonPath = path.join(
|
||||||
|
IS_WINDOWS ? installDir : _binDir,
|
||||||
|
`python${binaryExtension}`
|
||||||
|
);
|
||||||
|
if (updateEnvironment) {
|
||||||
core.exportVariable('pythonLocation', installDir);
|
core.exportVariable('pythonLocation', installDir);
|
||||||
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
|
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
|
||||||
|
core.exportVariable('pythonLocation', installDir);
|
||||||
|
// https://cmake.org/cmake/help/latest/module/FindPython.html#module:FindPython
|
||||||
|
core.exportVariable('Python_ROOT_DIR', installDir);
|
||||||
|
// https://cmake.org/cmake/help/latest/module/FindPython2.html#module:FindPython2
|
||||||
|
core.exportVariable('Python2_ROOT_DIR', installDir);
|
||||||
|
// https://cmake.org/cmake/help/latest/module/FindPython3.html#module:FindPython3
|
||||||
|
core.exportVariable('Python3_ROOT_DIR', installDir);
|
||||||
|
core.exportVariable('PKG_CONFIG_PATH', installDir + '/lib/pkgconfig');
|
||||||
|
|
||||||
if (IS_LINUX) {
|
if (IS_LINUX) {
|
||||||
const libPath = process.env.LD_LIBRARY_PATH
|
const libPath = process.env.LD_LIBRARY_PATH
|
||||||
|
@ -82,13 +98,6 @@ export async function useCpythonVersion(
|
||||||
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
|
core.exportVariable('LD_LIBRARY_PATH', pyLibPath + libPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const _binDir = binDir(installDir);
|
|
||||||
const binaryExtension = IS_WINDOWS ? '.exe' : '';
|
|
||||||
const pythonPath = path.join(
|
|
||||||
IS_WINDOWS ? installDir : _binDir,
|
|
||||||
`python${binaryExtension}`
|
|
||||||
);
|
|
||||||
core.addPath(installDir);
|
core.addPath(installDir);
|
||||||
core.addPath(_binDir);
|
core.addPath(_binDir);
|
||||||
|
|
||||||
|
@ -109,6 +118,7 @@ export async function useCpythonVersion(
|
||||||
core.addPath(userScriptsDir);
|
core.addPath(userScriptsDir);
|
||||||
}
|
}
|
||||||
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
// On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
|
||||||
|
}
|
||||||
|
|
||||||
const installed = versionFromPath(installDir);
|
const installed = versionFromPath(installDir);
|
||||||
core.setOutput('python-version', installed);
|
core.setOutput('python-version', installed);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as path from 'path';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {getCacheDistributor} from './cache-distributions/cache-factory';
|
import {getCacheDistributor} from './cache-distributions/cache-factory';
|
||||||
import {isCacheFeatureAvailable} from './utils';
|
import {isCacheFeatureAvailable, IS_LINUX, IS_WINDOWS} from './utils';
|
||||||
|
|
||||||
function isPyPyVersion(versionSpec: string) {
|
function isPyPyVersion(versionSpec: string) {
|
||||||
return versionSpec.startsWith('pypy');
|
return versionSpec.startsWith('pypy');
|
||||||
|
@ -28,7 +28,7 @@ function resolveVersionInput(): string {
|
||||||
|
|
||||||
if (version && versionFile) {
|
if (version && versionFile) {
|
||||||
core.warning(
|
core.warning(
|
||||||
'Both python-version and python-version-file inputs are specified, only python-version will be used'
|
'Both python-version and python-version-file inputs are specified, only python-version will be used.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,42 +36,63 @@ function resolveVersionInput(): string {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionFile = versionFile || '.python-version';
|
if (versionFile) {
|
||||||
if (!fs.existsSync(versionFile)) {
|
if (!fs.existsSync(versionFile)) {
|
||||||
throw new Error(
|
logWarning(
|
||||||
`The specified python version file at: ${versionFile} does not exist`
|
`The specified python version file at: ${versionFile} doesn't exist. Attempting to find .python-version file.`
|
||||||
);
|
);
|
||||||
|
versionFile = '.python-version';
|
||||||
|
if (!fs.existsSync(versionFile)) {
|
||||||
|
throw new Error(`The ${versionFile} doesn't exist.`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
version = fs.readFileSync(versionFile, 'utf8');
|
version = fs.readFileSync(versionFile, 'utf8');
|
||||||
core.info(`Resolved ${versionFile} as ${version}`);
|
core.info(`Resolved ${versionFile} as ${version}`);
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run() {
|
core.warning(
|
||||||
if (process.env.AGENT_TOOLSDIRECTORY?.trim()) {
|
"Neither 'python-version' nor 'python-version-file' inputs were supplied."
|
||||||
core.debug(
|
|
||||||
`Python is expected to be installed into AGENT_TOOLSDIRECTORY=${process.env['AGENT_TOOLSDIRECTORY']}`
|
|
||||||
);
|
|
||||||
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
|
|
||||||
} else {
|
|
||||||
core.debug(
|
|
||||||
`Python is expected to be installed into RUNNER_TOOL_CACHE==${process.env['RUNNER_TOOL_CACHE']}`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
// According to the README windows binaries do not require to be installed
|
||||||
|
// in the specific location, but Mac and Linux do
|
||||||
|
if (!IS_WINDOWS && !process.env.AGENT_TOOLSDIRECTORY?.trim()) {
|
||||||
|
if (IS_LINUX) process.env['AGENT_TOOLSDIRECTORY'] = '/opt/hostedtoolcache';
|
||||||
|
else process.env['AGENT_TOOLSDIRECTORY'] = '/Users/runner/hostedtoolcache';
|
||||||
|
process.env['RUNNER_TOOL_CACHE'] = process.env['AGENT_TOOLSDIRECTORY'];
|
||||||
|
}
|
||||||
|
core.debug(
|
||||||
|
`Python is expected to be installed into RUNNER_TOOL_CACHE=${process.env['RUNNER_TOOL_CACHE']}`
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
const version = resolveVersionInput();
|
const version = resolveVersionInput();
|
||||||
if (version) {
|
if (version) {
|
||||||
let pythonVersion: string;
|
let pythonVersion: string;
|
||||||
const arch: string = core.getInput('architecture') || os.arch();
|
const arch: string = core.getInput('architecture') || os.arch();
|
||||||
|
const updateEnvironment = core.getBooleanInput('update-environment');
|
||||||
if (isPyPyVersion(version)) {
|
if (isPyPyVersion(version)) {
|
||||||
const installed = await finderPyPy.findPyPyVersion(version, arch);
|
const installed = await finderPyPy.findPyPyVersion(
|
||||||
|
version,
|
||||||
|
arch,
|
||||||
|
updateEnvironment
|
||||||
|
);
|
||||||
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
|
pythonVersion = `${installed.resolvedPyPyVersion}-${installed.resolvedPythonVersion}`;
|
||||||
core.info(
|
core.info(
|
||||||
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
`Successfully set up PyPy ${installed.resolvedPyPyVersion} with Python (${installed.resolvedPythonVersion})`
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const installed = await finder.useCpythonVersion(version, arch);
|
const installed = await finder.useCpythonVersion(
|
||||||
|
version,
|
||||||
|
arch,
|
||||||
|
updateEnvironment
|
||||||
|
);
|
||||||
pythonVersion = installed.version;
|
pythonVersion = installed.version;
|
||||||
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
|
core.info(`Successfully set up ${installed.impl} (${pythonVersion})`);
|
||||||
}
|
}
|
||||||
|
@ -92,4 +113,9 @@ async function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function logWarning(message: string): void {
|
||||||
|
const warningPrefix = '[warning]';
|
||||||
|
core.info(`${warningPrefix}${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
Loading…
Add table
Reference in a new issue