-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from dmvict/js_action
READY: Add pre retry command
- Loading branch information
Showing
5 changed files
with
169 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...d/Release/.deps/home/work/Temp/wretry.action/node_modules/wdeasync/Release/deasync.node.d
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -885,6 +885,93 @@ function retryWithOptionRetryCondition( test ) | |
|
||
// | ||
|
||
function retryWithOptionPreRetryCommand( test ) | ||
{ | ||
const context = this; | ||
const a = test.assetFor( false ); | ||
const actionPath = a.abs( '_action/actions/wretry.action/v1' ); | ||
const testAction = 'dmvict/[email protected]'; | ||
const execPath = `node ${ a.path.nativize( a.abs( actionPath, 'src/Main.js' ) ) }`; | ||
const isTestContainer = _.process.insideTestContainer(); | ||
|
||
/* - */ | ||
|
||
a.ready.then( () => | ||
{ | ||
test.case = 'enought attempts, executing command between retries'; | ||
core.exportVariable( `INPUT_ACTION`, testAction ); | ||
core.exportVariable( `INPUT_WITH`, 'value : 0' ); | ||
core.exportVariable( `INPUT_ATTEMPT_LIMIT`, '4' ); | ||
core.exportVariable( `INPUT_PRE_RETRY_COMMAND`, 'echo "Executing pre_retry_command"' ); | ||
return null; | ||
}); | ||
|
||
actionSetup(); | ||
|
||
a.shellNonThrowing({ currentPath : actionPath, execPath }); | ||
a.ready.then( ( op ) => | ||
{ | ||
test.identical( op.exitCode, 0 ); | ||
if( !isTestContainer ) | ||
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, /::error::.*Process returned exit code/ ), 0 ); | ||
test.identical( _.strCount( op.output, 'Success' ), 1 ); | ||
test.identical( _.strCount( op.output, 'Executing pre_retry_command' ), 4 ); | ||
return null; | ||
}); | ||
|
||
/* */ | ||
|
||
a.ready.then( () => | ||
{ | ||
test.case = 'command between retries trows error, interrupting execution'; | ||
core.exportVariable( `INPUT_ACTION`, testAction ); | ||
core.exportVariable( `INPUT_WITH`, 'value : 0' ); | ||
core.exportVariable( `INPUT_ATTEMPT_LIMIT`, '4' ); | ||
core.exportVariable( `INPUT_PRE_RETRY_COMMAND`, 'exit 1' ); | ||
return null; | ||
}); | ||
|
||
actionSetup(); | ||
|
||
a.shellNonThrowing({ currentPath : actionPath, execPath }); | ||
a.ready.then( ( op ) => | ||
{ | ||
test.notIdentical( op.exitCode, 0 ); | ||
if( !isTestContainer ) | ||
test.ge( _.strCount( op.output, '::set-env' ), 2 ); | ||
test.identical( _.strCount( op.output, '::error::Wrong attempt' ), 1 ); | ||
test.identical( _.strCount( op.output, /::error::undefined.*Attempts exhausted, made 4 attempts/ ), 0 ); | ||
test.identical( _.strCount( op.output, /::error::.*Process returned exit code/ ), 1 ); | ||
test.identical( _.strCount( op.output, 'Success' ), 0 ); | ||
return null; | ||
}); | ||
|
||
a.ready.finally( () => | ||
{ | ||
delete process.env.INPUT_PRE_RETRY_COMMAND; | ||
return null; | ||
}); | ||
|
||
/* - */ | ||
|
||
return a.ready; | ||
|
||
/* */ | ||
|
||
function actionSetup() | ||
{ | ||
a.ready.then( () => { a.fileProvider.filesDelete( a.abs( '.' ) ); return null; } ); | ||
a.ready.then( () => { a.fileProvider.dirMake( actionPath ); return null; } ); | ||
a.shell( `git clone ${ a.path.nativize( context.actionDirPath ) } ${ a.path.nativize( actionPath ) }` ); | ||
return a.ready; | ||
} | ||
} | ||
|
||
// | ||
|
||
function retryWithExternalActionOnLocal( test ) | ||
{ | ||
const context = this; | ||
|
@@ -1869,6 +1956,7 @@ const Proto = | |
retryWithOptionAttemptLimit, | ||
retryWithOptionAttemptDelay, | ||
retryWithOptionRetryCondition, | ||
retryWithOptionPreRetryCommand, | ||
|
||
retryWithExternalActionOnLocal, | ||
retryWithExternalActionOnRemote, | ||
|