Throwing an error when python-version input is empty and PYTHON_VERSION_REQUIRED is set true

This commit is contained in:
Kazuhiro Masuda 2025-04-18 18:16:15 +09:00
parent 6ed2c67c8a
commit 35853705fb
2 changed files with 19 additions and 4 deletions

9
dist/setup/index.js vendored
View file

@ -97729,7 +97729,14 @@ function run() {
}
}
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');
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);

View file

@ -146,9 +146,17 @@ async function run() {
await cacheDependencies(cache, pythonVersion);
}
} 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');
core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);