Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow python-version-file to be a relative path #431

Merged
merged 2 commits into from Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions dist/setup/index.js
Expand Up @@ -64546,18 +64546,18 @@ function cacheDependencies(cache, pythonVersion) {
}
function resolveVersionInput() {
let version = core.getInput('python-version');
const versionFile = core.getInput('python-version-file');
let versionFile = core.getInput('python-version-file');
if (version && versionFile) {
core.warning('Both python-version and python-version-file inputs are specified, only python-version will be used');
}
if (version) {
return version;
}
const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFile || '.python-version');
if (!fs_1.default.existsSync(versionFilePath)) {
throw new Error(`The specified python version file at: ${versionFilePath} does not exist`);
versionFile = versionFile || '.python-version';
if (!fs_1.default.existsSync(versionFile)) {
throw new Error(`The specified python version file at: ${versionFile} does not exist`);
}
version = fs_1.default.readFileSync(versionFilePath, 'utf8');
version = fs_1.default.readFileSync(versionFile, 'utf8');
core.info(`Resolved ${versionFile} as ${version}`);
return version;
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions src/setup-python.ts
Expand Up @@ -24,7 +24,7 @@ async function cacheDependencies(cache: string, pythonVersion: string) {

function resolveVersionInput(): string {
let version = core.getInput('python-version');
const versionFile = core.getInput('python-version-file');
let versionFile = core.getInput('python-version-file');

if (version && versionFile) {
core.warning(
Expand All @@ -36,16 +36,13 @@ function resolveVersionInput(): string {
return version;
}

const versionFilePath = path.join(
process.env.GITHUB_WORKSPACE!,
versionFile || '.python-version'
);
if (!fs.existsSync(versionFilePath)) {
versionFile = versionFile || '.python-version';
if (!fs.existsSync(versionFile)) {
throw new Error(
`The specified python version file at: ${versionFilePath} does not exist`
`The specified python version file at: ${versionFile} does not exist`
);
}
version = fs.readFileSync(versionFilePath, 'utf8');
version = fs.readFileSync(versionFile, 'utf8');
core.info(`Resolved ${versionFile} as ${version}`);

return version;
Expand Down