@ -3432,6 +3432,7 @@ function getCacheEntry(keys, paths, options) {
const resource = ` cache?keys= ${ encodeURIComponent ( keys . join ( ',' ) ) } &version= ${ version } ` ;
const resource = ` cache?keys= ${ encodeURIComponent ( keys . join ( ',' ) ) } &version= ${ version } ` ;
const response = yield requestUtils _1 . retryTypedResponse ( 'getCacheEntry' , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) { return httpClient . getJson ( getCacheApiUrl ( resource ) ) ; } ) ) ;
const response = yield requestUtils _1 . retryTypedResponse ( 'getCacheEntry' , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) { return httpClient . getJson ( getCacheApiUrl ( resource ) ) ; } ) ) ;
if ( response . statusCode === 204 ) {
if ( response . statusCode === 204 ) {
// Cache not found
return null ;
return null ;
}
}
if ( ! requestUtils _1 . isSuccessStatusCode ( response . statusCode ) ) {
if ( ! requestUtils _1 . isSuccessStatusCode ( response . statusCode ) ) {
@ -3440,6 +3441,7 @@ function getCacheEntry(keys, paths, options) {
const cacheResult = response . result ;
const cacheResult = response . result ;
const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult . archiveLocation ;
const cacheDownloadUrl = cacheResult === null || cacheResult === void 0 ? void 0 : cacheResult . archiveLocation ;
if ( ! cacheDownloadUrl ) {
if ( ! cacheDownloadUrl ) {
// Cache achiveLocation not found. This should never happen, and hence bail out.
throw new Error ( 'Cache not found.' ) ;
throw new Error ( 'Cache not found.' ) ;
}
}
core . setSecret ( cacheDownloadUrl ) ;
core . setSecret ( cacheDownloadUrl ) ;
@ -10045,7 +10047,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result ;
return result ;
} ;
} ;
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
exports . isCacheFeatureAvailable = exports . getInputAsInt = exports . getInputAsArray = exports . isValidEvent = exports . logWarning = exports . setCacheHitOutput = exports . isExactKeyMatch = exports . isGhes = void 0 ;
exports . isCacheFeatureAvailable = exports . getInputAsInt = exports . getInputAsArray = exports . isValidEvent = exports . logWarning = exports . isExactKeyMatch = exports . isGhes = void 0 ;
const cache = _ _importStar ( _ _webpack _require _ _ ( 692 ) ) ;
const cache = _ _importStar ( _ _webpack _require _ _ ( 692 ) ) ;
const core = _ _importStar ( _ _webpack _require _ _ ( 470 ) ) ;
const core = _ _importStar ( _ _webpack _require _ _ ( 470 ) ) ;
const constants _1 = _ _webpack _require _ _ ( 196 ) ;
const constants _1 = _ _webpack _require _ _ ( 196 ) ;
@ -10061,10 +10063,6 @@ function isExactKeyMatch(key, cacheKey) {
} ) === 0 ) ;
} ) === 0 ) ;
}
}
exports . isExactKeyMatch = isExactKeyMatch ;
exports . isExactKeyMatch = isExactKeyMatch ;
function setCacheHitOutput ( isCacheHit ) {
core . setOutput ( constants _1 . Outputs . CacheHit , isCacheHit . toString ( ) ) ;
}
exports . setCacheHitOutput = setCacheHitOutput ;
function logWarning ( message ) {
function logWarning ( message ) {
const warningPrefix = "[warning]" ;
const warningPrefix = "[warning]" ;
core . info ( ` ${ warningPrefix } ${ message } ` ) ;
core . info ( ` ${ warningPrefix } ${ message } ` ) ;
@ -38205,7 +38203,7 @@ const path = __importStar(__webpack_require__(622));
const utils = _ _importStar ( _ _webpack _require _ _ ( 15 ) ) ;
const utils = _ _importStar ( _ _webpack _require _ _ ( 15 ) ) ;
const constants _1 = _ _webpack _require _ _ ( 931 ) ;
const constants _1 = _ _webpack _require _ _ ( 931 ) ;
const IS _WINDOWS = process . platform === 'win32' ;
const IS _WINDOWS = process . platform === 'win32' ;
// Function also mutates the args array. For non-mutation call with passing an empty array.
// Returns tar path and type: BSD or GNU
function getTarPath ( ) {
function getTarPath ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
switch ( process . platform ) {
switch ( process . platform ) {
@ -38237,6 +38235,7 @@ function getTarPath() {
default :
default :
break ;
break ;
}
}
// Default assumption is GNU tar is present in path
return {
return {
path : yield io . which ( 'tar' , true ) ,
path : yield io . which ( 'tar' , true ) ,
type : constants _1 . ArchiveToolType . GNU
type : constants _1 . ArchiveToolType . GNU
@ -38250,6 +38249,7 @@ function getTarArgs(tarPath, compressionMethod, type, archivePath = '') {
const cacheFileName = utils . getCacheFileName ( compressionMethod ) ;
const cacheFileName = utils . getCacheFileName ( compressionMethod ) ;
const tarFile = 'cache.tar' ;
const tarFile = 'cache.tar' ;
const workingDirectory = getWorkingDirectory ( ) ;
const workingDirectory = getWorkingDirectory ( ) ;
// Speficic args for BSD tar on windows for workaround
const BSD _TAR _ZSTD = tarPath . type === constants _1 . ArchiveToolType . BSD &&
const BSD _TAR _ZSTD = tarPath . type === constants _1 . ArchiveToolType . BSD &&
compressionMethod !== constants _1 . CompressionMethod . Gzip &&
compressionMethod !== constants _1 . CompressionMethod . Gzip &&
IS _WINDOWS ;
IS _WINDOWS ;
@ -38287,8 +38287,10 @@ function getTarArgs(tarPath, compressionMethod, type, archivePath = '') {
return args ;
return args ;
} ) ;
} ) ;
}
}
function getArgs ( compressionMethod , type , archivePath = '' ) {
// Returns commands to run tar and compression program
function getCommands ( compressionMethod , type , archivePath = '' ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
let args ;
const tarPath = yield getTarPath ( ) ;
const tarPath = yield getTarPath ( ) ;
const tarArgs = yield getTarArgs ( tarPath , compressionMethod , type , archivePath ) ;
const tarArgs = yield getTarArgs ( tarPath , compressionMethod , type , archivePath ) ;
const compressionArgs = type !== 'create'
const compressionArgs = type !== 'create'
@ -38298,11 +38300,15 @@ function getArgs(compressionMethod, type, archivePath = '') {
compressionMethod !== constants _1 . CompressionMethod . Gzip &&
compressionMethod !== constants _1 . CompressionMethod . Gzip &&
IS _WINDOWS ;
IS _WINDOWS ;
if ( BSD _TAR _ZSTD && type !== 'create' ) {
if ( BSD _TAR _ZSTD && type !== 'create' ) {
return [ ... compressionArgs , ... tarArgs ] . join ( ' ' ) ;
args = [ [ ... compressionArgs ] . join ( ' ' ) , [ ... tarArgs ] . join ( ' ' ) ] ;
}
}
else {
else {
return [ ... tarArgs , ... compressionArgs ] . join ( ' ' ) ;
args = [ [ ... tarArgs ] . join ( ' ' ) , [ ... compressionArgs ] . join ( ' ' ) ] ;
}
if ( BSD _TAR _ZSTD ) {
return args ;
}
}
return [ args . join ( ' ' ) ] ;
} ) ;
} ) ;
}
}
function getWorkingDirectory ( ) {
function getWorkingDirectory ( ) {
@ -38325,8 +38331,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
? [
? [
'zstd -d --long=30 -o' ,
'zstd -d --long=30 -o' ,
constants _1 . TarFilename ,
constants _1 . TarFilename ,
archivePath . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' ) ,
archivePath . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' )
'&&'
]
]
: [
: [
'--use-compress-program' ,
'--use-compress-program' ,
@ -38337,8 +38342,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
? [
? [
'zstd -d -o' ,
'zstd -d -o' ,
constants _1 . TarFilename ,
constants _1 . TarFilename ,
archivePath . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' ) ,
archivePath . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' )
'&&'
]
]
: [ '--use-compress-program' , IS _WINDOWS ? '"zstd -d"' : 'unzstd' ] ;
: [ '--use-compress-program' , IS _WINDOWS ? '"zstd -d"' : 'unzstd' ] ;
default :
default :
@ -38346,6 +38350,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) {
}
}
} ) ;
} ) ;
}
}
// Used for creating the archive
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
// zstdmt is equivalent to 'zstd -T0'
// zstdmt is equivalent to 'zstd -T0'
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
@ -38361,7 +38366,6 @@ function getCompressionProgram(tarPath, compressionMethod) {
case constants _1 . CompressionMethod . Zstd :
case constants _1 . CompressionMethod . Zstd :
return BSD _TAR _ZSTD
return BSD _TAR _ZSTD
? [
? [
'&&' ,
'zstd -T0 --long=30 -o' ,
'zstd -T0 --long=30 -o' ,
cacheFileName . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' ) ,
cacheFileName . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' ) ,
constants _1 . TarFilename
constants _1 . TarFilename
@ -38373,7 +38377,6 @@ function getCompressionProgram(tarPath, compressionMethod) {
case constants _1 . CompressionMethod . ZstdWithoutLong :
case constants _1 . CompressionMethod . ZstdWithoutLong :
return BSD _TAR _ZSTD
return BSD _TAR _ZSTD
? [
? [
'&&' ,
'zstd -T0 -o' ,
'zstd -T0 -o' ,
cacheFileName . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' ) ,
cacheFileName . replace ( new RegExp ( ` \\ ${ path . sep } ` , 'g' ) , '/' ) ,
constants _1 . TarFilename
constants _1 . TarFilename
@ -38384,44 +38387,45 @@ function getCompressionProgram(tarPath, compressionMethod) {
}
}
} ) ;
} ) ;
}
}
function listTar ( archivePath , compressionMethod ) {
// Executes all commands as separate processes
function execCommands ( commands , cwd ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const args = yield getArgs ( compressionMethod , 'list' , archivePath ) ;
for ( const command of commands ) {
try {
try {
yield exec _1 . exec ( args ) ;
yield exec _1 . exec ( command , undefined , { cwd } ) ;
}
}
catch ( error ) {
catch ( error ) {
throw new Error ( ` Tar failed with error: ${ error === null || error === void 0 ? void 0 : error . message } ` ) ;
throw new Error ( ` ${ command . split ( ' ' ) [ 0 ] } failed with error: ${ error === null || error === void 0 ? void 0 : error . message } ` ) ;
}
}
}
} ) ;
} ) ;
}
}
// List the contents of a tar
function listTar ( archivePath , compressionMethod ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const commands = yield getCommands ( compressionMethod , 'list' , archivePath ) ;
yield execCommands ( commands ) ;
} ) ;
}
exports . listTar = listTar ;
exports . listTar = listTar ;
// Extract a tar
function extractTar ( archivePath , compressionMethod ) {
function extractTar ( archivePath , compressionMethod ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
// Create directory to extract tar into
// Create directory to extract tar into
const workingDirectory = getWorkingDirectory ( ) ;
const workingDirectory = getWorkingDirectory ( ) ;
yield io . mkdirP ( workingDirectory ) ;
yield io . mkdirP ( workingDirectory ) ;
const args = yield getArgs ( compressionMethod , 'extract' , archivePath ) ;
const commands = yield getCommands ( compressionMethod , 'extract' , archivePath ) ;
try {
yield execCommands ( commands ) ;
yield exec _1 . exec ( args ) ;
}
catch ( error ) {
throw new Error ( ` Tar failed with error: ${ error === null || error === void 0 ? void 0 : error . message } ` ) ;
}
} ) ;
} ) ;
}
}
exports . extractTar = extractTar ;
exports . extractTar = extractTar ;
// Create a tar
function createTar ( archiveFolder , sourceDirectories , compressionMethod ) {
function createTar ( archiveFolder , sourceDirectories , compressionMethod ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
// Write source directories to manifest.txt to avoid command length limits
// Write source directories to manifest.txt to avoid command length limits
fs _1 . writeFileSync ( path . join ( archiveFolder , constants _1 . ManifestFilename ) , sourceDirectories . join ( '\n' ) ) ;
fs _1 . writeFileSync ( path . join ( archiveFolder , constants _1 . ManifestFilename ) , sourceDirectories . join ( '\n' ) ) ;
const args = yield getArgs ( compressionMethod , 'create' ) ;
const commands = yield getCommands ( compressionMethod , 'create' ) ;
try {
yield execCommands ( commands , archiveFolder ) ;
yield exec _1 . exec ( args , undefined , { cwd : archiveFolder } ) ;
}
catch ( error ) {
throw new Error ( ` Tar failed with error: ${ error === null || error === void 0 ? void 0 : error . message } ` ) ;
}
} ) ;
} ) ;
}
}
exports . createTar = createTar ;
exports . createTar = createTar ;
@ -47237,15 +47241,12 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
let compressionMethod = yield utils . getCompressionMethod ( ) ;
let compressionMethod = yield utils . getCompressionMethod ( ) ;
let archivePath = '' ;
let archivePath = '' ;
try {
try {
try {
// path are needed to compute version
// path are needed to compute version
cacheEntry = yield cacheHttpClient . getCacheEntry ( keys , paths , {
cacheEntry = yield cacheHttpClient . getCacheEntry ( keys , paths , {
compressionMethod
compressionMethod
} ) ;
} ) ;
if ( ! ( cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry . archiveLocation ) ) {
}
// This is to support the old cache entry created by gzip on windows.
catch ( error ) {
// This is to support the old cache entry created
// by the old version of the cache action on windows.
if ( process . platform === 'win32' &&
if ( process . platform === 'win32' &&
compressionMethod !== constants _1 . CompressionMethod . Gzip ) {
compressionMethod !== constants _1 . CompressionMethod . Gzip ) {
compressionMethod = constants _1 . CompressionMethod . Gzip ;
compressionMethod = constants _1 . CompressionMethod . Gzip ;
@ -47253,17 +47254,15 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
compressionMethod
compressionMethod
} ) ;
} ) ;
if ( ! ( cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry . archiveLocation ) ) {
if ( ! ( cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry . archiveLocation ) ) {
throw error ;
return undefined ;
}
}
core . debug ( "Couldn't find cache entry with zstd compression, falling back to gzip compression." ) ;
}
}
else {
else {
throw error ;
// Cache not found
return undefined ;
}
}
}
}
if ( ! ( cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry . archiveLocation ) ) {
// Cache not found
return undefined ;
}
archivePath = path . join ( yield utils . createTempDirectory ( ) , utils . getCacheFileName ( compressionMethod ) ) ;
archivePath = path . join ( yield utils . createTempDirectory ( ) , utils . getCacheFileName ( compressionMethod ) ) ;
core . debug ( ` Archive Path: ${ archivePath } ` ) ;
core . debug ( ` Archive Path: ${ archivePath } ` ) ;
// Download the cache from the cache entry
// Download the cache from the cache entry
@ -50459,7 +50458,7 @@ function restoreImpl(stateProvider) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
try {
if ( ! utils . isCacheFeatureAvailable ( ) ) {
if ( ! utils . isCacheFeatureAvailable ( ) ) {
utils. setCacheHitOutput ( false ) ;
core. setOutput ( constants _1 . Outputs . CacheHit , "false" ) ;
return ;
return ;
}
}
// Validate inputs, this can cause task failure
// Validate inputs, this can cause task failure