Skip to content

Commit 98cf4b8

Browse files
author
Sreeparna Deb
committed
chore(ci): test auto-update plugins table
1 parent a1bc868 commit 98cf4b8

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Update Available-Plugins Table
2+
3+
on:
4+
workflow_dispatch: # manual trigger
5+
push:
6+
branches:
7+
- test-auto-update-available-plugins
8+
9+
jobs:
10+
regen-table:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.x'
22+
23+
- name: Install dependencies
24+
run: pip install requests
25+
26+
- name: Generate plugins table
27+
env:
28+
CORE_PREFIX: ${{ secrets.CORE_PREFIX }}
29+
run: |
30+
python scripts/gen_dev_wiki_table.py > Available-Plugins.md
31+
32+
- name: Commit & push changes
33+
uses: stefanzweifel/git-auto-commit-action@v4
34+
with:
35+
commit_message: "chore: auto-update Available-Plugins.md"
36+
file_pattern: Available-Plugins.md
37+
branch: test-auto-update-available-plugins

scripts/gen_dev_wiki_table.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
import subprocess
5+
import requests
6+
import json
7+
8+
OWNER = "ManiVaultStudio"
9+
REPOS = [
10+
("Scatterplot", "View", "master"),
11+
("ImageViewerPlugin", "View", "master"),
12+
("HeatMap", "View", "master"),
13+
("ParallelCoordinatesPlugin", "View", "master"),
14+
("SpectralViewPlugin", "View", "main"),
15+
("t-SNE-Analysis", "Analysis", "master"),
16+
("MeanShiftClustering", "Analysis", "master"),
17+
("PcaPlugin", "Analysis", "main"),
18+
("SpidrPlugin", "Analysis", "main"),
19+
("BinIO", "IO", "master"),
20+
("ExtCsvLoader", "IO", "main"),
21+
("ImageLoaderPlugin", "IO", "master"),
22+
("HDF5Loader", "IO", "master"),
23+
("UMAP-Plugin", "Analysis", "main"),
24+
]
25+
26+
CORE_PREFIX = os.environ.get("CORE_PREFIX")
27+
if not CORE_PREFIX:
28+
sys.exit("ERROR: Please set CORE_PREFIX, e.g. export CORE_PREFIX=release/core_1.3/")
29+
30+
# Derive core version
31+
core_ver = CORE_PREFIX.removeprefix("release/core_").rstrip("/")
32+
33+
# Markdown header
34+
lines = [
35+
"| Plugin | Type | Compatible Core | Version | Active | Status |",
36+
"|--------|:----:|:--------:|:----------------:|:------:|:------:|",
37+
]
38+
39+
# Helpers
40+
def fetch_json(url):
41+
r = requests.get(url, timeout=10)
42+
return r.json() if r.status_code == 200 else None
43+
44+
for repo, ptype, branch in REPOS:
45+
# badges
46+
active = f"![last commit](https://img.shields.io/github/last-commit/{OWNER}/{repo}/{branch})"
47+
status = f"![ci-build](https://github.com/{OWNER}/{repo}/actions/workflows/build.yml/badge.svg?branch={branch})"
48+
49+
# Try PluginInfo.json
50+
info_url = f"https://raw.githubusercontent.com/{OWNER}/{repo}/{branch}/PluginInfo.json"
51+
info = fetch_json(info_url)
52+
53+
if info:
54+
plugin_name = info.get("name", repo)
55+
core_version = ", ".join(info.get("version", {}).get("core", [])) or core_ver
56+
plugin_version = info.get("version", {}).get("plugin", "N/A")
57+
else:
58+
plugin_name = repo
59+
core_version = core_ver
60+
61+
# Fetch branches
62+
api_url = f"https://api.github.com/repos/{OWNER}/{repo}/branches?per_page=100"
63+
branches = fetch_json(api_url) or []
64+
suffixes = [
65+
b["name"].removeprefix(CORE_PREFIX)
66+
for b in branches
67+
if b["name"].startswith(CORE_PREFIX)
68+
]
69+
plugin_version = ", ".join(suffixes) if suffixes else "N/A"
70+
71+
lines.append(
72+
f"| [{plugin_name}](https://github.com/{OWNER}/{repo})"
73+
f" | {ptype} | {core_version} | {plugin_version}"
74+
f" | {active} | {status} |"
75+
)
76+
77+
print("\n".join(lines))

0 commit comments

Comments
 (0)