mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 07:22:14 +00:00
Add Linux version and release to primary key
This commit is contained in:
parent
c474c82340
commit
655506db87
5 changed files with 111 additions and 14 deletions
66
dist/setup/index.js
vendored
66
dist/setup/index.js
vendored
|
@ -64430,8 +64430,17 @@ class PipCache extends cache_distributor_1.default {
|
||||||
computeKeys() {
|
computeKeys() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const hash = yield glob.hashFiles(this.cacheDependencyPath);
|
const hash = yield glob.hashFiles(this.cacheDependencyPath);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
let primaryKey = '';
|
||||||
const restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`;
|
let restoreKey = '';
|
||||||
|
if (utils_1.IS_LINUX) {
|
||||||
|
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 {
|
||||||
|
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}`;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
restoreKey: [restoreKey]
|
restoreKey: [restoreKey]
|
||||||
|
@ -64486,6 +64495,7 @@ const os = __importStar(__nccwpck_require__(2037));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const cache_distributor_1 = __importDefault(__nccwpck_require__(8953));
|
const cache_distributor_1 = __importDefault(__nccwpck_require__(8953));
|
||||||
|
const utils_1 = __nccwpck_require__(1314);
|
||||||
class PipenvCache extends cache_distributor_1.default {
|
class PipenvCache extends cache_distributor_1.default {
|
||||||
constructor(pythonVersion, patterns = '**/Pipfile.lock') {
|
constructor(pythonVersion, patterns = '**/Pipfile.lock') {
|
||||||
super('pipenv', patterns);
|
super('pipenv', patterns);
|
||||||
|
@ -64511,9 +64521,16 @@ class PipenvCache extends cache_distributor_1.default {
|
||||||
}
|
}
|
||||||
computeKeys() {
|
computeKeys() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const hash = yield glob.hashFiles(this.patterns);
|
const hash = yield glob.hashFiles(this.cacheDependencyPath);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
let primaryKey = '';
|
||||||
const restoreKey = undefined;
|
const restoreKey = undefined;
|
||||||
|
if (utils_1.IS_LINUX) {
|
||||||
|
const osRelease = yield utils_1.getLinuxOSReleaseInfo();
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
restoreKey
|
restoreKey
|
||||||
|
@ -64567,6 +64584,7 @@ const glob = __importStar(__nccwpck_require__(8090));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
const cache_distributor_1 = __importDefault(__nccwpck_require__(8953));
|
const cache_distributor_1 = __importDefault(__nccwpck_require__(8953));
|
||||||
|
const utils_1 = __nccwpck_require__(1314);
|
||||||
class PoetryCache extends cache_distributor_1.default {
|
class PoetryCache extends cache_distributor_1.default {
|
||||||
constructor(pythonVersion, patterns = '**/poetry.lock') {
|
constructor(pythonVersion, patterns = '**/poetry.lock') {
|
||||||
super('poetry', patterns);
|
super('poetry', patterns);
|
||||||
|
@ -64587,8 +64605,15 @@ class PoetryCache extends cache_distributor_1.default {
|
||||||
}
|
}
|
||||||
computeKeys() {
|
computeKeys() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const hash = yield glob.hashFiles(this.patterns);
|
const hash = yield glob.hashFiles(this.cacheDependencyPath);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
let primaryKey = '';
|
||||||
|
if (utils_1.IS_LINUX) {
|
||||||
|
const osRelease = yield utils_1.getLinuxOSReleaseInfo();
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
}
|
||||||
const restoreKey = undefined;
|
const restoreKey = undefined;
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
|
@ -65354,16 +65379,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0;
|
exports.getLinuxOSReleaseInfo = exports.isCacheFeatureAvailable = exports.isGhes = exports.validatePythonVersionFormatForPyPy = exports.writeExactPyPyVersionFile = exports.readExactPyPyVersionFile = exports.getPyPyVersionFromPath = exports.isNightlyKeyword = exports.validateVersion = exports.createSymlinkInFolder = exports.WINDOWS_PLATFORMS = exports.WINDOWS_ARCHS = exports.IS_LINUX = exports.IS_WINDOWS = void 0;
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const semver = __importStar(__nccwpck_require__(1383));
|
const semver = __importStar(__nccwpck_require__(1383));
|
||||||
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
exports.IS_WINDOWS = process.platform === 'win32';
|
exports.IS_WINDOWS = process.platform === 'win32';
|
||||||
exports.IS_LINUX = process.platform === 'linux';
|
exports.IS_LINUX = process.platform === 'linux';
|
||||||
exports.WINDOWS_ARCHS = ['x86', 'x64'];
|
exports.WINDOWS_ARCHS = ['x86', 'x64'];
|
||||||
|
@ -65447,6 +65482,23 @@ function isCacheFeatureAvailable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
|
function getLinuxOSReleaseInfo() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const versionId = yield exec.getExecOutput('lsb_release', ['-a']);
|
||||||
|
let osVersion = '';
|
||||||
|
let osRelease = '';
|
||||||
|
versionId.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);
|
||||||
|
return `${osVersion}-${osRelease}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getLinuxOSReleaseInfo = getLinuxOSReleaseInfo;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
|
@ -7,7 +7,7 @@ import * as path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
import CacheDistributor from './cache-distributor';
|
import CacheDistributor from './cache-distributor';
|
||||||
import {IS_WINDOWS} from '../utils';
|
import {getLinuxOSReleaseInfo, IS_LINUX, IS_WINDOWS} from '../utils';
|
||||||
|
|
||||||
class PipCache extends CacheDistributor {
|
class PipCache extends CacheDistributor {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -57,8 +57,17 @@ class PipCache extends CacheDistributor {
|
||||||
|
|
||||||
protected async computeKeys() {
|
protected async computeKeys() {
|
||||||
const hash = await glob.hashFiles(this.cacheDependencyPath);
|
const hash = await glob.hashFiles(this.cacheDependencyPath);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
let primaryKey = '';
|
||||||
const restoreKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}`;
|
let restoreKey = '';
|
||||||
|
|
||||||
|
if (IS_LINUX) {
|
||||||
|
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 {
|
||||||
|
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}`;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as path from 'path';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
|
||||||
import CacheDistributor from './cache-distributor';
|
import CacheDistributor from './cache-distributor';
|
||||||
|
import {getLinuxOSReleaseInfo, IS_LINUX} from '../utils';
|
||||||
|
|
||||||
class PipenvCache extends CacheDistributor {
|
class PipenvCache extends CacheDistributor {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -31,9 +32,17 @@ class PipenvCache extends CacheDistributor {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async computeKeys() {
|
protected async computeKeys() {
|
||||||
const hash = await glob.hashFiles(this.patterns);
|
const hash = await glob.hashFiles(this.cacheDependencyPath);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
let primaryKey = '';
|
||||||
const restoreKey = undefined;
|
const restoreKey = undefined;
|
||||||
|
|
||||||
|
if (IS_LINUX) {
|
||||||
|
const osRelease = await getLinuxOSReleaseInfo();
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
} else {
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
restoreKey
|
restoreKey
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as path from 'path';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
import CacheDistributor from './cache-distributor';
|
import CacheDistributor from './cache-distributor';
|
||||||
|
import {getLinuxOSReleaseInfo, IS_LINUX} from '../utils';
|
||||||
|
|
||||||
class PoetryCache extends CacheDistributor {
|
class PoetryCache extends CacheDistributor {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -32,9 +33,19 @@ class PoetryCache extends CacheDistributor {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async computeKeys() {
|
protected async computeKeys() {
|
||||||
const hash = await glob.hashFiles(this.patterns);
|
const hash = await glob.hashFiles(this.cacheDependencyPath);
|
||||||
const primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
|
||||||
|
let primaryKey = '';
|
||||||
|
|
||||||
|
if (IS_LINUX) {
|
||||||
|
const osRelease = await getLinuxOSReleaseInfo();
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${osRelease}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
} else {
|
||||||
|
primaryKey = `${this.CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-python-${this.pythonVersion}-${this.packageManager}-${hash}`;
|
||||||
|
}
|
||||||
|
|
||||||
const restoreKey = undefined;
|
const restoreKey = undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
primaryKey,
|
primaryKey,
|
||||||
restoreKey
|
restoreKey
|
||||||
|
|
16
src/utils.ts
16
src/utils.ts
|
@ -3,6 +3,7 @@ import * as core from '@actions/core';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
|
||||||
export const IS_WINDOWS = process.platform === 'win32';
|
export const IS_WINDOWS = process.platform === 'win32';
|
||||||
export const IS_LINUX = process.platform === 'linux';
|
export const IS_LINUX = process.platform === 'linux';
|
||||||
|
@ -119,3 +120,18 @@ export function isCacheFeatureAvailable(): boolean {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getLinuxOSReleaseInfo() {
|
||||||
|
const versionId = await exec.getExecOutput('lsb_release', ['-a']);
|
||||||
|
let osVersion = '';
|
||||||
|
let osRelease = '';
|
||||||
|
|
||||||
|
versionId.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);
|
||||||
|
return `${osVersion}-${osRelease}`;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue