Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 41f7d6e64f |
+14
-8
@@ -122,14 +122,20 @@ export async function postRuntime(
|
|||||||
const reviewerToken = (await Deno.readTextFile(manifest.reviewerFile))
|
const reviewerToken = (await Deno.readTextFile(manifest.reviewerFile))
|
||||||
.trim();
|
.trim();
|
||||||
const request = async (path: string, body: unknown): Promise<void> => {
|
const request = async (path: string, body: unknown): Promise<void> => {
|
||||||
const response = await fetcher(`${context.apiUrl}/${path}`, {
|
let response: Response;
|
||||||
method: "POST",
|
try {
|
||||||
headers: {
|
response = await fetcher(`${context.apiUrl}/${path}`, {
|
||||||
Authorization: `token ${reviewerToken}`,
|
method: "POST",
|
||||||
"Content-Type": "application/json",
|
headers: {
|
||||||
},
|
Authorization: `token ${reviewerToken}`,
|
||||||
body: JSON.stringify(body),
|
"Content-Type": "application/json",
|
||||||
});
|
},
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
const detail = error instanceof Error ? error.message : String(error);
|
||||||
|
throw new GiteaRequestError(`${path}: ${detail}`, { cause: error });
|
||||||
|
}
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new GiteaRequestError(
|
throw new GiteaRequestError(
|
||||||
`${path}: ${response.status} ${await response.text()}`,
|
`${path}: ${response.status} ${await response.text()}`,
|
||||||
|
|||||||
@@ -196,6 +196,24 @@ Deno.test("removes runtime credentials when posting fails", async () => {
|
|||||||
assert(await missing(result.runtimeDir));
|
assert(await missing(result.runtimeDir));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("preserves a Gitea transport failure without retrying a comment", async () => {
|
||||||
|
const result = await fixture({ ok: true, body: "done" });
|
||||||
|
let requests = 0;
|
||||||
|
|
||||||
|
await assertRejects(
|
||||||
|
() =>
|
||||||
|
postRuntime(result.manifestPath, context, () => {
|
||||||
|
requests++;
|
||||||
|
return Promise.reject(new Error(`network failure ${requests}`));
|
||||||
|
}),
|
||||||
|
Error,
|
||||||
|
"network failure 1",
|
||||||
|
);
|
||||||
|
|
||||||
|
assertEquals(requests, 1);
|
||||||
|
assert(await missing(result.runtimeDir));
|
||||||
|
});
|
||||||
|
|
||||||
Deno.test("refuses to follow an agent artifact symlink", async () => {
|
Deno.test("refuses to follow an agent artifact symlink", async () => {
|
||||||
if (Deno.build.os === "windows") return;
|
if (Deno.build.os === "windows") return;
|
||||||
const result = await fixture({ ok: true, body: "done" });
|
const result = await fixture({ ok: true, body: "done" });
|
||||||
|
|||||||
Reference in New Issue
Block a user