tests.test_ci_status moduleΒΆ

Tests for CI job triage.

tests.test_ci_status.job(name, conclusion='success', status='completed')[source]ΒΆ

Shorthand for a settled job.

tests.test_ci_status.run(*jobs, conclusion='success', status='completed')[source]ΒΆ

Shorthand for a run carrying jobs.

tests.test_ci_status.UNEXPANDED_MATRIX_JOB = "${{ matrix.state == 'stable' && 'βœ…' || '⁉️' }} ${{ matrix.os }} / py${{ matrix.python-label || matrix.python-version }}"ΒΆ

The name of a matrix job GitHub never expanded: its name: expression.

tests.test_ci_status.test_job_requirement_reads_the_glyph(name, required)[source]ΒΆ

Classification keys off the glyph, never a positional field.

tests.test_ci_status.test_a_job_name_template_reads_as_required()[source]ΒΆ

Every job name that picks its glyph from the matrix is required unexpanded.

GitHub shows the name: expression as written for a matrix it never expanded. Each of those templates holds both glyphs. One that held the unstable glyph alone would read as a probe, and hide the required cells that never ran.

tests.test_ci_status.test_a_matrix_never_expanded_is_required()[source]ΒΆ

A run stopped before its matrix got its cells left required cells undone.

One cancelled job stands for the whole matrix, and every other job passed. Reading that job as a probe makes the run green.

tests.test_ci_status.test_a_matrix_never_expanded_is_named_in_the_findings()[source]ΒΆ

The reader learns that no cell ran, not only that a job was cancelled.

tests.test_ci_status.test_a_failed_matrix_never_expanded_blocks()[source]ΒΆ

A matrix that failed before it expanded is a required failure.

tests.test_ci_status.test_probe_failure_does_not_block()[source]ΒΆ

An allowed-failure cell is reported and never gates.

tests.test_ci_status.test_required_failure_blocks()[source]ΒΆ

A red required cell holds up the merge.

tests.test_ci_status.test_a_probe_failure_inside_a_green_run_is_still_surfaced()[source]ΒΆ

continue-on-error folds a crash into a green run conclusion.

This is why the run’s own conclusion never answers β€œis anything broken”.

tests.test_ci_status.test_queued_run_status_does_not_hide_finished_jobs()[source]ΒΆ

A run reads queued while its jobs are already settling.

tests.test_ci_status.test_workflow_level_failure_has_no_failed_job()[source]ΒΆ

A run failing around its jobs is a workflow error, not a benign one.

tests.test_ci_status.test_a_normal_failure_is_not_read_as_workflow_level()[source]ΒΆ

With a failed job to point at, the run failed inside a job.

tests.test_ci_status.test_skipped_and_cancelled_jobs_are_not_failures()[source]ΒΆ

Only failure blocks: a skipped job is a gate that did not apply.

tests.test_ci_status.test_a_run_without_a_result_never_reads_green(jobs, conclusion, verdict, inconclusive)[source]ΒΆ

A run that was cancelled, or that ran no job, says nothing about its commit.

It is not a failure, so it never blocks. It is not a pass either: a green verdict there hides that the matrix never ran on the newest commits.

tests.test_ci_status.test_a_failure_outranks_a_cancellation()[source]ΒΆ

A cancelled run that already holds a red required job is a red run.

tests.test_ci_status.test_a_run_still_going_is_not_inconclusive_yet()[source]ΒΆ

Cancelled jobs beside running ones belong to a run that has not settled.

tests.test_ci_status.test_a_run_with_no_job_yet_is_neither_green_nor_settled(run_status)[source]ΒΆ

A run GitHub has yet to give a job says nothing about its commit yet.

It waits that way for a runner, or behind the run ahead of it in its concurrency group. Read as green and settled, it ends a watch before the matrix even started.

tests.test_ci_status.test_findings_put_what_gates_a_merge_first(status, expected)[source]ΒΆ

Errors gate a merge, warnings do not: each finding says which it is.

tests.test_ci_status.test_workflow_level_failure_is_an_error_finding()[source]ΒΆ

A run failing around its jobs names the place to look instead.

tests.test_ci_status.test_run_cells_follow_the_table_columns()[source]ΒΆ

The table row is the workflow, the short SHA, the status, the verdict.

tests.test_ci_status.test_monitored_workflows_selects_push_triggered_files(tmp_path)[source]ΒΆ

Derived from the tree, so a new workflow is watched automatically.

tests.test_ci_status.test_monitored_workflows_reads_the_yaml_boolean_on_key(tmp_path)[source]ΒΆ

A bare on: parses as the boolean True under YAML 1.1.

tests.test_ci_status.test_monitored_workflows_missing_directory(tmp_path)[source]ΒΆ

A repo with no workflows reports none rather than raising.

tests.test_ci_status.test_monitored_workflows_skips_unparsable_file(tmp_path)[source]ΒΆ

One malformed file never aborts the sweep.

tests.test_ci_status.test_latest_run_reads_jobs()[source]ΒΆ

The run and its jobs come back as one object.

tests.test_ci_status.test_latest_run_with_no_run()[source]ΒΆ

An empty listing is not an error: GitHub may not have materialized one.

tests.test_ci_status.test_an_unreadable_run_fails_rather_than_reading_green()[source]ΒΆ

A payload that is not a run raises instead of producing a jobless run.

tests.test_ci_status.test_read_ci_status_skips_workflows_without_a_run()[source]ΒΆ

A workflow with no run drops out rather than reporting a fake green.

tests.test_ci_status.test_read_ci_status_anchors_on_the_tip()[source]ΒΆ

Every workflow that ran on the tip is read there, and the walk stops.

tests.test_ci_status.test_read_ci_status_walks_back_to_a_path_filtered_workflow()[source]ΒΆ

A workflow the tip skipped is read on the commit that last started it.

tests.test_ci_status.test_read_ci_status_walks_back_from_a_run_that_ran_no_job()[source]ΒΆ

A workflow that skipped every job on the tip is read where it last ran.

The tip is a version-bump commit: tests.yaml skips it, and its push cancelled the run of the commit under it. The skipped run reads as a finished one with no failure, which hides that the matrix never ran on the change.

tests.test_ci_status.test_read_ci_status_stops_at_a_cancelled_run()[source]ΒΆ

A cancelled run is the newest word on its workflow, whatever ran before.

The green run of the parent is older than the commit left without a result: reporting it would read as a pass on a tree it never saw.

tests.test_ci_status.test_read_ci_status_reports_a_workflow_that_only_skipped()[source]ΒΆ

With nothing but skipped runs in the window, the newest one is reported.

Its own verdict says the tip has no result, so the tip note leaves it out.

tests.test_ci_status.test_read_ci_status_prefers_a_run_with_a_result_on_the_same_commit(with_result, skipped)[source]ΒΆ

Of two runs on one commit, the one that ran a job is read, newer or not.

The usual case is a run dispatched on a commit whose push run skipped every job. The other order is a later event that no job of the workflow answers.

tests.test_ci_status.test_read_ci_status_ignores_a_stale_branch_listing()[source]ΒΆ

A months-old snapshot from the branch listing never reaches the report.

The listing below claims the latest tests.yaml run failed on an old commit, while the tip’s own run is green. A reader trusting the listing reports the old red.

tests.test_ci_status.test_read_ci_status_falls_back_past_the_window()[source]ΒΆ

A workflow with no run on the newest commits asks its dated run listing.

tests.test_ci_status.test_runs_on_tip_is_empty_before_the_tip_runs()[source]ΒΆ

Right after a push, every run read belongs to an earlier commit.

tests.test_ci_status.test_ci_status_command_reports_a_run_without_a_result()[source]ΒΆ

The command says which commit has no result, and still exits clean.

Nothing failed, so nothing is fatal: the report is what tells a cancelled or skipped run from a green one.

tests.test_ci_status.test_ci_status_command_reports_an_unreadable_run_as_an_error()[source]ΒΆ

A run gh cannot read fails the command with a message, not a traceback.

tests.test_ci_status.test_workflow_files_keeps_everything_with_runs_of_its_own(tmp_path)[source]ΒΆ

Every trigger counts except workflow_call, which creates no run.

monitored_workflows answers β€œwhat does a push start”, which is a narrower question than β€œwhat may I name”: a schedule-only workflow has runs worth reading, and a reusable one never does.

tests.test_ci_status.test_workflow_files_missing_directory(tmp_path)[source]ΒΆ

A repository with no workflow directory offers no workflow.

tests.test_ci_status.test_write_failed_logs_writes_one_file_per_failed_required_job(tmp_path)[source]ΒΆ

Each failed required job lands in a file named after its workflow and job.

tests.test_ci_status.test_write_failed_logs_skips_a_job_without_an_id(tmp_path, caplog)[source]ΒΆ

A listing with no job ID leaves the log unfetched, and says so.

tests.test_ci_status.test_write_failed_logs_skips_a_log_it_cannot_read(tmp_path, caplog)[source]ΒΆ

A log read that fails costs its own file: the next log is still written.

tests.test_ci_status.test_watch_state_reports_each_verdict_once(tmp_path)[source]ΒΆ

A verdict already in the file is not a change; a new one is, and is saved.

tests.test_ci_status.test_watch_state_survives_an_unreadable_file(tmp_path)[source]ΒΆ

A corrupt state file starts the watch from an empty baseline.

tests.test_ci_status.test_watch_state_survives_a_file_it_cannot_open(tmp_path, monkeypatch)[source]ΒΆ

A state file the watch is refused starts it from an empty baseline too.

tests.test_ci_status.test_watch_ends_when_every_run_settled_on_the_tip()[source]ΒΆ

Polls go on while a run is live, and stop once the tip settled green.

tests.test_ci_status.test_watch_ends_on_the_first_failed_required_job()[source]ΒΆ

A red required job is the moment to act, not one to wait through.

tests.test_ci_status.test_watch_keeps_polling_until_the_tip_has_a_run()[source]ΒΆ

A settled run of an older commit is not the tip’s result.

tests.test_ci_status.test_watch_until_change_stops_at_the_first_new_verdict()[source]ΒΆ

A re-armed watcher wakes once per event and never sleeps past it.

tests.test_ci_status.test_watch_until_change_waits_through_a_failure_it_already_reported()[source]ΒΆ

A re-armed watcher does not wake again on a red job the state file holds.

The first wake reported the failure. Ending every later tick on it at once turns a watch re-armed on each wake into a busy loop.

tests.test_ci_status.test_watch_gives_up_at_the_timeout()[source]ΒΆ

A watch with a timeout ends once the clock passes it, whatever the state.

tests.test_ci_status.test_watch_never_sleeps_past_the_timeout()[source]ΒΆ

The last sleep shrinks to the time left, so a watch ends at its deadline.

tests.test_ci_status.test_ci_status_command_waits_and_prints_each_change(tmp_path)[source]ΒΆ

Under –wait the command prints the changes, then the table of the last poll.

tests.test_ci_status.test_ci_status_command_writes_the_failed_logs(tmp_path)[source]ΒΆ

–failed-logs names each file it wrote.

tests.test_ci_status.test_ci_status_command_says_what_it_has_no_result_for(status, expected)[source]ΒΆ

Each state with no result yet is reported, and the command exits clean.

tests.test_ci_status.test_ci_status_command_reports_the_automation_and_release_prs(automation_prs, release_pr, expected)[source]ΒΆ

The extra reads print one line per automation PR, and one for the release PR.