open-atmos / devops_tests

pytest test routines asserting for GitHub issue-linked TODO labelling in the code, README link consistency and some Jupyter notebook sanity checks
GNU General Public License v3.0
0 stars 2 forks source link

check all notebooks linked from README #7

Closed slayoo closed 3 months ago

slayoo commented 1 year ago

something like this would do:

def _relative_path(absolute_path):
    return os.path.relpath(
        absolute_path,
        pathlib.Path(__file__).parent.parent.parent.absolute()
    )

def _nbviewer_badge_markdown(absolute_path):
    svg_badge_url = "https://raw.githubusercontent.com/jupyter/design/master/logos/Badges/nbviewer_badge.svg"
    link = f"https://nbviewer.jupyter.org/github/open-atmos/PySDM/blob/main/{_relative_path(absolute_path)}"
    return f"[![preview in nbviewer]({svg_badge_url})]({link})"

def _mybinder_badge_markdown(abslute_path):
    svg_badge_url = "https://mybinder.org/badge_logo.svg"
    link = f"https://mybinder.org/v2/gh/open-atmos/PySDM.git/main?urlpath=lab/tree/{_relative_path(abslute_path)}"
    return f"[![launch on mybinder.org]({svg_badge_url})]({link})"

def _colab_badge_markdown(absolute_path):
    svg_badge_url = "https://colab.research.google.com/assets/colab-badge.svg"
    link = f"https://colab.research.google.com/github/open-atmos/PySDM/blob/main/{_relative_path(absolute_path)}"
    return f"[![launch on Colab]({svg_badge_url})]({link})"

class TestExampleNotebooks:
    @staticmethod
    def test_all_linked_from_readme(notebook):
        if os.path.basename(notebook).startswith('_'):
            return
        with open(pathlib.Path(__file__).parent.parent.parent / "README.md") as fp:
            readme_contents = fp.read()
            assert _colab_badge_markdown(notebook) in readme_contents
            assert _mybinder_badge_markdown(notebook) in readme_contents
            assert _nbviewer_badge_markdown(notebook) in readme_contents
github-actions[bot] commented 11 months ago

Stale issue message

github-actions[bot] commented 9 months ago

Stale issue message

github-actions[bot] commented 6 months ago

Stale issue message

github-actions[bot] commented 3 months ago

Stale issue message