From 6586978012bf29e5ce3cc670c45a9e752744cf29 Mon Sep 17 00:00:00 2001 From: danielperezz Date: Sun, 16 Nov 2025 18:22:22 +0200 Subject: [PATCH 1/6] fix --- .github/workflows/test-all.yaml | 9 ++++++++- cli/README.md | 4 ++-- cli/common/update_readme.py | 17 ++++++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 162804863..91c56ce8e 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -6,6 +6,7 @@ on: branches: - development - master + - readmes-broken-links workflow_dispatch: {} jobs: @@ -116,6 +117,10 @@ jobs: permissions: contents: write steps: + - name: Get the current branch name + shell: bash + run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT + id: branch - uses: actions/checkout@v4 with: fetch-depth: 0 @@ -128,7 +133,9 @@ jobs: pip install --upgrade pip pip install -r requirements.txt - name: Regenerate README tables - run: python -m cli.cli update-readme --asset functions --asset modules + env: + CHANNEL: ${{ steps.branch.outputs.branch }} + run: python -m cli.cli update-readme $CHANNEL --asset functions --asset modules - name: Commit & push (if changed) env: USERNAME: ${{ secrets.USERNAME }} diff --git a/cli/README.md b/cli/README.md index 4a3cd3bfc..31443b132 100644 --- a/cli/README.md +++ b/cli/README.md @@ -60,7 +60,7 @@ Example: Regenerate the `README.md` files in each of the asset directories (functions/modules). Usage: - `python -m cli.cli update-readme --asset TYPE` + `python -m cli.cli update-readme -c CHANNEL --asset TYPE` Example: - `python -m cli.cli update-readme --asset functions --asset modules` \ No newline at end of file + `python -m cli.cli update-readme -c master --asset functions --asset modules` \ No newline at end of file diff --git a/cli/common/update_readme.py b/cli/common/update_readme.py index 6bcab8d33..89b6aa094 100644 --- a/cli/common/update_readme.py +++ b/cli/common/update_readme.py @@ -25,6 +25,7 @@ COLUMNS = ("Name", "Description", "Kind", "Categories") @click.command("update-readme") +@click.option("-c", "--channel", default="master", help="Name of build channel") @click.option( "--asset", multiple=True, @@ -34,7 +35,7 @@ ) @click.option("--check", is_flag=True, help="Do not write; exit non‑zero if README(s) would change.") -def update_readme(asset: Iterable[str], +def update_readme(channel: str, asset: Iterable[str], check: bool) -> None: """ Regenerate the README tables for asset types from their item.yaml files. @@ -50,7 +51,7 @@ def update_readme(asset: Iterable[str], root = Path(".").resolve() asset_dir = root / t readme = asset_dir / "README.md" - rows = _rows_for_asset_type(asset_dir) + rows = _rows_for_asset_type(channel, asset_dir) table_md = _build_table_md(rows) old = readme.read_text() if readme.exists() else f"# {t.title()}\n\n" new = _replace_block(old, table_md) @@ -58,7 +59,7 @@ def update_readme(asset: Iterable[str], changed_any = True touched.append(str(readme)) else: - if _update_one(t): + if _update_one(channel, t): changed_any = True touched.append(str((Path(t) / "README.md").as_posix())) @@ -78,7 +79,7 @@ def update_readme(asset: Iterable[str], click.echo("No README changes.") -def _rows_for_asset_type(asset_dir: Path) -> List[Tuple[str, str, str, str]]: +def _rows_for_asset_type(channel: str, asset_dir: Path) -> List[Tuple[str, str, str, str]]: """Scan /src/*/item.yaml and return table rows.""" src = asset_dir / "src" if not src.exists(): @@ -97,7 +98,9 @@ def _rows_for_asset_type(asset_dir: Path) -> List[Tuple[str, str, str, str]]: cats = data.get("categories") or [] cats_str = ", ".join(c.strip() for c in cats) if isinstance(cats, list) else str(cats).strip() # Link the name to its source directory - link = f"[{asset_name}]({(asset_dir / 'src' / asset_name).as_posix()})" + # Construct the relative path from the repo root for the asset + rel_path = asset_dir.relative_to(Path(".").resolve()) + link = f"[{asset_name}](https://github.com/mlrun/functions/tree/{channel}/{rel_path}/src/{asset_name})" rows.append((link, desc, kind, cats_str)) rows.sort(key=lambda r: r[0].lower()) @@ -140,13 +143,13 @@ def _replace_block(readme_text: str, new_block: str) -> str: return readme_text[:start_close] + "\n" + new_block + "\n" + readme_text[ei:] -def _update_one(asset_type: str) -> bool: +def _update_one(channel: str, asset_type: str) -> bool: """Generate/replace the table in /README.md. Return True if changed.""" root = Path(".").resolve() asset_dir = root / asset_type readme = asset_dir / "README.md" - rows = _rows_for_asset_type(asset_dir) + rows = _rows_for_asset_type(channel, asset_dir) table_md = _build_table_md(rows) old = readme.read_text() if readme.exists() else f"# {asset_type.title()}\n\n" new = _replace_block(old, table_md) From 9c8fa045b836692aa23344631e1874b53ba632c2 Mon Sep 17 00:00:00 2001 From: danielperezz Date: Mon, 17 Nov 2025 09:23:45 +0200 Subject: [PATCH 2/6] test fix --- .github/workflows/test-all.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 91c56ce8e..993e1bef6 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -78,6 +78,7 @@ jobs: run_monorepo_tests: needs: build_strategy_matrix + if: github.repository == 'mlrun/functions' || github.repository == 'mlrun/hub-assets' runs-on: ubuntu-latest strategy: # matrix: [{"package": some package that changed}, {...}, ...] @@ -111,8 +112,6 @@ jobs: # run: python functions/cli/cli.py run-tests -r functions -s ipynb update_readmes: - needs: build_strategy_matrix - if: github.repository == 'mlrun/functions' || github.repository == 'mlrun/hub-assets' runs-on: ubuntu-latest permissions: contents: write From b3154fc5a65102bc6a8557a583d4675713ee54ab Mon Sep 17 00:00:00 2001 From: danielperezz Date: Mon, 17 Nov 2025 09:26:03 +0200 Subject: [PATCH 3/6] test fix --- .github/workflows/test-all.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 993e1bef6..4f6114264 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -134,7 +134,7 @@ jobs: - name: Regenerate README tables env: CHANNEL: ${{ steps.branch.outputs.branch }} - run: python -m cli.cli update-readme $CHANNEL --asset functions --asset modules + run: python -m cli.cli update-readme -c $CHANNEL --asset functions --asset modules - name: Commit & push (if changed) env: USERNAME: ${{ secrets.USERNAME }} From e889121cc4e096159c67587e1152f9a69283bada Mon Sep 17 00:00:00 2001 From: danielperezz Date: Mon, 17 Nov 2025 09:32:28 +0200 Subject: [PATCH 4/6] test fix --- .github/workflows/test-all.yaml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 4f6114264..7e7af45de 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -135,20 +135,13 @@ jobs: env: CHANNEL: ${{ steps.branch.outputs.branch }} run: python -m cli.cli update-readme -c $CHANNEL --asset functions --asset modules - - name: Commit & push (if changed) - env: - USERNAME: ${{ secrets.USERNAME }} - USEREMAIL: ${{ secrets.USERMAIL }} - run: | - if git diff --quiet; then - echo "No README changes." - exit 0 - fi - git config --local user.name $USERNAME - git config --local user.email $USEREMAIL - git add functions/README.md modules/README.md || true - git commit -m "chore(readme): auto-update asset tables [skip ci]" - git push + - name: Upload updated READMEs as artifact + uses: actions/upload-artifact@v4 + with: + name: updated-readmes + path: | + functions/README.md + modules/README.md build-marketplace: name: Build marketplace From 42ec47b3afd3b3faa11e4dadb4e4740bf3f7b347 Mon Sep 17 00:00:00 2001 From: danielperezz Date: Mon, 17 Nov 2025 09:33:55 +0200 Subject: [PATCH 5/6] test fix --- .github/workflows/test-all.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index 7e7af45de..e8842d866 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -135,13 +135,13 @@ jobs: env: CHANNEL: ${{ steps.branch.outputs.branch }} run: python -m cli.cli update-readme -c $CHANNEL --asset functions --asset modules - - name: Upload updated READMEs as artifact - uses: actions/upload-artifact@v4 - with: - name: updated-readmes - path: | - functions/README.md - modules/README.md + - name: Upload updated READMEs as artifact + uses: actions/upload-artifact@v4 + with: + name: updated-readmes + path: | + functions/README.md + modules/README.md build-marketplace: name: Build marketplace From aaaba0d8f8bf9df655f8fff9572901f17227b84f Mon Sep 17 00:00:00 2001 From: danielperezz Date: Mon, 17 Nov 2025 09:40:55 +0200 Subject: [PATCH 6/6] final workflow --- .github/workflows/test-all.yaml | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test-all.yaml b/.github/workflows/test-all.yaml index e8842d866..d8eb6c6ed 100644 --- a/.github/workflows/test-all.yaml +++ b/.github/workflows/test-all.yaml @@ -6,7 +6,6 @@ on: branches: - development - master - - readmes-broken-links workflow_dispatch: {} jobs: @@ -78,7 +77,6 @@ jobs: run_monorepo_tests: needs: build_strategy_matrix - if: github.repository == 'mlrun/functions' || github.repository == 'mlrun/hub-assets' runs-on: ubuntu-latest strategy: # matrix: [{"package": some package that changed}, {...}, ...] @@ -112,6 +110,8 @@ jobs: # run: python functions/cli/cli.py run-tests -r functions -s ipynb update_readmes: + needs: build_strategy_matrix + if: github.repository == 'mlrun/functions' || github.repository == 'mlrun/hub-assets' runs-on: ubuntu-latest permissions: contents: write @@ -135,13 +135,20 @@ jobs: env: CHANNEL: ${{ steps.branch.outputs.branch }} run: python -m cli.cli update-readme -c $CHANNEL --asset functions --asset modules - - name: Upload updated READMEs as artifact - uses: actions/upload-artifact@v4 - with: - name: updated-readmes - path: | - functions/README.md - modules/README.md + - name: Commit & push (if changed) + env: + USERNAME: ${{ secrets.USERNAME }} + USEREMAIL: ${{ secrets.USERMAIL }} + run: | + if git diff --quiet; then + echo "No README changes." + exit 0 + fi + git config --local user.name $USERNAME + git config --local user.email $USEREMAIL + git add functions/README.md modules/README.md || true + git commit -m "chore(readme): auto-update asset tables [skip ci]" + git push build-marketplace: name: Build marketplace