nixbot

builds

failed treefmt-check checks.aarch64-darwin.treefmt · build #392 · raw

1treefmt v2.5.0traversed 333 files2emitted 267 files for processing3formatted 267 files (3 changed) in 910ms4 M nixbot/nixbot/tests/test_db.py5 M nixbot/nixbot/tests/test_service.py6 M nixbot/nixbot/tests/test_status.py7diff --git a/nixbot/nixbot/tests/test_db.py b/nixbot/nixbot/tests/test_db.py8index 159209b..d1f2bcd 1006449--- a/nixbot/nixbot/tests/test_db.py10+++ b/nixbot/nixbot/tests/test_db.py11@@ -266,10 +266,13 @@ async def test_terminal_report_ack_rejects_late_target_snapshot(12 await builds_q.mark_build_report_delivered(13 pool, build_id=build_id, generation=0, commit_shas=["pr-sha"]14 )15- assert await pool.fetchval(16- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",17- build_id,18- ) == 019+ assert (20+ await pool.fetchval(21+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",22+ build_id,23+ )24+ == 025+ )26 27 # Attaching main invalidates the ack. An older in-flight API snapshot may28 # finish afterward, but cannot acknowledge a target it never posted.29@@ -283,10 +286,13 @@ async def test_terminal_report_ack_rejects_late_target_snapshot(30 await builds_q.mark_build_report_delivered(31 pool, build_id=build_id, generation=0, commit_shas=["pr-sha"]32 )33- assert await pool.fetchval(34- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",35- build_id,36- ) is None37+ assert (38+ await pool.fetchval(39+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",40+ build_id,41+ )42+ is None43+ )44 assert build_id in await builds_q.unreconciled_terminal_builds(pool)45 46 await builds_q.mark_build_report_delivered(47diff --git a/nixbot/nixbot/tests/test_service.py b/nixbot/nixbot/tests/test_service.py48index 0ff4e51..c35c14e 10064449--- a/nixbot/nixbot/tests/test_service.py50+++ b/nixbot/nixbot/tests/test_service.py51@@ -941,9 +941,7 @@ class TargetRecordingReporter(AttributeRecordingReporter):52 async def build_finished(self, event: Any, build: Any, result: BuildResult) -> None:53 self.final_results.append((event.commit_sha, result))54 55- async def eval_finished(56- self, event: Any, build: Any, report: EvalReport57- ) -> None:58+ async def eval_finished(self, event: Any, build: Any, report: EvalReport) -> None:59 self.eval_results.append((event.commit_sha, report.success))60 self.eval_reports.append((event.commit_sha, report))61 62@@ -980,9 +978,7 @@ async def test_restart_and_final_report_use_persisted_targets_after_restart(63 async def no_resumable_builds(*args: Any, **kwargs: Any) -> list[Any]:64 return []65 66- monkeypatch.setattr(67- restart_dispatch, "find_unfinished_builds", no_resumable_builds68- )69+ monkeypatch.setattr(restart_dispatch, "find_unfinished_builds", no_resumable_builds)70 await restart_dispatch.rerun(service, build_id, restart=True)71 72 assert set(reporter.restarted) == {73@@ -1003,9 +999,7 @@ async def test_restart_and_final_report_use_persisted_targets_after_restart(74 await build_reuse.report_eval_finished(75 service.orchestrator, source_event, build, EvalReport(success=False)76 )77- await build_reuse.report_eval_cancelled(78- service.orchestrator, source_event, build79- )80+ await build_reuse.report_eval_cancelled(service.orchestrator, source_event, build)81 assert set(reporter.eval_results) == {82 ("pr-sha", True),83 ("main-sha", True),84@@ -1051,9 +1045,7 @@ async def test_old_terminal_report_does_not_post_after_restart_reset(85 )86 reporter = TargetRecordingReporter()87 service.orchestrator.reporter = reporter88- await service.enqueue_work(89- "report", f"report-{build_id}", {"build_id": build_id}90- )91+ await service.enqueue_work("report", f"report-{build_id}", {"build_id": build_id})92 93 await service.orchestrator.reset_build_for_restart(build_id, None)94 await service.drain_work()95@@ -1109,10 +1101,13 @@ async def test_terminal_eval_api_failure_blocks_ack_until_retry(96 service.orchestrator.request_build_report = service.request_build_report97 98 await service.orchestrator.request_build_report(build_id)99- assert await pool.fetchval(100- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",101- build_id,102- ) is None103+ assert (104+ await pool.fetchval(105+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",106+ build_id,107+ )108+ is None109+ )110 assert reporter.final_results == []111 112 await service.drain_work()113@@ -1122,10 +1117,13 @@ async def test_terminal_eval_api_failure_blocks_ack_until_retry(114 "pr-sha",115 "main-sha",116 }117- assert await pool.fetchval(118- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",119- build_id,120- ) == 0121+ assert (122+ await pool.fetchval(123+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",124+ build_id,125+ )126+ == 0127+ )128 129 130 async def test_terminal_report_treats_partial_eval_with_attribute_as_failed(131@@ -1260,7 +1258,13 @@ async def test_terminal_report_formats_production_warning_groups_through_forge(132 ) -> None:133 text = extra.get("text")134 self.posts.append(135- (sha, context, state, description, text if isinstance(text, str) else None)136+ (137+ sha,138+ context,139+ state,140+ description,141+ text if isinstance(text, str) else None,142+ )143 )144 145 pool = service.pool146@@ -1323,9 +1327,7 @@ async def test_terminal_report_formats_production_warning_groups_through_forge(147 assert "download failed (\u00d73)" in eval_post[4]148 assert "input is deprecated" in eval_post[4]149 assert any(150- post[0] == sha151- and post[1] == "nixbot/nix-build"152- and post[2] == build_state153+ post[0] == sha and post[1] == "nixbot/nix-build" and post[2] == build_state154 for post in poster.posts155 )156 157@@ -1375,12 +1377,8 @@ async def test_late_target_crash_recovers_terminal_eval_and_final(158 async def no_unfinished_builds(*args: Any, **kwargs: Any) -> list[Any]:159 return []160 161- monkeypatch.setattr(162- builds_q, "reportable_attribute_failures", no_early_failures163- )164- monkeypatch.setattr(165- builds_q, "unreconciled_terminal_builds", only_this_terminal166- )167+ monkeypatch.setattr(builds_q, "reportable_attribute_failures", no_early_failures)168+ monkeypatch.setattr(builds_q, "unreconciled_terminal_builds", only_this_terminal)169 monkeypatch.setattr("nixbot.service.find_unfinished_builds", no_unfinished_builds)170 reporter = TargetRecordingReporter()171 service.orchestrator.reporter = reporter172@@ -1393,10 +1391,13 @@ async def test_late_target_crash_recovers_terminal_eval_and_final(173 "pr-sha",174 "main-sha",175 }176- assert await pool.fetchval(177- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",178- build_id,179- ) == 0180+ assert (181+ await pool.fetchval(182+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",183+ build_id,184+ )185+ == 0186+ )187 188 189 async def test_late_terminal_target_gets_rich_failures_and_final_status(190@@ -1445,7 +1446,9 @@ async def test_late_terminal_target_gets_rich_failures_and_final_status(191 assert len(main_results) == 1192 assert main_results[0].attr_prefix == "hydraJobs"193 assert main_results[0].results[0].error == "error: persisted rich diagnostic"194- main_failures = [failure for failure in reporter.failures if failure[0] == "main-sha"]195+ main_failures = [196+ failure for failure in reporter.failures if failure[0] == "main-sha"197+ ]198 assert len(main_failures) == 1199 assert main_failures[0][2] == "error: persisted rich diagnostic"200 assert main_failures[0][5] == "hydraJobs"201@@ -1521,13 +1524,17 @@ async def test_live_reconciliation_repairs_queue_write_and_retry_update_failures202 service.enqueue_work = failed_enqueue # type: ignore[method-assign]203 await service.request_build_report(build_id)204 service.enqueue_work = original_enqueue # type: ignore[method-assign]205- assert await pool.fetchval(206- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",207- build_id,208- ) is None209- assert await pool.fetchval(210- "SELECT count(*) FROM work_queue WHERE kind = 'report'"211- ) == 0212+ assert (213+ await pool.fetchval(214+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",215+ build_id,216+ )217+ is None218+ )219+ assert (220+ await pool.fetchval("SELECT count(*) FROM work_queue WHERE kind = 'report'")221+ == 0222+ )223 224 queue = WorkQueue(pool)225 await service._reconcile_terminal_reports(queue) # noqa: SLF001226@@ -1543,15 +1550,15 @@ async def test_live_reconciliation_repairs_queue_write_and_retry_update_failures227 with pytest.raises(RuntimeError, match="retry update failed"):228 await service._execute_work(queue, item) # noqa: SLF001229 queue.retry = original_retry # type: ignore[method-assign]230- assert await pool.fetchval(231- "SELECT status FROM work_queue WHERE id = $1", item.id232- ) == "running"233+ assert (234+ await pool.fetchval("SELECT status FROM work_queue WHERE id = $1", item.id)235+ == "running"236+ )237 238 # The idle-loop lease sweep repairs the otherwise unleased running row239 # without requiring a process restart.240 await pool.execute(241- "UPDATE work_queue SET claimed_at = now() - interval '1 hour' "242- "WHERE id = $1",243+ "UPDATE work_queue SET claimed_at = now() - interval '1 hour' WHERE id = $1",244 item.id,245 )246 reporter.available = True247@@ -1559,10 +1566,13 @@ async def test_live_reconciliation_repairs_queue_write_and_retry_update_failures248 await service.drain_work()249 250 assert {commit for commit, _ in reporter.final_results} == {"terminal-sha"}251- assert await pool.fetchval(252- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",253- build_id,254- ) == 0255+ assert (256+ await pool.fetchval(257+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",258+ build_id,259+ )260+ == 0261+ )262 263 264 async def test_attribute_report_reloads_persisted_failure_retries_and_fans_out(265@@ -1696,9 +1706,7 @@ async def test_terminal_recovery_reconciles_failure_beyond_early_slice(266 early = await builds_q.reportable_attribute_failures(267 pool, report_limit=service.config.failed_build_report_limit268 )269- assert attrs[-1] not in {270- row.attr for row in early if row.build_id == build_id271- }272+ assert attrs[-1] not in {row.attr for row in early if row.build_id == build_id}273 274 async def no_early_failures(*args: Any, **kwargs: Any) -> list[Any]:275 return []276@@ -1706,12 +1714,8 @@ async def test_terminal_recovery_reconciles_failure_beyond_early_slice(277 async def only_terminal_build(*args: Any, **kwargs: Any) -> list[int]:278 return [build_id]279 280- monkeypatch.setattr(281- builds_q, "reportable_attribute_failures", no_early_failures282- )283- monkeypatch.setattr(284- builds_q, "unreconciled_terminal_builds", only_terminal_build285- )286+ monkeypatch.setattr(builds_q, "reportable_attribute_failures", no_early_failures)287+ monkeypatch.setattr(builds_q, "unreconciled_terminal_builds", only_terminal_build)288 reporter = TargetRecordingReporter()289 service.orchestrator.reporter = reporter290 291@@ -1788,10 +1792,13 @@ async def test_direct_cancel_fans_out_and_acknowledges_durable_targets(292 generation = await pool.fetchval(293 "SELECT status_generation FROM builds WHERE id = $1", build_id294 )295- assert await pool.fetchval(296- "SELECT reported_generation FROM build_reporting WHERE build_id = $1",297- build_id,298- ) == generation299+ assert (300+ await pool.fetchval(301+ "SELECT reported_generation FROM build_reporting WHERE build_id = $1",302+ build_id,303+ )304+ == generation305+ )306 307 308 async def test_check_rerequested_dispatch(service: CIService) -> None:309diff --git a/nixbot/nixbot/tests/test_status.py b/nixbot/nixbot/tests/test_status.py310index 99c73e0..126edd8 100644311--- a/nixbot/nixbot/tests/test_status.py312+++ b/nixbot/nixbot/tests/test_status.py313@@ -895,9 +895,7 @@ async def test_poster_network_errors_do_not_propagate() -> None:314 await reporter.build_started(EVENT, BUILD) # must not raise315 await reporter.eval_finished(EVENT, BUILD, EvalReport(success=False))316 with pytest.raises(httpx.ConnectError):317- await reporter.terminal_eval_finished(318- EVENT, BUILD, EvalReport(success=False)319- )320+ await reporter.terminal_eval_finished(EVENT, BUILD, EvalReport(success=False))321 with pytest.raises(httpx.ConnectError):322 await reporter.build_finished(EVENT, BUILD, BuildResult("succeeded", 1, []))323 324@@ -954,9 +952,7 @@ async def test_check_permission_error_does_not_disable_forge() -> None:325 )326 await reporter.build_started(EVENT, BUILD)327 with pytest.raises(CheckPermissionError):328- await reporter.terminal_eval_finished(329- EVENT, BUILD, EvalReport(success=False)330- )331+ await reporter.terminal_eval_finished(EVENT, BUILD, EvalReport(success=False))332 with pytest.raises(CheckPermissionError):333 await reporter.build_finished(EVENT, BUILD, BuildResult("succeeded", 1, []))334 # Every phase still attempts to post. The forge is never latched off.