Skip to content

Commit

Permalink
Merge pull request #175 from dmvict/fix_pre_retry_command
Browse files Browse the repository at this point in the history
READY: Fix pre retry command
  • Loading branch information
dmvict authored Nov 6, 2024
2 parents 3f9af41 + def8dc6 commit 1b18cb0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/Retry.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const _ = wTools;
function retry( scriptType )
{
let shouldRetry = core.getInput( 'retry_condition' ) || true;
let isRetry = false;
const actionName = core.getInput( 'action' );
const command = core.getMultilineInput( 'command' );
const preRetryCommand = core.getMultilineInput( 'pre_retry_command' );
Expand Down Expand Up @@ -167,7 +168,7 @@ function retry( scriptType )
if( process.env.GITHUB_OUTPUT && _.fileProvider.fileExists( process.env.GITHUB_OUTPUT ) )
_.fileProvider.fileWrite( process.env.GITHUB_OUTPUT, '' );

if( preRetryCommand.length > 0 )
if( isRetry && preRetryCommand.length > 0 )
{
const o =
{
Expand Down Expand Up @@ -230,6 +231,8 @@ function retry( scriptType )
{
_.error.attend( err );

isRetry = true;

if( _.bool.is( shouldRetry ) )
return shouldRetry;
return !!common.evaluateExpression( shouldRetry );
Expand Down
4 changes: 2 additions & 2 deletions test/Action.test.s
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ function retryWithOptionPreRetryCommand( test )
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 );
test.identical( _.strCount( op.output, 'Executing pre_retry_command' ), 3 );
return null;
});

Expand All @@ -942,7 +942,7 @@ function retryWithOptionPreRetryCommand( test )
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::Wrong attempt' ), 2 );
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 );
Expand Down
2 changes: 1 addition & 1 deletion test/Command.test.s
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function retryWithOptionPreRetryCommand( test )
test.notIdentical( op.exitCode, 0 );
test.identical( _.strCount( op.output, '::error::Please, specify Github action name' ), 0 );
test.identical( _.strCount( op.output, 'Attempts exhausted, made 4 attempts' ), 1 );
test.identical( _.strCount( op.output, 'Executing pre_retry_command' ), 4 );
test.identical( _.strCount( op.output, 'Executing pre_retry_command' ), 3 );
return null;
});

Expand Down

0 comments on commit 1b18cb0

Please sign in to comment.