mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
Merge 3a69c5f668
into 6ed2c67c8a
This commit is contained in:
commit
fea8af0911
4 changed files with 56 additions and 4 deletions
27
.github/workflows/test-python.yml
vendored
27
.github/workflows/test-python.yml
vendored
|
@ -505,3 +505,30 @@ jobs:
|
||||||
}
|
}
|
||||||
$pythonVersion
|
$pythonVersion
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
|
setup-python-version-required:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
[
|
||||||
|
macos-latest,
|
||||||
|
windows-latest,
|
||||||
|
ubuntu-22.04,
|
||||||
|
ubuntu-22.04-arm,
|
||||||
|
ubuntu-24.04-arm,
|
||||||
|
ubuntu-latest,
|
||||||
|
macos-13
|
||||||
|
]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup Python
|
||||||
|
id: setup-python
|
||||||
|
uses: ./
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION_REQUIRED: true
|
||||||
|
continue-on-error: true
|
||||||
|
- name: Validate failure
|
||||||
|
if: steps.setup-python.outcome != 'failure'
|
||||||
|
run: exit 1
|
||||||
|
|
9
dist/setup/index.js
vendored
9
dist/setup/index.js
vendored
|
@ -97729,7 +97729,14 @@ function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.warning('The `python-version` input is not set. The version of Python currently in `PATH` will be used.');
|
const trueValue = ['true', 'True', 'TRUE'];
|
||||||
|
const pythonVersionRequired = process.env['PYTHON_VERSION_REQUIRED'] || '';
|
||||||
|
if (!trueValue.includes(pythonVersionRequired)) {
|
||||||
|
core.warning('The `python-version` input is not set. The version of Python currently in `PATH` will be used.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('The `python-version` input is required.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
||||||
|
|
|
@ -138,6 +138,16 @@ steps:
|
||||||
```
|
```
|
||||||
Please refer to the [Advanced range syntax section](https://github.com/npm/node-semver#advanced-range-syntax) of the [semver](https://github.com/npm/node-semver) to check other available range syntaxes.
|
Please refer to the [Advanced range syntax section](https://github.com/npm/node-semver#advanced-range-syntax) of the [semver](https://github.com/npm/node-semver) to check other available range syntaxes.
|
||||||
|
|
||||||
|
If you want to make an error when unspecified, set `PYTHON_VERSION_REQUIRED: true` to env.
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
env:
|
||||||
|
PYTHON_VERSION_REQUIRED: true
|
||||||
|
# the action fail with error.
|
||||||
|
```
|
||||||
|
|
||||||
### Specifying a PyPy version
|
### Specifying a PyPy version
|
||||||
The version of PyPy should be specified in the format `pypy<python_version>[-v<pypy_version>]` or `pypy-<python_version>[-v<pypy_version>]`.
|
The version of PyPy should be specified in the format `pypy<python_version>[-v<pypy_version>]` or `pypy-<python_version>[-v<pypy_version>]`.
|
||||||
The `-v<pypy_version>` parameter is optional and can be skipped. The latest PyPy version will be used in this case.
|
The `-v<pypy_version>` parameter is optional and can be skipped. The latest PyPy version will be used in this case.
|
||||||
|
|
|
@ -146,9 +146,17 @@ async function run() {
|
||||||
await cacheDependencies(cache, pythonVersion);
|
await cacheDependencies(cache, pythonVersion);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
core.warning(
|
const trueValue = ['true', 'True', 'TRUE'];
|
||||||
'The `python-version` input is not set. The version of Python currently in `PATH` will be used.'
|
const pythonVersionRequired = process.env['PYTHON_VERSION_REQUIRED'] || '';
|
||||||
);
|
if(!trueValue.includes(pythonVersionRequired)) {
|
||||||
|
core.warning(
|
||||||
|
'The `python-version` input is not set. The version of Python currently in `PATH` will be used.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
throw new Error(
|
||||||
|
'The `python-version` input is required.'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const matchersPath = path.join(__dirname, '../..', '.github');
|
const matchersPath = path.join(__dirname, '../..', '.github');
|
||||||
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
|
||||||
|
|
Loading…
Add table
Reference in a new issue