Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/claims/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ClaimedRun implements Claim {
/** A rejected trigger never held the claim; setStatus keeps its record from replacing a real run's. */
async reject<Data>(): Promise<TaskResult<Data>> {
const summary = `@${this.#opts.actor} needs \`${config.minimumPermission}\` permission on this repository to start it.`;
await finishStatus(this.#status("rejected", summary), { rootFinished: this.#opts.mode !== "continue" });
await finishStatus(this.#status("rejected", summary));
return this.#record("rejected", "permission_denied", summary);
}

Expand Down Expand Up @@ -235,7 +235,7 @@ class ClaimedRun implements Claim {
/** Writes a final state while this run still holds the claim; false once another run's status is showing. */
async #publish(state: TaskResult["state"], summary: string, links?: StatusLink[]): Promise<boolean> {
if (!(await this.#holdsClaim())) return false;
return await finishStatus(this.#status(state, summary, links), { rootFinished: this.#opts.mode !== "continue" });
return await finishStatus(this.#status(state, summary, links));
}

#record<Data = undefined>(
Expand Down
4 changes: 2 additions & 2 deletions factory.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export function defineFactoryConfig(config: FactoryConfig): FactoryConfig {

export default defineFactoryConfig({
repos: {
"render-examples/render-factory-example-target": {
"jacobprall/software-factory-demo": {
baseBranch: "main",
install: "npm ci",
verify: ["npm run build", "npm test"],
verify: ["npm run build", "npm test -- --watchAll=false"],
},
},
labels: {
Expand Down
10 changes: 5 additions & 5 deletions tests/claims.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ describe("setStatus and finishStatus", () => {
});

describe("withClaim", () => {
const ctx = { metadata: { taskRunId: "trn-run", rootTaskRunId: "trn-root" } };
const ctx = { metadata: { taskRunId: "trn-run", rootTaskRunId: "trn-run" } };

it("rejects an actor without permission before taking over", async () => {
const gh = new FakeGitHub();
Expand All @@ -248,11 +248,11 @@ describe("withClaim", () => {
const fn = vi.fn();
const outcome = await withClaim(ctx, { repo: REPO, subject, task: "triage", title: "Triage", actor: "reader", gh: gh.asClient(), runs }, fn);
expect(fn).not.toHaveBeenCalled();
expect(outcome).toMatchObject({ state: "rejected", outcome: "permission_denied", traceId: "trn-root", runId: "trn-run" });
expect(outcome).toMatchObject({ state: "rejected", outcome: "permission_denied", traceId: "trn-run", runId: "trn-run" });
expect(gh.comments[0]?.body).toContain("did not run: @reader needs `write` permission");
expect(parseMarker(gh.comments[0]?.body ?? "", "status")?.state).toBe("rejected");
expect(gh.labels.has(WORKING_LABEL)).toBe(false);
expect(events).toMatchObject([{ type: "run.finished", traceId: "trn-root", runId: "trn-run", payload: { state: "rejected" } }]);
expect(events).toMatchObject([{ type: "run.finished", traceId: "trn-run", runId: "trn-run", payload: { state: "rejected" } }]);
});

it("runs the work and records events with the trace id and outcome", async () => {
Expand All @@ -274,15 +274,15 @@ describe("withClaim", () => {
);
expect(runs.cancelled).toEqual(["trn-prev"]);
expect(parseMarker(gh.comments[0]?.body ?? "", "status")?.sandboxId).toBeUndefined();
expect(outcome).toEqual({ state: "done", outcome: "asked-questions", summary: "asked 2 questions", traceId: "trn-root", runId: "trn-run" });
expect(outcome).toEqual({ state: "done", outcome: "asked-questions", summary: "asked 2 questions", traceId: "trn-run", runId: "trn-run" });
expect(gh.comments).toHaveLength(1);
expect(gh.comments[0]?.body).toContain("**Triage** finished: asked 2 questions");
expect(gh.labels.has(WORKING_LABEL)).toBe(false);
expect(events).toMatchObject([
{ type: "run.finished", traceId: "trn-prev", payload: { state: "cancelled", outcome: "superseded", stoppedBy: "trn-run" } },
{
type: "run.finished",
traceId: "trn-root",
traceId: "trn-run",
runId: "trn-run",
repo: REPO.fullName,
subject: "issue#12",
Expand Down
Loading