@ -3151,6 +3151,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
var _ _asyncValues = ( this && this . _ _asyncValues ) || function ( o ) {
if ( ! Symbol . asyncIterator ) throw new TypeError ( "Symbol.asyncIterator is not defined." ) ;
var m = o [ Symbol . asyncIterator ] , i ;
return m ? m . call ( o ) : ( o = typeof _ _values === "function" ? _ _values ( o ) : o [ Symbol . iterator ] ( ) , i = { } , verb ( "next" ) , verb ( "throw" ) , verb ( "return" ) , i [ Symbol . asyncIterator ] = function ( ) { return this ; } , i ) ;
function verb ( n ) { i [ n ] = o [ n ] && function ( v ) { return new Promise ( function ( resolve , reject ) { v = o [ n ] ( v ) , settle ( resolve , reject , v . done , v . value ) ; } ) ; } ; }
function settle ( resolve , reject , d , v ) { Promise . resolve ( v ) . then ( function ( v ) { resolve ( { value : v , done : d } ) ; } , reject ) ; }
} ;
var _ _importStar = ( this && this . _ _importStar ) || function ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
@ -3233,19 +3240,35 @@ function logWarning(message) {
core . info ( ` ${ warningPrefix } ${ message } ` ) ;
}
exports . logWarning = logWarning ;
function expandPaths ( patterns ) {
var _a ;
function resolvePaths ( patterns ) {
var e _1 , _a ;
var _b ;
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const paths = [ ] ;
const workspace = ( _a = process . env [ "GITHUB_WORKSPACE" ] , ( _a !== null && _a !== void 0 ? _a : process . cwd ( ) ) ) ;
const globber = yield glob . create ( patterns . join ( "\n" ) ) ;
const files = yield globber . glob ( ) ;
paths . push ( ... files ) ;
// Convert paths to relative paths here?
return paths . map ( x => path . relative ( workspace , x ) ) ;
const workspace = ( _b = process . env [ "GITHUB_WORKSPACE" ] , ( _b !== null && _b !== void 0 ? _b : process . cwd ( ) ) ) ;
const globber = yield glob . create ( patterns . join ( "\n" ) , {
implicitDescendants : false
} ) ;
try {
for ( var _c = _ _asyncValues ( globber . globGenerator ( ) ) , _d ; _d = yield _c . next ( ) , ! _d . done ; ) {
const file = _d . value ;
const relativeFile = path . relative ( workspace , file ) ;
core . debug ( ` Matched: ${ relativeFile } ` ) ;
// Paths are made relative so the tar entries are all relative to the root of the workspace.
paths . push ( ` ${ relativeFile } ` ) ;
}
}
catch ( e _1 _1 ) { e _1 = { error : e _1 _1 } ; }
finally {
try {
if ( _d && ! _d . done && ( _a = _c . return ) ) yield _a . call ( _c ) ;
}
finally { if ( e _1 ) throw e _1 . error ; }
}
return paths ;
} ) ;
}
exports . expandPaths = expandPaths ;
exports . resolv ePaths = resolv ePaths;
function getSupportedEvents ( ) {
return [ constants _1 . Events . Push , constants _1 . Events . PullRequest ] ;
}
@ -4449,15 +4472,16 @@ function run() {
return ;
}
core . debug ( ` Cache ID: ${ cacheId } ` ) ;
const cachePaths = yield utils . expand Paths( core
const cachePaths = yield utils . resolv ePaths( core
. getInput ( constants _1 . Inputs . Path )
. split ( "\n" )
. filter ( x => x !== "" ) ) ;
core . debug ( "Cache Paths:" ) ;
core . debug ( ` ${ JSON . stringify ( cachePaths ) } ` ) ;
const archivePath = path . join ( yield utils . createTempDirectory ( ) , "cache.tgz" ) ;
const archiveFolder = yield utils . createTempDirectory ( ) ;
const archivePath = path . join ( archiveFolder , constants _1 . CacheFilename ) ;
core . debug ( ` Archive Path: ${ archivePath } ` ) ;
yield tar _1 . createTar ( archive Path , cachePaths ) ;
yield tar _1 . createTar ( archive Folder , cachePaths ) ;
const fileSizeLimit = 5 * 1024 * 1024 * 1024 ; // 5GB per repo limit
const archiveFileSize = utils . getArchiveFileSize ( archivePath ) ;
core . debug ( ` File Size: ${ archiveFileSize } ` ) ;
@ -4506,6 +4530,7 @@ var Events;
Events [ "Push" ] = "push" ;
Events [ "PullRequest" ] = "pull_request" ;
} ) ( Events = exports . Events || ( exports . Events = { } ) ) ;
exports . CacheFilename = "cache.tgz" ;
/***/ } ) ,
@ -4888,8 +4913,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result ;
} ;
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
const exec _1 = _ _webpack _require _ _ ( 986 ) ;
const io = _ _importStar ( _ _webpack _require _ _ ( 1 ) ) ;
const path = _ _importStar ( _ _webpack _require _ _ ( 622 ) ) ;
const constants _1 = _ _webpack _require _ _ ( 694 ) ;
const exec _1 = _ _webpack _require _ _ ( 986 ) ;
const fs _1 = _ _webpack _require _ _ ( 747 ) ;
function getTarPath ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
@ -4904,13 +4931,14 @@ function getTarPath() {
return yield io . which ( "tar" , true ) ;
} ) ;
}
function execTar ( args ) {
function execTar ( args , cwd ) {
var _a , _b ;
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
try {
yield exec _1 . exec ( ` " ${ yield getTarPath ( ) } " ` , args );
yield exec _1 . exec ( ` " ${ yield getTarPath ( ) } " ` , args , { cwd : cwd } );
}
catch ( error ) {
console . log ( "error" , error ) ;
const IS _WINDOWS = process . platform === "win32" ;
if ( IS _WINDOWS ) {
throw new Error ( ` Tar failed with error: ${ ( _a = error ) === null || _a === void 0 ? void 0 : _a . message } . Ensure BSD tar is installed and on the PATH. ` ) ;
@ -4933,19 +4961,22 @@ function extractTar(archivePath) {
} ) ;
}
exports . extractTar = extractTar ;
function createTar ( archive Path , sourceDirectories ) {
function createTar ( archive Folder , sourceDirectories ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
// TODO: will want to stream sourceDirectories into tar
const manifestFilename = "manifest.txt" ;
fs _1 . writeFileSync ( path . join ( archiveFolder , manifestFilename ) , sourceDirectories . join ( "\n" ) ) ;
const workingDirectory = getWorkingDirectory ( ) ;
const args = [
"-cz" ,
"-f" ,
archivePath ,
constants_1 . CacheFilename ,
"-C" ,
workingDirectory ,
sourceDirectories . join ( " " )
"--files-from" ,
manifestFilename
] ;
yield execTar ( args );
yield execTar ( args , archiveFolder );
} ) ;
}
exports . createTar = createTar ;