Skip to content

Commit ee9d780

Browse files
committed
test(ci): extract managed image workflow types
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>
1 parent f0170ed commit ee9d780

3 files changed

Lines changed: 100 additions & 123 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export type Step = {
5+
env?: Record<string, unknown>;
6+
id?: string;
7+
if?: string;
8+
name?: string;
9+
run?: string;
10+
uses?: string;
11+
with?: Record<string, unknown>;
12+
"working-directory"?: string;
13+
};
14+
15+
export type MatrixEntry = {
16+
agent?: string;
17+
arch?: string;
18+
artifact_platform?: string;
19+
base_alias?: string;
20+
base_dockerfile?: string;
21+
base_image?: string;
22+
base_repository?: string;
23+
display_name?: string;
24+
dockerfile?: string;
25+
image?: string;
26+
repository?: string;
27+
platform?: string;
28+
required_binary?: string;
29+
runner?: string;
30+
};
31+
32+
export type Job = {
33+
env?: Record<string, unknown>;
34+
if?: string;
35+
needs?: string | string[];
36+
permissions?: Record<string, string>;
37+
"runs-on"?: string;
38+
steps?: Step[];
39+
strategy?: {
40+
"fail-fast"?: boolean;
41+
matrix?: { include?: MatrixEntry[] };
42+
};
43+
"timeout-minutes"?: number;
44+
uses?: string;
45+
};
46+
47+
export type Workflow = {
48+
concurrency?: {
49+
"cancel-in-progress"?: string | boolean;
50+
group?: string;
51+
};
52+
env?: Record<string, string>;
53+
jobs?: Record<string, Job>;
54+
on?: {
55+
pull_request?: {
56+
branches?: string[];
57+
paths?: string[];
58+
};
59+
push?: {
60+
paths?: string[];
61+
};
62+
workflow_call?: unknown;
63+
};
64+
permissions?: Record<string, string>;
65+
};

test/managed-image-publication-retention.test.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

test/managed-image-publication-workflow.test.ts

Lines changed: 35 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -16,69 +16,12 @@ import {
1616
runManagedImagePromotion,
1717
runPublicationBarrier,
1818
} from "./helpers/managed-image-publication-barrier";
19-
20-
type Step = {
21-
env?: Record<string, unknown>;
22-
id?: string;
23-
if?: string;
24-
name?: string;
25-
run?: string;
26-
uses?: string;
27-
with?: Record<string, unknown>;
28-
"working-directory"?: string;
29-
};
30-
31-
type MatrixEntry = {
32-
agent?: string;
33-
arch?: string;
34-
artifact_platform?: string;
35-
base_alias?: string;
36-
base_dockerfile?: string;
37-
base_image?: string;
38-
base_repository?: string;
39-
display_name?: string;
40-
dockerfile?: string;
41-
image?: string;
42-
repository?: string;
43-
platform?: string;
44-
required_binary?: string;
45-
runner?: string;
46-
};
47-
48-
type Job = {
49-
env?: Record<string, unknown>;
50-
if?: string;
51-
needs?: string | string[];
52-
permissions?: Record<string, string>;
53-
"runs-on"?: string;
54-
steps?: Step[];
55-
strategy?: {
56-
"fail-fast"?: boolean;
57-
matrix?: { include?: MatrixEntry[] };
58-
};
59-
"timeout-minutes"?: number;
60-
uses?: string;
61-
};
62-
63-
type Workflow = {
64-
concurrency?: {
65-
"cancel-in-progress"?: string | boolean;
66-
group?: string;
67-
};
68-
env?: Record<string, string>;
69-
jobs?: Record<string, Job>;
70-
on?: {
71-
pull_request?: {
72-
branches?: string[];
73-
paths?: string[];
74-
};
75-
push?: {
76-
paths?: string[];
77-
};
78-
workflow_call?: unknown;
79-
};
80-
permissions?: Record<string, string>;
81-
};
19+
import type {
20+
Job,
21+
MatrixEntry,
22+
Step,
23+
Workflow,
24+
} from "./helpers/managed-image-publication-workflow-types";
8225

8326
const repoRoot = path.resolve(import.meta.dirname, "..");
8427
const fullShaAction = /^[^@]+@[0-9a-f]{40}$/iu;
@@ -1497,4 +1440,33 @@ fi
14971440
},
14981441
});
14991442
});
1443+
1444+
it("retains exact platform and aggregate cohort contracts for ninety days (#7744)", () => {
1445+
const promoter = managedPromoter(readWorkflow("managed-images.yaml"));
1446+
const uploads = (promoter.steps ?? [])
1447+
.filter((candidate) => candidate.uses?.startsWith("actions/upload-artifact@"))
1448+
.map((candidate) => candidate.with);
1449+
1450+
expect(uploads).toEqual([
1451+
{
1452+
name: "managed-image-cohort-${{ github.run_id }}-${{ github.run_attempt }}",
1453+
path: "${{ runner.temp }}/managed-image-contracts/cohort.json",
1454+
"if-no-files-found": "error",
1455+
"retention-days": 90,
1456+
},
1457+
...publicationAgents.flatMap((agent) =>
1458+
publicationPlatforms.map((platform) => {
1459+
const artifactPlatform = platform.replaceAll("/", "-");
1460+
return {
1461+
name:
1462+
"managed-image-${{ github.run_id }}-${{ github.run_attempt }}-" +
1463+
`${agent}-${artifactPlatform}`,
1464+
path: `\${{ runner.temp }}/managed-image-contracts/${agent}/${artifactPlatform}/contract.json`,
1465+
"if-no-files-found": "error",
1466+
"retention-days": 90,
1467+
};
1468+
}),
1469+
),
1470+
]);
1471+
});
15001472
});

0 commit comments

Comments
 (0)