Skip to content

add retry logic to the action#3

Merged
waheedahmed merged 1 commit into
mainfrom
waheed/retry-logic
Apr 30, 2026
Merged

add retry logic to the action#3
waheedahmed merged 1 commit into
mainfrom
waheed/retry-logic

Conversation

@waheedahmed
Copy link
Copy Markdown
Owner

This pull request introduces configurable retry logic for enqueueing pull requests into the merge queue, allowing users to control both the number of retries and the delay between them. The changes include updates to the documentation, action inputs, configuration handling, and the main processing logic to support these new options.

New Merge Retry Options:

  • Added documentation in README.md explaining the new merge-retries and merge-retry-sleep options, including usage examples.
  • Updated action.yml to define merge-retries and merge-retry-sleep as optional inputs with default values (6 retries, 5000ms sleep).

Configuration and Processing Logic:

  • Modified getConfig() in src/api.js to read and parse the new merge-retries and merge-retry-sleep inputs from the action configuration.
  • Enhanced processPR() in src/api.js to implement retry logic for the enqueue operation, using the configured number of retries and sleep interval. [1] [2]

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds configurable retry behavior when enqueueing eligible pull requests into GitHub’s merge queue, exposing new action inputs and documenting how to use them.

Changes:

  • Add merge-retries / merge-retry-sleep configuration handling and enqueue retry loop in processPR().
  • Define new action inputs for retry count and delay.
  • Document the new retry options in the README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/api.js Parses new retry inputs and implements retry/sleep behavior around the enqueue call.
action.yml Adds new action inputs intended to configure retries and sleep duration.
README.md Documents the new retry options and provides an example workflow snippet.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/api.js
Comment thread src/api.js
Comment on lines +199 to +216
// Retry logic for enqueue
const maxRetries = typeof config.mergeRetries === 'number' && !isNaN(config.mergeRetries) ? config.mergeRetries : 6;
const retrySleep = typeof config.mergeRetrySleep === 'number' && !isNaN(config.mergeRetrySleep) ? config.mergeRetrySleep : 5000;

let attempt = 0;
let lastError = null;
while (attempt <= maxRetries) {
try {
const entry = await enqueue(octokit, pr.id);
if (entry) {
core.info(
`Added to merge queue: position=${entry.position}, state=${entry.state}`
);
} else {
core.info("Added to merge queue (no entry details returned)");
}
return;
} catch (err) {
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The action executes dist/index.js (action.ymlruns.main), but dist/index.js still contains the old non-retrying enqueue logic (no merge-retries/merge-retry-sleep handling). Run the build (npm run build) and commit the updated dist/ output so the published action actually includes the retry feature.

Copilot uses AI. Check for mistakes.
Comment thread README.md
Comment thread action.yml
Comment on lines +1 to +11
r merge-retries:
description: >
Number of times to retry enqueueing if it fails. Default is 6. Set to 0 to disable retry logic.
required: false
default: "6"

merge-retry-sleep:
description: >
Time (in milliseconds) to sleep between retries. Default is 5000 (5 seconds). Set to 0 to disable sleeping between retries.
required: false
default: "5000"
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

action.yml is invalid YAML / invalid action metadata: the file starts with an unexpected r merge-retries: key and the new inputs are defined before name: and outside the inputs: map. GitHub Actions will ignore/break these inputs. Move merge-retries and merge-retry-sleep under the existing inputs: section and remove the stray leading r/fix indentation so the file has a valid top-level schema (name, description, inputs, runs, etc.).

Copilot uses AI. Check for mistakes.
Comment thread src/api.js
Comment on lines +200 to +206
const maxRetries = typeof config.mergeRetries === 'number' && !isNaN(config.mergeRetries) ? config.mergeRetries : 6;
const retrySleep = typeof config.mergeRetrySleep === 'number' && !isNaN(config.mergeRetrySleep) ? config.mergeRetrySleep : 5000;

let attempt = 0;
let lastError = null;
while (attempt <= maxRetries) {
try {
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry loop can silently skip enqueueing when merge-retries is set to a negative number: with maxRetries < 0, while (attempt <= maxRetries) never runs and processPR returns without enqueueing or failing. Clamp mergeRetries to a minimum of 0 (and ideally validate it’s an integer) so there is always at least one enqueue attempt.

Copilot uses AI. Check for mistakes.
Comment thread src/api.js
Comment on lines +203 to +205
let attempt = 0;
let lastError = null;
while (attempt <= maxRetries) {
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastError is assigned but never read. This makes the retry logic harder to follow; remove it or use it to report a final error after the loop (if you change the control flow).

Copilot uses AI. Check for mistakes.
@waheedahmed waheedahmed merged commit baacec3 into main Apr 30, 2026
3 checks passed
waheedahmed added a commit that referenced this pull request Apr 30, 2026
waheedahmed added a commit that referenced this pull request Apr 30, 2026
waheedahmed added a commit that referenced this pull request Apr 30, 2026
@waheedahmed waheedahmed deleted the waheed/retry-logic branch April 30, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants