repomatic.setup_guide module¶

Build and manage the setup guide issue.

Backs the setup-guide command: composes the repository-settings checks of repomatic.lint_repo and the PAT permission probes of repomatic.github.token with the setup-guide-* templates into a single issue body, then drives the issue lifecycle. The guide reads the same LintContext as lint-repo, so the two commands agree on every gate.

Each setup step renders as a collapsible section whose open/closed state and emoji reflect the check outcome, and the issue closes only once every verifiable step passes.

repomatic.setup_guide.CANNOT_VERIFY = '\n\n> ℹ️ **Note**: This setting could not be verified: `REPOMATIC_PAT` is missing the **Administration: Read-only** permission. Update the token with the pre-filled link in the first step.'¶

Note appended to a step whose probe could not run.

Both settings it covers are read through Administration-scoped endpoints, so a PAT issued without that permission answers 403 and the check lands on None. The note ties that None to the permission, which the warning table above the steps also names.

class repomatic.setup_guide.SetupStep(placeholder, title, template, probe=<function SetupStep.<lambda>>, applies=<function SetupStep.<lambda>>, args=<function _default_args>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False)[source]¶

Bases: object

One step of the setup guide, declared once and read by every phase.

One entry per step drives its probe, its rendering, its template keyword and its part in the close gate, so the four stay in sync.

placeholder: str¶

The $name this step’s rendered block fills in setup-guide.md.

title: str¶

Heading shown in the collapsible section’s <summary> line.

template: str¶

Template rendered as the section’s body.

probe()¶

Read the step’s completion state.

Tri-state, per CheckResult.

applies()¶

Whether this repository needs the step at all.

A step that does not apply renders nothing and satisfies its gate, so a non-Sphinx project is never asked about Pages.

args()¶

Template variables, defaulting to the pair almost every step wants.

Return type:

dict[str, str | None]

gates_closure: bool = True¶

Whether this step’s outcome can hold the issue open.

False for the two steps with nothing to probe (immutable releases, the final verification), which would otherwise wedge the issue open forever.

tolerates_unknown: bool = False¶

Whether an indeterminate probe (None) satisfies the gate.

True for the settings read through Administration-scoped endpoints: a PAT without that permission answers 403, and a reader has no way to satisfy a check that cannot run, so it must not block the issue closing. Everywhere else None is treated as incomplete, keeping the step prompting.

explains_unverifiable: bool = False¶

Append CANNOT_VERIFY to the body when the probe answered None.

The reader is looking at a setting they were told to configure, so the difference between “verified” and “nobody could look” belongs on screen.

outcome(ctx)[source]¶

Probe the step, once: its state as the section renders it.

None survives only where tolerates_unknown says an unreadable probe is not the reader’s fault; elsewhere it collapses to incomplete so the section stays open.

Return type:

bool | None

render(ctx, passed)[source]¶

Render this step’s collapsible section for its passed outcome.

Return type:

str

satisfied(passed)[source]¶

Whether a step with the passed outcome lets the issue close.

Return type:

bool

repomatic.setup_guide.SETUP_STEPS: tuple[SetupStep, ...] = (SetupStep(placeholder='step_token', title='Create and configure the token', template='setup-guide-token', probe=<function _token_ok>, applies=<function SetupStep.<lambda>>, args=<function <lambda>>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_dependabot', title='Configure Dependabot settings', template='setup-guide-dependabot', probe=<function _dependabot_ok>, applies=<function SetupStep.<lambda>>, args=<function _default_args>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='immutable_releases_step', title='Enable immutable releases', template='immutable-releases', probe=<function <lambda>>, applies=<function <lambda>>, args=<function <lambda>>, gates_closure=False, tolerates_unknown=True, explains_unverifiable=False), SetupStep(placeholder='step_branch_ruleset', title='Protect the main branch', template='setup-guide-branch-ruleset', probe=<function <lambda>>, applies=<function SetupStep.<lambda>>, args=<function <lambda>>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_fork_pr_approval', title='Require approval for fork PR workflows', template='setup-guide-fork-pr-approval', probe=<function <lambda>>, applies=<function SetupStep.<lambda>>, args=<function _default_args>, gates_closure=True, tolerates_unknown=True, explains_unverifiable=True), SetupStep(placeholder='step_sha_pinning_required', title='Require SHA pinning for GitHub Actions', template='setup-guide-sha-pinning-required', probe=<function <lambda>>, applies=<function SetupStep.<lambda>>, args=<function _default_args>, gates_closure=True, tolerates_unknown=True, explains_unverifiable=True), SetupStep(placeholder='step_pypi_trusted_publisher', title='Register the PyPI Trusted Publisher entry', template='setup-guide-pypi-trusted-publisher', probe=<function _probe_trusted_publisher>, applies=<function <lambda>>, args=<function <lambda>>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_pages_source', title='Set GitHub Pages deployment source to GitHub Actions', template='setup-guide-pages-source', probe=<function <lambda>>, applies=<function <lambda>>, args=<function _default_args>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_cloudflare_pages', title='Configure the Cloudflare Pages credentials', template='setup-guide-cloudflare-pages', probe=<function <lambda>>, applies=<function <lambda>>, args=<function <lambda>>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_cloudflare_r2', title='Configure the R2 upload keys', template='setup-guide-cloudflare-r2', probe=<function <lambda>>, applies=<function <lambda>>, args=<function <lambda>>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_virustotal', title='Configure VirusTotal scanning (optional)', template='setup-guide-virustotal', probe=<function <lambda>>, applies=<function <lambda>>, args=<function _default_args>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_notifications_pat', title='Create and configure the notifications token', template='setup-guide-notifications-pat', probe=<function <lambda>>, applies=<function <lambda>>, args=<function _default_args>, gates_closure=True, tolerates_unknown=False, explains_unverifiable=False), SetupStep(placeholder='step_verify', title='Verify the setup', template='setup-guide-verify', probe=<function SetupStep.<lambda>>, applies=<function SetupStep.<lambda>>, args=<function _default_args>, gates_closure=False, tolerates_unknown=False, explains_unverifiable=False))¶

Every step of the setup guide, in the order the issue body lists them.

Each step’s template takes the shape of the REPOMATIC_PAT step: one lead sentence saying what to set and why, then numbered actions in the order they run. An action gives the command, then at most one alternative, written Or by hand: when it goes through the web UI. A form’s values go in a field table. A note only warns against a wrong action or names the cost of skipping one. Reasons and other routes live in docs/, or in a comment beside the step.

repomatic.setup_guide.manage_setup_guide(ctx)[source]¶

Render the setup guide issue body and drive the issue lifecycle.

Walks SETUP_STEPS: each step that applies probes its state once, renders its collapsible section from that state, and reports whether it lets the issue close. The issue closes only when every applicable gating step passes.

Parameters:

ctx (LintContext) – What the steps read. A context without a repository skips the permission and settings probes.

Return type:

None