Skip to content

Commit 0a37573

Browse files
authored
feat(worker): auto-fix a pull request when its CI checks fail (#321)
* feat(worker): let the PR checks failed trigger match every failing check * feat(worker): coalesce one commit's failing check deliveries * feat(worker): cap automatic fix runs per pull request and announce exhaustion
1 parent 845c834 commit 0a37573

20 files changed

Lines changed: 8615 additions & 51 deletions

apps/dashboard/components/cockpit/flow-editor/config-fields.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3717,6 +3717,16 @@ export function ConfigFields({
37173717
onChange={(value) => onChange("params.checkNames", value ?? [])}
37183718
/>
37193719
</ConfigField>
3720+
<ConfigField label="Ignored check names">
3721+
<ArrayTextarea
3722+
key={`${node.id}:ignoreCheckNames`}
3723+
value={node.params.ignoreCheckNames}
3724+
disabled={!canEdit}
3725+
mono
3726+
placeholder="lint"
3727+
onChange={(value) => onChange("params.ignoreCheckNames", value ?? [])}
3728+
/>
3729+
</ConfigField>
37203730
<ConfigField label="Trusted GitHub App slugs">
37213731
<ArrayTextarea
37223732
key={`${node.id}:githubAppSlugs`}
@@ -3737,9 +3747,21 @@ export function ConfigFields({
37373747
onChange={(value) => onChange("params.gitlabPipelineSources", value)}
37383748
/>
37393749
</ConfigField>
3750+
<ConfigField label="Max fix attempts per PR">
3751+
<NumberField
3752+
value={node.params.maxFixAttemptsPerPr}
3753+
min={1}
3754+
max={10}
3755+
disabled={!canEdit}
3756+
onChange={(v) => onChange("params.maxFixAttemptsPerPr", v)}
3757+
/>
3758+
</ConfigField>
37403759
<ConfigNote>
3741-
Events fail closed until an exact check name matches. GitHub defaults to the
3742-
github-actions App; GitLab defaults to merge-request pipelines.
3760+
Leave the check names empty to react to every failing check, or list names to
3761+
narrow it to those. GitHub defaults to the github-actions App; GitLab defaults to
3762+
merge-request pipelines. Ignored check names never start a run even when they
3763+
fail. Max fix attempts per PR caps how many automatic fix attempts one pull
3764+
request may receive before the loop stops.
37433765
</ConfigNote>
37443766
<TriggerRateLimitFields
37453767
node={node}

apps/shared/contracts/workflow-graph.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ export const BLOCK_PARAM_KEYS: Record<WorkflowBlockType, readonly string[]> = {
159159
"providers",
160160
"scope",
161161
"checkNames",
162+
"ignoreCheckNames",
162163
"githubAppSlugs",
163164
"gitlabPipelineSources",
165+
"maxFixAttemptsPerPr",
164166
"rateLimitMax",
165167
"rateLimitWindow",
166168
],
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE TABLE "pr_autofix_attempts" (
2+
"definition_id" text NOT NULL,
3+
"node_id" text NOT NULL,
4+
"provider" text NOT NULL,
5+
"repo_path" text NOT NULL,
6+
"pr_number" integer NOT NULL,
7+
"attempts" integer DEFAULT 1 NOT NULL,
8+
"updated_at" timestamp with time zone NOT NULL,
9+
CONSTRAINT "pr_autofix_attempts_pk" PRIMARY KEY("definition_id","node_id","provider","repo_path","pr_number")
10+
);

0 commit comments

Comments
 (0)