mirror of
https://github.com/actions/setup-python.git
synced 2026-06-20 23:33:35 +03:00
Add RHEL support and include Linux distro in cache keys (#1323)
* Add RHEL support for manifest matching and OS detection * update dist * make cache keys distro-aware and key RHEL by major version * Normalize RHEL OS detection and improve cache key consistency * Refactor OS info retrieval to use getOSInfo and handle null cases for improved reliability
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import * as cache from '@actions/cache';
|
||||
import * as core from '@actions/core';
|
||||
import {getOSInfo, IS_LINUX} from '../utils';
|
||||
import {CACHE_DEPENDENCY_BACKUP_PATH} from './constants';
|
||||
|
||||
export enum State {
|
||||
@@ -22,6 +23,33 @@ abstract class CacheDistributor {
|
||||
}>;
|
||||
protected async handleLoadedCache() {}
|
||||
|
||||
/**
|
||||
* Builds the Linux distro portion of a cache key (e.g. `-26.04-Ubuntu`, `-9-rhel`).
|
||||
* RHEL is keyed by major version since it ships one ABI-stable artifact per major.
|
||||
*/
|
||||
protected async getLinuxInfoKeySegment(): Promise<string> {
|
||||
if (!IS_LINUX) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const osInfo = await getOSInfo();
|
||||
if (!osInfo) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// lsb_release reports RHEL as "RedHatEnterpriseLinux" while /etc/os-release
|
||||
// reports it as "rhel"; normalize both to "rhel" so the key is consistent.
|
||||
const normalizedName = osInfo.osName.toLowerCase();
|
||||
const isRhel =
|
||||
normalizedName === 'rhel' || normalizedName.includes('redhat');
|
||||
const osName = isRhel ? 'rhel' : osInfo.osName;
|
||||
const osVersion = isRhel
|
||||
? osInfo.osVersion.split('.')[0]
|
||||
: osInfo.osVersion;
|
||||
|
||||
return `-${osVersion}-${osName}`;
|
||||
}
|
||||
|
||||
public async restoreCache() {
|
||||
const {primaryKey, restoreKey} = await this.computeKeys();
|
||||
if (primaryKey.endsWith('-')) {
|
||||
|
||||
Reference in New Issue
Block a user