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', on_tip=False)[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_skipped_matrix_never_expanded_is_a_notice()[source]

A matrix its if: ruled out is named, without a warning to act on.

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_a_required_job_github_cancelled_still_gates_the_merge()[source]

A required job no runner picked up fails its run with no failed job.

It is no workflow error, so the verdict names the job instead. Its commit has no result for that job, so the run still blocks.

tests.test_ci_status.test_a_probe_github_cancelled_gates_no_merge(conclusion, on_tip)[source]

A probe that no runner picked up fails its run with no failed job.

It is no workflow error, and like a failed probe it holds nothing up: the finding names it as a warning.

tests.test_ci_status.test_a_failure_with_no_failed_and_no_cancelled_job_is_workflow_level()[source]

Only a failed or a cancelled job explains a failed run: a skip does not.

tests.test_ci_status.test_a_cancelled_run_is_not_a_stopped_one()[source]

A newer push cancels the whole run: its conclusion is cancelled.

tests.test_ci_status.test_a_cancelled_run_on_the_tip_gates_the_merge()[source]

A job past its timeout concludes its run cancelled, like a push does.

No newer push stopped a run on the tip, so its commit gets no result from any other run, and the run blocks.

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_concluded_job_with_a_stale_status_has_settled()[source]

A job GitHub left at in_progress after its conclusion is not running.

Counted as running, it would hold a watch open until the watch times out, on a run that is already green.

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_a_required_job_github_cancelled_is_an_error_finding()[source]

The finding names the cancelled job and the re-run, not a workflow error.

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_workflow_discovery_reads_a_single_event_and_an_event_list(tmp_path)[source]

on: can name one event, or list several, in place of a mapping.

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.BAD_GATEWAY = 'HTTP 502: Server Error (https://api.github.com/repos/kiwi/orchard/actions/runs/42/jobs?per_page=100)'

What gh run view prints while GitHub cannot serve the jobs of one run.

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_reads_on_past_a_run_it_cannot_read()[source]

A transient error on one run leaves the other workflows read.

tests.test_ci_status.test_read_ci_status_ends_on_a_run_error_that_lasts()[source]

An error that no new poll clears still ends the read.

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. No newer push stopped a run on the tip, so it blocks.

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.KIWI_PULL = {'head': {'ref': 'kiwi'}, 'number': 7}

An open pull request from the kiwi branch of a fork.

tests.test_ci_status.MAIN_PULL = {'head': {'ref': 'main'}, 'number': 6}

An open pull request from the main branch of a fork.

tests.test_ci_status.test_read_ci_status_reads_a_fork_branch_from_its_pull_request()[source]

The branch of a pull request from a fork is read from the pull request.

Its commits come from the ref of the pull request, and its runs from the name of the branch.

tests.test_ci_status.test_read_ci_status_keeps_an_unread_branch_an_error(http_status, pulls)[source]

A branch no open pull request comes from fails as the repository answered.

So does a branch whose read failed on anything else than a 404, which no pull request explains.

tests.test_ci_status.test_read_ci_status_refuses_a_branch_name_two_forks_share()[source]

Two open pull requests from branches of the same name leave no tip to read.

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_waits_through_a_failure_the_tip_can_replace()[source]

A red run of the commit before the tip gives way to the tip’s own run.

tests.test_ci_status.test_watch_ends_on_a_failure_of_an_earlier_commit_once_the_tip_settled()[source]

A workflow the tip did not run keeps its red verdict once the tip is done.

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.GATEWAY_TIMEOUT = "HTTP 504: We couldn't respond to your request in time. Sorry about that. Please try resubmitting your request and contact us if the problem persists. (https://api.github.com/repos/kiwi/orchard/actions/runs/1/jobs?per_page=100)"

What gh run view prints when GitHub times out on the jobs of a run.

tests.test_ci_status.test_watch_skips_a_poll_that_fails_transiently(stderr, caplog)[source]

A transient read failure costs its poll alone: the watch ends as usual.

tests.test_ci_status.test_watch_ends_after_too_many_failed_polls_in_a_row()[source]

A fault that lasts the whole bound ends the watch with its error.

tests.test_ci_status.test_watch_counts_only_the_failed_polls_in_a_row()[source]

A poll that reads resets the count, so scattered faults never end a watch.

tests.test_ci_status.test_watch_stops_reading_a_run_it_keeps_failing_to_read(caplog)[source]

A run GitHub keeps failing to serve is dropped: the rest end the watch.

tests.test_ci_status.test_watch_counts_only_the_failed_reads_of_a_run_in_a_row(caplog)[source]

A run that reads again resets its count, so scattered faults drop nothing.

tests.test_ci_status.test_watch_ends_once_it_stops_reading_the_only_run_on_the_tip()[source]

The run it stops reading can be the run of the tip, so it waits no more.

The run left reads on an earlier commit, as a paths: filter leaves it.

tests.test_ci_status.test_watch_ends_at_once_on_a_client_error(stderr)[source]

A client error gets the same answer on every poll, so the first one ends it.

tests.test_ci_status.test_watch_raises_at_the_timeout_when_no_poll_read()[source]

A watch whose every poll failed has no status to end on, only the error.

tests.test_ci_status.test_watch_ends_on_the_last_status_read_at_the_timeout()[source]

A timeout right after a failed poll ends the watch on the poll before it.

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_waits_through_a_server_error()[source]

One GitHub timeout under –wait costs a poll, not the exit code.

tests.test_ci_status.test_ci_status_command_reports_a_run_it_cannot_read(runs)[source]

An unreadable run gets a warning line, and alone it is not fatal.

No run is listed when it is alone, so no line says that every run listed belongs to an earlier commit.

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.