Documentation
¶
Index ¶
- func CleanupScenario(w *world.World)
- func CollectFailureLogs(ctx context.Context, w *world.World, scenarioErr error)
- func DeactivateKillSwitch(w *world.World) error
- func DeactivateKillSwitchBase(w *world.World) error
- func DisableReactionNotifications(w *world.World) error
- func RedactText(s string) string
- func Register(sc *godog.ScenarioContext)
- func RegisterRedactionLiterals(w *world.World)
- func ResetDispatchGraceForTest(t testing.TB)
- func RestoreAgents(w *world.World) error
- func RestoreAllowedResources(w *world.World) error
- func RestoreRuntime(w *world.World) error
- func SanitizeConsole(s string) string
- func ValidateSlotClean(w *world.World) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupScenario ¶
CleanupScenario undoes the scenario's changes to the leased repository and the repositories named after it. Every mutation is made by name, and the slot may have been taken over by another holder since the scenario began (a lessee that outlives the pool's GC deadline, for example). When World.LeaseOwned is set, each mutation, each retry of one, and each request resend inside the forge client first verifies the scenario still owns its lease; a lost or unverifiable lease skips the mutation (logged) rather than touching the new holder's resources. Local cleanup (mock servers, artifact directories) is unaffected.
func CollectFailureLogs ¶ added in v0.46.0
CollectFailureLogs is called by the suite's After hook for a failed scenario, before CleanupScenario and before the leased repository — and with it every run's logs — is deleted. It saves the logs of the repository's recent workflow runs (and the scenario's resolved run) that were not already saved during the scenario, which covers the failure paths where no step got hold of a run: a wait that timed out, a setup step that failed before any run was resolved, or a step that waits for a run without saving its logs.
It always writes a failure-summary.txt under debug-scenario-<name>-<suffix>/ listing the scenario error and, for each run, where its logs were saved or why they could not be collected — so every failed scenario leaves an artifact, even when there are no logs to collect.
Like saveWorkflowRunLogs it is best-effort, a no-op when BEHAVIOUR_ARTIFACT_DIR is unset, redacts everything it writes, and writes files 0o600.
func DeactivateKillSwitch ¶ added in v0.34.0
DeactivateKillSwitch sets kill_switch: false in the enrolled repo's config.yaml. Exported so CleanupScenario (in package steps) can call it during scenario teardown.
func DeactivateKillSwitchBase ¶ added in v0.48.0
DeactivateKillSwitchBase sets kill_switch: false in the enrolled repo's config.base.yaml. Exported so CleanupScenario (in package steps) can call it during scenario teardown. The SCM driver has no delete-file operation, so this resets the key to false rather than removing the file — matching DeactivateKillSwitch's approach for config.yaml.
func DisableReactionNotifications ¶ added in v0.38.0
DisableReactionNotifications removes the status_notifications from the enrolled repo's config.yaml. Exported so CleanupScenario can call it during scenario teardown.
func RedactText ¶ added in v0.56.0
RedactText masks secrets in s with the same redaction the debug-log collection applies to everything it writes: failure messages recorded at record time get the same treatment as the collected artifacts.
The guarantee has two parts:
- Pattern-based redaction (security.NewSecretRedactor().Scan) runs unconditionally and needs no initialization: secrets with a recognizable shape — token prefixes such as ghp_ or sk_, credential assignments, private key blocks — are masked whether or not anything was registered.
- Exact-literal replacement depends on prior registration in the same process. Literals of at least 8 bytes are registered process-wide with the shared redactor, whose scan masks them; shorter sensitive values (down to four bytes) are kept in package-level state guarded by shortSecretsMu and masked here. RedactText registers nothing itself: both sets are populated by this package's debug-log collection — CollectFailureLogs, the workflow-log saving steps and the mint-status steps register the World token and sensitive runner environment values before writing artifacts — and by the failure-recording sites, which call RegisterRedactionLiterals before redacting a message at record time.
Callers cannot assume a stronger guarantee than the tooling provides: in a process where no secrets were registered — a consumer binary that only calls RedactText, for example — both literal sets are empty and an opaque credential that no pattern recognizes passes through unredacted.
func Register ¶
func Register(sc *godog.ScenarioContext)
Register binds all step definitions. Steps retrieve their per-scenario World from the godog context via world.FromContext.
func RegisterRedactionLiterals ¶ added in v0.56.0
RegisterRedactionLiterals registers the runner's known credential literals — w.Token, the values of sensitive-looking environment variables and the explicitly listed infrastructure identifiers — with the process-wide secret redactor. Prefix and structural patterns cannot recognise an opaque credential, which would otherwise survive in summaries, diagnostics and name-derived directory names. Values the shared redactor declines as too short are masked locally by RedactText.
The failure-recording sites — the suite's After hook and the bootstrap recorder — also call this before redacting a message at record time, so the first failure a process records is redacted with the World's literals already registered, not only after debug-log collection has run.
func ResetDispatchGraceForTest ¶ added in v0.56.1
ResetDispatchGraceForTest gives the calling test a fresh grace budget, so grace waits from other tests in the process do not shorten or skip its wait, and restores the previous budget and dispatchDiagnosticsGrace when the test ends. It is the single reset entry point, also for tests in other packages (such as the suite's After hook tests); tests that call it must not run in parallel with other tests that use the grace wait.
func RestoreAgents ¶ added in v0.38.0
RestoreAgents sets the agents list back to the pre-scenario value captured by snapshotAgents. Exported so CleanupScenario can call it during scenario teardown.
func RestoreAllowedResources ¶ added in v0.38.0
RestoreAllowedResources sets allowed_remote_resources back to the pre-scenario value captured by snapshotAllowedResources. Exported so CleanupScenario can call it during scenario teardown.
func RestoreRuntime ¶ added in v0.37.0
RestoreRuntime puts the install-time runtime back. Exported so CleanupScenario can call it during scenario teardown.
func SanitizeConsole ¶ added in v0.56.0
SanitizeConsole neutralizes text that GitHub Actions would interpret when printed to the console: line breaks and other control characters are replaced with spaces so interpolated text cannot start a new line, and the "::" workflow-command delimiter is broken up.
func ValidateSlotClean ¶ added in v0.44.0
ValidateSlotClean reads the leased repo's config and fails if a previous scenario left mutable state behind (e.g. kill switch on, OWNERS auth enabled). Called when a scenario leases its repo, so stale state is caught before it causes a silent false positive.
Types ¶
This section is empty.
Source Files
¶
- actors.go
- artifacts.go
- base_dispatch.go
- bot_actors.go
- bot_role_probe.go
- branch.go
- cleanup.go
- debuglogs.go
- dispatch.go
- dispatch_count.go
- dummy_agent.go
- forge_state.go
- fork.go
- gateway.go
- jirapoll.go
- jirapoll_transport.go
- lease_guard.go
- mint_probe.go
- mint_status.go
- owners.go
- persona_log.go
- playback.go
- prescript_skip.go
- reaction.go
- registry.go
- runner_secrets.go
- runtime.go
- triage.go
- url_dispatch.go