Skip to content

Commit dad4e62

Browse files
add blocking stages : build, package and smoke
1 parent 1abd5e1 commit dad4e62

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

backend/tasks/job_execution.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
("run_dast", "DAST"),
1818
]
1919

20+
BLOCKING_STAGES = {
21+
"BUILD",
22+
"PACKAGE",
23+
"SMOKE-TEST",
24+
}
25+
2026
@celery_app.task(bind=True, name="execute_job")
2127
def execute_job(self, job_id: str):
2228

@@ -187,11 +193,6 @@ def _run_stage(
187193
check=False,
188194
)
189195

190-
# read stage result.json
191-
result_file = (
192-
Path("/home/runner/reports") / stage.lower() / "result.json"
193-
)
194-
195196
try:
196197
raw = subprocess.check_output(
197198
[
@@ -213,14 +214,22 @@ def _run_stage(
213214
_write_state(job_dir, state)
214215
return
215216

216-
# FAILURE
217+
# FAILURE (stage-level)
217218
state["stages"][stage]["status"] = "FAILED"
218-
state["state"] = "FAILED"
219219
state["updated_at"] = _now()
220-
state["error"] = result.get("message", "stage failed")
221-
_write_state(job_dir, state)
222220

223-
raise RuntimeError(f"Stage {stage} failed")
221+
if stage in BLOCKING_STAGES:
222+
# hard stop pipeline
223+
state["state"] = "FAILED"
224+
state["error"] = result.get("message", "blocking stage failed")
225+
_write_state(job_dir, state)
226+
raise RuntimeError(f"Blocking stage {stage} failed")
227+
228+
# non-blocking failure → continue pipeline
229+
state.setdefault("warnings", {})
230+
state["warnings"][stage] = result.get("message", "stage failed")
231+
_write_state(job_dir, state)
232+
return
224233

225234
def _read_state(job_dir: Path) -> dict:
226235
return json.loads((job_dir / "state.json").read_text())

0 commit comments

Comments
 (0)