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 frontend/src/apiDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export interface TestingFarmRunGroup {
status: string;
submitted_time: number;
target: string;
web_url: string;
web_url: string | null;
}

// /api/testing-farm/$id
Expand All @@ -348,7 +348,7 @@ export interface TestingFarmRun {
run_ids: number[];
status: string;
submitted_time: number;
web_url: string;
web_url: string | null;
}

// /api/propose-downstream
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/testing-farm/TestingFarmRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { StatusLabel } from "../statusLabels/StatusLabel";
import { TriggerLink, TriggerSuffix } from "../trigger/TriggerLink";
import { CoprDataListItem } from "./CoprDataListItem";
import { KojiDataListItem } from "./KojiDataListItem";
import { getTestingFarmResultsUrl } from "./testingFarmUrls";

export const TestingFarmRun = () => {
const { id } = TestingFarmRoute.useParams();
Expand Down Expand Up @@ -109,7 +110,7 @@ export const TestingFarmRun = () => {
<StatusLabel
status={data.status}
target={data.chroot}
link={data.web_url}
link={getTestingFarmResultsUrl(data)}
/>
</DescriptionListDescription>
<DescriptionListTerm>Pipeline ID</DescriptionListTerm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { PackitPaginationContext } from "../shared/PackitPaginationContext";
import { Timestamp } from "../shared/Timestamp";
import { StatusLabel } from "../statusLabels/StatusLabel";
import { TriggerLink, TriggerSuffix } from "../trigger/TriggerLink";
import { getTestingFarmResultsUrl } from "./testingFarmUrls";

export const TestingFarmRunsTable = () => {
const [page, setPage] = useState(1);
Expand Down Expand Up @@ -102,7 +103,11 @@ export const TestingFarmRunsTable = () => {
</Td>
<Td dataLabel={columnNames.testResults}>
<strong>
<a href={testing_farm_run.web_url}>
<a
href={
getTestingFarmResultsUrl(testing_farm_run) ?? undefined
}
>
{testing_farm_run.pipeline_id}
</a>
</strong>
Expand Down
27 changes: 27 additions & 0 deletions frontend/src/components/testing-farm/testingFarmUrls.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright Contributors to the Packit project.
// SPDX-License-Identifier: MIT
import { test } from "vitest";
import { getTestingFarmResultsUrl } from "./testingFarmUrls";

const pipelineId = "b3a1c9f0-1d2e-4f5a-8b7c-6d5e4f3a2b1c";

test("results URL prefers the reported web URL", ({ expect }) => {
expect(
getTestingFarmResultsUrl({
pipeline_id: pipelineId,
web_url: `https://artifacts.dev.testing-farm.io/${pipelineId}`,
}),
).toBe(`https://artifacts.dev.testing-farm.io/${pipelineId}`);
});

test("results URL falls back to the Testing Farm API", ({ expect }) => {
expect(
getTestingFarmResultsUrl({ pipeline_id: pipelineId, web_url: null }),
).toBe(`https://api.dev.testing-farm.io/v0.1/requests/${pipelineId}`);
});

test("results URL is missing for a run not submitted yet", ({ expect }) => {
expect(
getTestingFarmResultsUrl({ pipeline_id: null, web_url: null }),
).toBeNull();
});
27 changes: 27 additions & 0 deletions frontend/src/components/testing-farm/testingFarmUrls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright Contributors to the Packit project.
// SPDX-License-Identifier: MIT

// Same instance packit-service submits the requests to
const TESTING_FARM_API_URL = "https://api.dev.testing-farm.io/v0.1";

interface TestingFarmRunUrls {
pipeline_id: string | null;
web_url: string | null;
}

/**
* Returns the URL with the results of the Testing Farm run.
*
* Packit receives the results URL only once Testing Farm reports back, until
* then point to the Testing Farm API, which shows the current state of the
* request.
*/
export const getTestingFarmResultsUrl = (run: TestingFarmRunUrls) => {
if (run.web_url) {
return run.web_url;
}
if (run.pipeline_id) {
return `${TESTING_FARM_API_URL}/requests/${run.pipeline_id}`;
}
return null;
};
Loading