@ -107854,6 +107854,7 @@ const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awa
}
}
core . saveState ( constants _1 . State . CacheMatchedKey , cacheKey ) ;
core . saveState ( constants _1 . State . CacheMatchedKey , cacheKey ) ;
core . info ( ` Cache restored from key: ${ cacheKey } ` ) ;
core . info ( ` Cache restored from key: ${ cacheKey } ` ) ;
( 0 , cache _utils _1 . logCacheSizes ) ( cachePaths ) ;
if ( cachePaths . length > 1 ) {
if ( cachePaths . length > 1 ) {
const buildHash = ( 0 , hashdir _1 . computeMetaHash ) ( [ cachePaths [ 1 ] ] ) ;
const buildHash = ( 0 , hashdir _1 . computeMetaHash ) ( [ cachePaths [ 1 ] ] ) ;
core . debug ( ` build hash is ${ buildHash } ` ) ;
core . debug ( ` build hash is ${ buildHash } ` ) ;
@ -107912,11 +107913,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ) ;
} ;
} ;
var _ _importDefault = ( this && this . _ _importDefault ) || function ( 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 . getCacheDirectoryPath = exports . getPackageManagerInfo = exports . getCommandOutput = void 0 ;
exports . isCacheFeatureAvailable = exports . isGhes = exports . logCacheSizes = exports . getCacheDirectoryPath = exports . getPackageManagerInfo = exports . getCommandOutput = void 0 ;
const cache = _ _importStar ( _ _nccwpck _require _ _ ( 27799 ) ) ;
const cache = _ _importStar ( _ _nccwpck _require _ _ ( 27799 ) ) ;
const core = _ _importStar ( _ _nccwpck _require _ _ ( 42186 ) ) ;
const core = _ _importStar ( _ _nccwpck _require _ _ ( 42186 ) ) ;
const exec = _ _importStar ( _ _nccwpck _require _ _ ( 71514 ) ) ;
const exec = _ _importStar ( _ _nccwpck _require _ _ ( 71514 ) ) ;
const fs _1 = _ _importDefault ( _ _nccwpck _require _ _ ( 57147 ) ) ;
const path _1 = _ _importDefault ( _ _nccwpck _require _ _ ( 71017 ) ) ;
const package _managers _1 = _ _nccwpck _require _ _ ( 96663 ) ;
const package _managers _1 = _ _nccwpck _require _ _ ( 96663 ) ;
const getCommandOutput = ( toolCommand ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
const getCommandOutput = ( toolCommand ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
let { stdout , stderr , exitCode } = yield exec . getExecOutput ( toolCommand , undefined , { ignoreReturnCode : true } ) ;
let { stdout , stderr , exitCode } = yield exec . getExecOutput ( toolCommand , undefined , { ignoreReturnCode : true } ) ;
@ -107958,6 +107964,44 @@ const getCacheDirectoryPath = (packageManagerInfo_1, ...args_1) => __awaiter(voi
return cachePaths ;
return cachePaths ;
} ) ;
} ) ;
exports . getCacheDirectoryPath = getCacheDirectoryPath ;
exports . getCacheDirectoryPath = getCacheDirectoryPath ;
function getDirSizeBytes ( dirPath ) {
if ( ! fs _1 . default . existsSync ( dirPath ) )
return 0 ;
const stat = fs _1 . default . statSync ( dirPath ) ;
if ( ! stat . isDirectory ( ) )
return stat . size ;
let total = 0 ;
for ( const entry of fs _1 . default . readdirSync ( dirPath , { withFileTypes : true } ) ) {
const entryPath = path _1 . default . join ( dirPath , entry . name ) ;
if ( entry . isDirectory ( ) ) {
total += getDirSizeBytes ( entryPath ) ;
}
else {
total += fs _1 . default . statSync ( entryPath ) . size ;
}
}
return total ;
}
function formatSize ( bytes ) {
if ( bytes < 1024 )
return ` ${ bytes } B ` ;
if ( bytes < 1024 * 1024 )
return ` ${ ( bytes / 1024 ) . toFixed ( 1 ) } KB ` ;
if ( bytes < 1024 * 1024 * 1024 )
return ` ${ ( bytes / ( 1024 * 1024 ) ) . toFixed ( 1 ) } MB ` ;
return ` ${ ( bytes / ( 1024 * 1024 * 1024 ) ) . toFixed ( 2 ) } GB ` ;
}
function logCacheSizes ( cachePaths ) {
const labels = [ 'GOMODCACHE' , 'GOCACHE' ] ;
let total = 0 ;
for ( let i = 0 ; i < cachePaths . length ; i ++ ) {
const size = getDirSizeBytes ( cachePaths [ i ] ) ;
total += size ;
core . info ( ` Cache size ${ labels [ i ] || cachePaths [ i ] } : ${ formatSize ( size ) } ` ) ;
}
core . info ( ` Cache size total: ${ formatSize ( total ) } ` ) ;
}
exports . logCacheSizes = logCacheSizes ;
function isGhes ( ) {
function isGhes ( ) {
const ghUrl = new URL ( process . env [ 'GITHUB_SERVER_URL' ] || 'https://github.com' ) ;
const ghUrl = new URL ( process . env [ 'GITHUB_SERVER_URL' ] || 'https://github.com' ) ;
const hostname = ghUrl . hostname . trimEnd ( ) . toUpperCase ( ) ;
const hostname = ghUrl . hostname . trimEnd ( ) . toUpperCase ( ) ;