Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit c0cb629

Browse files
If checkSuite is completed, we should stop tracking the queued job (#45)
* If checkSuit is completed, we should stop tracking the queued job
1 parent 94c9487 commit c0cb629

4 files changed

Lines changed: 36 additions & 7 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: check-docstring-first
@@ -11,11 +11,6 @@ repos:
1111
- id: check-yaml
1212
- id: debug-statements
1313
- id: end-of-file-fixer
14-
- repo: https://github.com/myint/docformatter
15-
rev: v1.7.5
16-
hooks:
17-
- id: docformatter
18-
args: [--in-place]
1914
- repo: https://github.com/asottile/pyupgrade
2015
rev: v3.15.2
2116
hooks:

src/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ def monitor_jobs():
136136

137137
for job_data in jobs_data["nodes"]:
138138
job = job_handler.queued.get(job_data["id"])
139-
if job_data["status"] != "QUEUED":
139+
if (
140+
job_data.get("checkSuite", {}).get("status") == "COMPLETED"
141+
or job_data["status"] != "QUEUED"
142+
):
140143
job = job_handler.queued.pop(job_data["id"], None)
141144
app.logger.info(
142145
f"Job {job_data['id']} is no longer queued {job_data['status']}"

src/query_graphql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def query_jobs(node_id_list: List[str]):
3232
name
3333
}
3434
checkSuite {
35+
status
3536
workflowRun {
3637
event
3738
runNumber

tests/test_app.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ def test_monitor_jobs(
6868
{
6969
"id": "workflow_id_queued",
7070
"status": "QUEUED",
71+
"checkSuite": {"status": "IN_PROGRESS"},
7172
"startedAt": "2024-04-29T12:43:16Z",
7273
"completedAt": None,
7374
},
7475
{
7576
"id": "workflow_id_in_progress",
7677
"status": "IN_PROGRESS",
78+
"checkSuite": {"status": "IN_PROGRESS"},
7779
"startedAt": "2024-04-29T12:43:32Z",
7880
"completedAt": None,
7981
},
@@ -86,3 +88,31 @@ def test_monitor_jobs(
8688
assert in_progress_job.status == "in_progress"
8789
assert in_progress_job.in_progress_at is not None
8890
send_queued_metric_mock.assert_called()
91+
92+
93+
@patch("jobs.Job.send_queued_metric")
94+
@patch("app.query_jobs")
95+
def test_monitor_jobs_completed_suit(
96+
query_jobs_mock, send_queued_metric_mock, queued_job
97+
):
98+
app.job_handler = JobEventsHandler()
99+
app.job_handler.queued = {
100+
"workflow_id_queued": queued_job,
101+
}
102+
103+
query_jobs_mock.return_value = {
104+
"nodes": [
105+
{
106+
"id": "workflow_id_queued",
107+
"status": "QUEUED",
108+
"checkSuite": {"status": "COMPLETED"},
109+
"startedAt": "2024-04-29T12:43:16Z",
110+
"completedAt": None,
111+
}
112+
]
113+
}
114+
115+
monitor_jobs()
116+
117+
assert "workflow_id_queued" not in app.job_handler.queued
118+
send_queued_metric_mock.assert_called()

0 commit comments

Comments
 (0)