Skip to content

Commit 9219cfc

Browse files
durandomcursoragent
andcommitted
[#5] ci: derive catalog packages from the todo allow-list
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a86d05c commit 9219cfc

5 files changed

Lines changed: 116 additions & 47 deletions

File tree

‎.github/workflows/generate-catalog-index.yaml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
- 'default.packages.yaml'
1212
- 'rhdh-supported-packages.txt'
1313
- 'rhdh-community-packages.txt'
14-
- 'parasol-community-packages.txt'
14+
- 'parasol-publish-workspaces.txt'
1515
- 'scripts/**'
1616
- 'versions.json'
1717
- '.github/workflows/generate-catalog-index.yaml'
@@ -142,12 +142,13 @@ jobs:
142142
- name: Generate community catalog
143143
id: gen-community
144144
run: |
145+
python3 scripts/parasol-allow-list.py --packages-file /tmp/parasol-packages.txt
145146
if scripts/update-index.sh \
146147
--overlays-dir . \
147148
--registry "$COMMUNITY_REGISTRY" \
148149
--output-dir catalog-index/community \
149150
--plugin-builds-dir plugin_builds/community \
150-
--packages-file parasol-community-packages.txt \
151+
--packages-file /tmp/parasol-packages.txt \
151152
--report-file catalog-index/community/build-report.json; then
152153
echo "ok=true" >> "$GITHUB_OUTPUT"
153154
else

‎.github/workflows/publish-release-branch-workspace-plugins.yaml‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,7 @@ jobs:
3636
id: list
3737
env:
3838
WORKSPACE_PATH: ${{ inputs.workspace-path }}
39-
run: |
40-
python3 <<'PY'
41-
import json
42-
import os
43-
import sys
44-
from pathlib import Path
45-
46-
explicit = os.environ.get("WORKSPACE_PATH", "").strip()
47-
if explicit:
48-
workspaces = [explicit]
49-
else:
50-
workspaces = []
51-
path = Path("parasol-publish-workspaces.txt")
52-
if path.is_file():
53-
for raw in path.read_text(encoding="utf-8").splitlines():
54-
line = raw.split("#", 1)[0].strip()
55-
if not line:
56-
continue
57-
if not line.startswith("workspaces/"):
58-
line = f"workspaces/{line}"
59-
workspaces.append(line)
60-
else:
61-
print(
62-
"::warning::parasol-publish-workspaces.txt is missing; publishing nothing",
63-
file=sys.stderr,
64-
)
65-
66-
print(f"Workspaces to publish: {json.dumps(workspaces)}", file=sys.stderr)
67-
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
68-
fh.write("workspaces=" + json.dumps(workspaces) + "\n")
69-
PY
39+
run: python3 scripts/parasol-allow-list.py --workspaces-json
7040

7141
prepare:
7242
runs-on: ubuntu-latest

‎parasol-community-packages.txt‎

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

‎parasol-publish-workspaces.txt‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# Fork allow-list for automatic OCI publish (issue #5).
21
# One workspace directory name per line (under workspaces/).
3-
# Comments and blank lines are ignored.
4-
#
5-
# Automatic publish on main / release-* and Create Release Branch export
6-
# only these workspaces. An empty list publishes nothing (no full sweep).
7-
# Expand by adding more names; do not remove this file.
2+
# To publish another: add the name here, and point that workspace's
3+
# metadata spec.dynamicArtifact at ghcr.io/rhdh-parasol/rhdh-plugin-export-overlays/...
84
todo

‎scripts/parasol-allow-list.py‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env python3
2+
"""Expand parasol-publish-workspaces.txt for publish CI and catalog-index.
3+
4+
Adding a workspace: put its directory name in parasol-publish-workspaces.txt
5+
and retarget that workspace's metadata dynamicArtifact to this fork's GHCR.
6+
"""
7+
8+
from __future__ import annotations
9+
10+
import argparse
11+
import json
12+
import os
13+
import sys
14+
from pathlib import Path
15+
16+
ALLOW_LIST_NAME = "parasol-publish-workspaces.txt"
17+
18+
19+
def _listed_names(root: Path) -> list[str]:
20+
path = root / ALLOW_LIST_NAME
21+
if not path.is_file():
22+
return []
23+
names: list[str] = []
24+
for raw in path.read_text(encoding="utf-8").splitlines():
25+
line = raw.split("#", 1)[0].strip()
26+
if not line:
27+
continue
28+
names.append(line.removeprefix("workspaces/"))
29+
return names
30+
31+
32+
def workspace_paths(root: Path) -> list[str]:
33+
return [f"workspaces/{name}" for name in _listed_names(root)]
34+
35+
36+
def package_lines(root: Path) -> list[str]:
37+
lines: list[str] = []
38+
for name in _listed_names(root):
39+
plugins_list = root / "workspaces" / name / "plugins-list.yaml"
40+
if not plugins_list.is_file():
41+
print(
42+
f"warning: missing {plugins_list}, skipping",
43+
file=sys.stderr,
44+
)
45+
continue
46+
for raw in plugins_list.read_text(encoding="utf-8").splitlines():
47+
line = raw.split("#", 1)[0].strip()
48+
if not line or ":" not in line:
49+
continue
50+
plugin_path = line.split(":", 1)[0].strip().strip("'\"")
51+
if plugin_path:
52+
lines.append(f"{name}/{plugin_path}")
53+
return lines
54+
55+
56+
def main() -> int:
57+
parser = argparse.ArgumentParser(description=__doc__)
58+
parser.add_argument(
59+
"--root",
60+
type=Path,
61+
default=Path("."),
62+
help="Overlay repo root",
63+
)
64+
parser.add_argument(
65+
"--workspace-path",
66+
default="",
67+
help="If set, publish only this workspace (overrides the allow-list)",
68+
)
69+
group = parser.add_mutually_exclusive_group(required=True)
70+
group.add_argument(
71+
"--workspaces-json",
72+
action="store_true",
73+
help="Print GitHub output workspaces=<json array of workspaces/name>",
74+
)
75+
group.add_argument(
76+
"--packages-file",
77+
type=Path,
78+
help="Write catalog --packages-file lines (workspace/plugins/...)",
79+
)
80+
args = parser.parse_args()
81+
root = args.root.resolve()
82+
83+
if args.workspaces_json:
84+
explicit = (args.workspace_path or os.environ.get("WORKSPACE_PATH", "")).strip()
85+
if explicit:
86+
if not explicit.startswith("workspaces/"):
87+
explicit = f"workspaces/{explicit}"
88+
paths = [explicit]
89+
else:
90+
paths = workspace_paths(root)
91+
print(f"Workspaces to publish: {json.dumps(paths)}", file=sys.stderr)
92+
gh_output = os.environ.get("GITHUB_OUTPUT")
93+
if gh_output:
94+
with open(gh_output, "a", encoding="utf-8") as fh:
95+
fh.write("workspaces=" + json.dumps(paths) + "\n")
96+
else:
97+
print(json.dumps(paths))
98+
return 0
99+
100+
lines = package_lines(root)
101+
args.packages_file.write_text(
102+
"\n".join(lines) + ("\n" if lines else ""),
103+
encoding="utf-8",
104+
)
105+
print(f"Wrote {len(lines)} package path(s) to {args.packages_file}", file=sys.stderr)
106+
return 0
107+
108+
109+
if __name__ == "__main__":
110+
raise SystemExit(main())

0 commit comments

Comments
 (0)