8000 Add linux os release info to primary key by panticmilos · Pull Request #467 · actions/setup-python · GitHub
[go: up one dir, main page]

Skip to content

Add linux os release info to primary key #467

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

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove console logs and debug version
  • Loading branch information
panticmilos committed Jul 18, 2022
commit 6e46140c9c36e79b1d020f4d50a3b42dd17cfcf6
9 changes: 3 additions & 6 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64433,13 +64433,11 @@ class PipCache extends cache_distributor_1.default {
let primaryKey = '';
let restoreKey = '';
if (utils_1.IS_LINUX) {
console.log('here');
const osRelease = yield utils_1.getLinuxOSReleaseInfo();
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}`;
}
else {
console.log('here2');
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}`;
}
Expand Down Expand Up @@ -65486,19 +65484,18 @@ function isCacheFeatureAvailable() {
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
function getLinuxOSReleaseInfo() {
return __awaiter(this, void 0, void 0, function* () {
const versionId = yield exec.getExecOutput('lsb_release', ['-a'], {
const { stdout, stderr, exitCode } = yield exec.getExecOutput('lsb_release', ['-a'], {
silent: true
});
let osVersion = '';
let osRelease = '';
versionId.stdout.split('\n').forEach(elem => {
stdout.split('\n').forEach(elem => {
if (elem.includes('Distributor'))
osVersion = elem.split(':')[1].trim();
if (elem.includes('Release'))
osRelease = elem.split(':')[1].trim();
});
core.info(osRelease);
core.info(osVersion);
core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`);
return `${osVersion}-${osRelease}`;
});
}
Expand Down
2 changes: 0 additions & 2 deletions src/cache-distributions/pip-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ class PipCache extends CacheDistributor {
let restoreKey = '';

if (IS_LINUX) {
console.log('here');
const osRelease = await getLinuxOSReleaseInfo();
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}`;
} else {
console.log('here2');
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}`;
}
Expand Down
17 changes: 11 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
}

export async function getLinuxOSReleaseInfo() {
const versionId = await exec.getExecOutput('lsb_release', ['-a'], {
silent: true
});
const {stdout, stderr, exitCode} = await exec.getExecOutput(
'lsb_release',
['-a'],
{
silent: true
}
);

let osVersion = '';
let osRelease = '';

versionId.stdout.split('\n').forEach(elem => {
stdout.split('\n').forEach(elem => {
if (elem.includes('Distributor')) osVersion = elem.split(':')[1].trim();
if (elem.includes('Release')) osRelease = elem.split(':')[1].trim();
});

core.info(osRelease);
core.info(osVersion);
core.debug(`OS Release: ${osRelease}, Version: ${osVersion}`);

return `${osVersion}-${osRelease}`;
}
0