Skip to content

Commit

Permalink
cli: add command to generate build status wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidalgarcia committed Nov 2, 2020
1 parent b962864 commit 80d3470
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 0 deletions.
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)
148 changes: 148 additions & 0 deletions reana/reana_dev/wiki.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# -*- 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

GITHUB_REANAHUB_URL = "https://github.com/reanahub"
CODECOV_REANAHUB_URL = "https://codecov.io/gh/reanahub"


@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": {},
"reana-auth-krb5": {},
"reana-auth-vomsproxy": {},
},
},
"examples": {
"simple": True,
"title": "Examples",
"description": "Selected reusable analysis examples.",
"packages": {
"reana-demo-alice-lego-train-test-run": {},
"reana-demo-alice-pt-analysis": {},
"reana-demo-atlas-recast": {},
"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-helloworld": {},
"reana-demo-lhcb-d2pimumu": {},
"reana-demo-lhcb-mc-production": {},
"reana-demo-root6-roofit": {},
"reana-demo-worldpopulation": {},
},
},
}

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",
"`maint-0.7`",
"`master`",
"Docs",
"Coverage",
"Version",
]
_print_header(headers)
for c, options in components.items():
table_row = f"| [{c}]({GITHUB_REANAHUB_URL}/{c}) "
if not simple:
table_row += f"| [![maint-0.7]({GITHUB_REANAHUB_URL}/{c}/workflows/CI/badge.svg?branch=maint-0.7)]({GITHUB_REANAHUB_URL}/{c}/actions?query=branch:maint-0.7) "

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 80d3470

Please sign in to comment.