diff --git a/src/Retry.js b/src/Retry.js index 0568135f..934962a1 100644 --- a/src/Retry.js +++ b/src/Retry.js @@ -67,13 +67,23 @@ function retry( scriptType ) process.env.RETRY_ACTION = actionName; const token = core.getInput( 'github_token' ); - const remoteActionPath = common.remotePathForm( actionName, token ); - const localActionDir = _.path.nativize( _.path.join( __dirname, '../../../', remoteActionPath.repo ) ); + const localIs = actionName.startsWith( './' ); + + let remoteActionPath = null; + if( !localIs ) + remoteActionPath = common.remotePathForm( actionName, token ); + + const localActionDir = localIs ? + _.path.nativize( _.path.join( process.env.GITHUB_WORKSPACE, actionName ) ) : + _.path.nativize( _.path.join( __dirname, '../../../', remoteActionPath.repo ) ); + + if( !localIs ) con.then( () => common.actionClone( localActionDir, remoteActionPath ) ); + con.then( () => { - const actionFileDir = _.path.nativize( _.path.join( localActionDir, remoteActionPath.localVcsPath ) ); + const actionFileDir = localIs ? localActionDir : _.path.nativize( _.path.join( localActionDir, remoteActionPath.localVcsPath ) ); const config = common.actionConfigRead( actionFileDir ); if( common.shouldExit( config, scriptType ) ) diff --git a/test/Action.test.s b/test/Action.test.s index 699f3867..f3fcebaa 100644 --- a/test/Action.test.s +++ b/test/Action.test.s @@ -203,6 +203,74 @@ function retryWithActionAndCommand( test ) // +function retryLocalAction( test ) +{ + const context = this; + const a = test.assetFor( false ); + const actionPath = a.abs( '_action/actions/wretry.action/v1' ); + const execPath = `node ${ a.path.nativize( a.abs( actionPath, 'src/Main.js' ) ) }`; + + const repoWithWorkflowDir = a.abs( 'test.action' ); + const localActionRepo = 'https://github.com/dmvict/test.action.git'; + const testAction = './.github/actions'; + + /* - */ + + a.ready.then( () => + { + test.case = 'enought attempts'; + core.exportVariable( `INPUT_ACTION`, testAction ); + core.exportVariable( `INPUT_WITH`, 'value : 0' ); + core.exportVariable( `INPUT_ATTEMPT_LIMIT`, '4' ); + core.exportVariable( `GITHUB_WORKSPACE`, repoWithWorkflowDir ); + return null; + }); + + actionSetup(); + + a.shellNonThrowing({ currentPath : actionPath, execPath }); + a.ready.then( ( op ) => + { + test.identical( op.exitCode, 0 ); + if( !_.process.insideTestContainer() ) + test.ge( _.strCount( op.output, '::set-env' ), 3 ); + test.identical( _.strCount( op.output, '::error::Wrong attempt' ), 3 ); + test.identical( _.strCount( op.output, /::error::undefined.*Attempts exhausted, made 4 attempts/ ), 0 ); + test.identical( _.strCount( op.output, 'Success' ), 1 ); + return null; + }); + + a.ready.finally( () => + { + delete process.env.GITHUB_WORKSPACE; + return null; + }); + + /* - */ + + return a.ready; + + /* */ + + function actionSetup() + { + a.ready.then( () => + { + a.fileProvider.filesDelete( a.abs( '.' ) ); + a.fileProvider.dirMake( actionPath ); + a.fileProvider.dirMake( repoWithWorkflowDir ); + return null; + }); + a.shell( `git clone ${ a.path.nativize( context.actionDirPath ) } ${ a.path.nativize( actionPath ) }` ); + a.shell( `git clone ${ localActionRepo } ${ a.path.nativize( repoWithWorkflowDir ) }` ); + a.shell({ currentPath : repoWithWorkflowDir, execPath : 'git checkout local_action' }); + a.shell( `node ${ a.path.nativize( a.abs( actionPath, 'src/Pre.js' ) ) }` ); + return a.ready; + } +} + +// + function retryFetchActionWithoutTagOrHash( test ) { const context = this; @@ -1946,6 +2014,7 @@ const Proto = retryWithUnsupportedAction, retryWithActionAndCommand, + retryLocalAction, retryFetchActionWithoutTagOrHash, retryFetchActionWithTag, retryFetchActionWithHash,