Skip to content

Commit 5ce007a

Browse files
authored
Get rid of max timeout input (#4)
1 parent 79b22e0 commit 5ce007a

File tree

5 files changed

+6
-21
lines changed

5 files changed

+6
-21
lines changed

.github/workflows/test-increased-wait-time.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ jobs:
5858
status: continuous-delivery/${{ needs.setup.outputs.environment }}.test-app
5959
expected_state: "success"
6060
token: ${{ github.token }}
61-
check-timeout: 120
6261
check-retry-count: 5
6362
check-retry-interval: 20
6463

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ Checks GitHub API for a given commit and look the commit status.
105105
|------|-------------|---------|----------|
106106
| check-retry-count | Check retry count | 5 | false |
107107
| check-retry-interval | Check retry interval (in seconds) | 10 | false |
108-
| check-timeout | Timeout check (in seconds) | 600 | false |
109108
| expected\_state | Commit status state wait for. Valid values 'success', 'error', 'failure', 'pending' | success | false |
110109
| repository | Repository | N/A | true |
111110
| sha | Commit SHA | N/A | true |

action.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ branding:
55
icon: 'clock'
66
color: 'white'
77
inputs:
8-
check-timeout:
9-
description: 'Timeout check (in seconds)'
10-
required: false
11-
default: "600"
128
check-retry-count:
139
description: 'Check retry count'
1410
required: false

docs/github-action.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
|------|-------------|---------|----------|
77
| check-retry-count | Check retry count | 5 | false |
88
| check-retry-interval | Check retry interval (in seconds) | 10 | false |
9-
| check-timeout | Timeout check (in seconds) | 600 | false |
109
| expected\_state | Commit status state wait for. Valid values 'success', 'error', 'failure', 'pending' | success | false |
1110
| repository | Repository | N/A | true |
1211
| sha | Commit SHA | N/A | true |

index.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ const github = require('@actions/github');
33
const repoToken = core.getInput('token');
44
const client = github.getOctokit(repoToken);
55

6+
const check_retry_count = core.getInput('check-retry-count');
7+
const check_retry_interval = core.getInput('check-retry-interval');
8+
69
// Function to wait for a specific commit status to become a success
7-
async function waitForCommitStatusSuccess(owner, repo, commitSha, statusContext, lookup, options = {}) {
8-
const { timeout = 300000, retryCount = 10, retryInterval = 5000 } = options;
9-
const startTime = Date.now();
10+
async function waitForCommitStatus(owner, repo, commitSha, statusContext, lookup, options = {}) {
11+
const { retryCount = 10, retryInterval = 5000 } = options;
1012

1113
let attemptCount = 0;
1214

@@ -29,12 +31,6 @@ async function waitForCommitStatusSuccess(owner, repo, commitSha, statusContext,
2931

3032
attemptCount++;
3133

32-
const elapsedTime = Date.now() - startTime;
33-
if (elapsedTime >= timeout) {
34-
console.log(`Timeout reached. Exiting...`);
35-
return false;
36-
}
37-
3834
console.log(`Waiting for commit status "${statusContext}" to become a success...`);
3935

4036
await new Promise((resolve) => setTimeout(resolve, retryInterval));
@@ -49,20 +45,16 @@ const main = async function() {
4945
const sha = core.getInput('sha');
5046
const status = core.getInput('status');
5147
const expected_state = core.getInput('expected_state');
52-
const check_timeout = core.getInput('check-timeout');
53-
const check_retry_count = core.getInput('check-retry-count');
54-
const check_retry_interval = core.getInput('check-retry-interval');
5548

5649
const options = {
57-
timeout: 1000 * check_timeout, // Convert from seconds to milliseconds
5850
retryCount: check_retry_count, // Retry 5 times before giving up
5951
retryInterval: 1000 * check_retry_interval // Convert from seconds to milliseconds
6052
};
6153

6254
owner = repository.split("/")[0]
6355
repo = repository.split("/")[1]
6456

65-
const test = await waitForCommitStatusSuccess(owner, repo, sha, status, expected_state, options)
57+
const test = await waitForCommitStatus(owner, repo, sha, status, expected_state, options)
6658
.then((result) => {
6759
console.log("Done waiting.");
6860
if (result) {

0 commit comments

Comments
 (0)