Skip to content

Commit

Permalink
cli: add command to generate build status wiki
Browse files Browse the repository at this point in the history
closes #435
  • Loading branch information
mvidalgarcia committed Nov 6, 2020
1 parent e49e017 commit 37e906f
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 4 deletions.
29 changes: 27 additions & 2 deletions reana/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,30 @@

"""``reana-dev`` CLI configuration."""

REPO_LIST_DEMO = [
REPO_LIST_DEMO_RUNNABLE = [
"reana-demo-helloworld",
"reana-demo-root6-roofit",
"reana-demo-worldpopulation",
"reana-demo-atlas-recast",
]
"""All git repositories containing REANA runnable demos."""

REANA_LIST_DEMO_ALL = REPO_LIST_DEMO_RUNNABLE + [
"reana-demo-alice-lego-train-test-run",
"reana-demo-alice-pt-analysis",
"reana-demo-bsm-search",
"reana-demo-cdci-crab-pulsar-integral-verification",
"reana-demo-cdci-integral-data-reduction",
"reana-demo-cms-h4l",
"reana-demo-cms-reco",
"reana-demo-cms-dimuon-mass-spectrum",
"reana-demo-fcchh-fullsim",
"reana-demo-lhcb-d2pimumu",
"reana-demo-lhcb-mc-production",
]
"""All git repositories containing REANA demos."""


REPO_LIST_ALL = [
"docs.reana.io",
"reana",
Expand Down Expand Up @@ -47,7 +63,7 @@
"reana-workflow-engine-yadage",
"reana-workflow-monitor",
"www.reana.io",
] + REPO_LIST_DEMO
] + REPO_LIST_DEMO_RUNNABLE
"""All REANA git repositories."""

REPO_LIST_CLIENT = [
Expand Down Expand Up @@ -187,3 +203,12 @@

GIT_DEFAULT_BASE_BRANCH = "master"
"""Default git base branch we shall be working against."""

GIT_SUPPORTED_MAINT_BRANCHES = ["maint-0.7"]
"""Git supported maintenance branches."""

GITHUB_REANAHUB_URL = "https://github.com/reanahub"
"""REANA Hub organisation GitHub URL."""

CODECOV_REANAHUB_URL = "https://codecov.io/gh/reanahub"
"""REANA Hub organisation Codecov URL."""
2 changes: 2 additions & 0 deletions reana/reana_dev/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from reana.reana_dev.python import python_commands_list
from reana.reana_dev.release import release_commands_list
from reana.reana_dev.run import run_commands_list
from reana.reana_dev.wiki import wiki_commands_list


@click.group()
Expand Down Expand Up @@ -188,5 +189,6 @@ def help():
+ run_commands_list
+ release_commands_list
+ helm_commands_list
+ wiki_commands_list
):
reana_dev.add_command(cmd)
4 changes: 2 additions & 2 deletions reana/reana_dev/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
REPO_LIST_ALL,
REPO_LIST_CLIENT,
REPO_LIST_CLUSTER,
REPO_LIST_DEMO,
REPO_LIST_DEMO_RUNNABLE,
)

INSTANCE_NAME = os.path.basename(os.environ["VIRTUAL_ENV"])
Expand Down Expand Up @@ -197,7 +197,7 @@ def select_components(components, exclude_components=None):
for repo in REPO_LIST_ALL:
output.add(repo)
elif component == "DEMO":
for repo in REPO_LIST_DEMO:
for repo in REPO_LIST_DEMO_RUNNABLE:
output.add(repo)
elif component == "CLIENT":
for repo in REPO_LIST_CLIENT:
Expand Down
141 changes: 141 additions & 0 deletions reana/reana_dev/wiki.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2020 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""`reana-dev`'s wiki commands."""

import click

from reana.config import (
CODECOV_REANAHUB_URL,
GIT_SUPPORTED_MAINT_BRANCHES,
GITHUB_REANAHUB_URL,
REANA_LIST_DEMO_ALL,
)


@click.group()
def wiki_commands():
"""Wiki commands group."""


@wiki_commands.command(name="wiki-create-build-status-page")
def create_build_status_page():
"""Generate Markdown for the Build Status wiki page."""
sections = {
"researchers": {
"title": "For researchers",
"description": "Find out how you can use REANA to describe, run, preserve and reuse your analyses.",
"packages": {
"reana-client": {},
"docs.reana.io": {"coverage": False, "docs": False},
"www.reana.io": {"coverage": False, "docs": False},
},
},
"administrators": {
"title": "For administrators",
"description": "Install and manage the REANA reusable analysis platform on your own compute cloud.",
"packages": {
"reana-commons": {},
"reana-db": {},
"reana-job-controller": {},
"reana-message-broker": {},
"reana-server": {},
"reana-ui": {},
"reana-workflow-controller": {},
"reana-workflow-engine-cwl": {},
"reana-workflow-engine-serial": {},
"reana-workflow-engine-yadage": {},
"reana-workflow-monitor": {},
},
},
"developers": {
"title": "For developers",
"description": "Understand REANA source code, adapt it to your needs, contribute changes back.",
"packages": {"reana": {}, "pytest-reana": {}},
},
"environments": {
"simple": True,
"title": "Environments",
"description": "Selected containerised environments.",
"packages": {
"reana-env-aliphysics": {},
"reana-env-jupyter": {},
"reana-env-root6": {},
},
},
"authentication": {
"simple": True,
"title": "Authentication",
"description": "Selected authentication environments.",
"packages": {"reana-auth-krb5": {}, "reana-auth-vomsproxy": {},},
},
"examples": {
"simple": True,
"title": "Examples",
"description": "Selected reusable analysis examples.",
"packages": {demo: {} for demo in sorted(REANA_LIST_DEMO_ALL)},
},
}

def _print_section(data):
click.echo(f"### {data['title']}\n")
click.echo(f"{data['description']}\n")
_print_table(data["packages"], simple=data.get("simple"))
click.echo()

def _print_header(hs):
header = separator = "|"
for h in hs:
header += f" {h} |"
separator += f" {'-' * len(h)} |"
click.echo(header)
click.echo(separator)

def _print_table(components, simple=False):
if simple:
headers = ["Package", "Build", "Version"]
else:
headers = [
"Package",
"`master`",
"Docs",
"Coverage",
"Version",
]
headers[1:1] = [f"`{branch}`" for branch in GIT_SUPPORTED_MAINT_BRANCHES]
_print_header(headers)
for c, options in components.items():
table_row = f"| [{c}]({GITHUB_REANAHUB_URL}/{c}) "
if not simple:
for branch in GIT_SUPPORTED_MAINT_BRANCHES:
table_row += f"| [![{branch}]({GITHUB_REANAHUB_URL}/{c}/workflows/CI/badge.svg?branch={branch})]({GITHUB_REANAHUB_URL}/{c}/actions?query=branch:{branch}) "

table_row += f"| [![master]({GITHUB_REANAHUB_URL}/{c}/workflows/CI/badge.svg?branch=master)]({GITHUB_REANAHUB_URL}/{c}/actions?query=branch:master) "

if not simple:
table_row += (
f"| [![Docs](https://readthedocs.org/projects/{c}/badge/?version=latest)](https://{c}.readthedocs.io/en/latest/?badge=latest) "
if options.get("docs", True)
else "| N/A "
) + (
f"| [![Coverage]({CODECOV_REANAHUB_URL}/{c}/branch/master/graph/badge.svg)]({CODECOV_REANAHUB_URL}/{c}) "
if options.get("coverage", True)
else "| N/A "
)

table_row += f"| [![Tag](https://img.shields.io/github/tag/reanahub/{c}.svg)]({GITHUB_REANAHUB_URL}/{c}/releases) |"

click.echo(table_row)
click.echo()

click.echo("# REANA build status\n")
for section, data in sections.items():
_print_section(data)


wiki_commands_list = list(wiki_commands.commands.values())

0 comments on commit 37e906f

Please sign in to comment.