Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

READY: Fix pre retry command #175

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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