Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the tool test json blob produced by default. Add new command share_test - to publish this blob to gist (requires setting github credentials in ~/.planemo.yml) and produce a sharable URL to rich HTML report based on these results. ``` % planemo test ... All 1 test(s) executed passed. simple_constructs[0]: passed % planemo share_test File published to Github Gist. Raw URL: https://gist.githubusercontent.com/jmchilton/457933350b28a3d1e752/raw/3888694aa109e0928a93ddd414b9acadaf578dc5/index Share results with URL: http://galaxyproject.github.io/planemo/tool_test_viewer.html?test_data_url=https://gist.githubusercontent.com/jmchilton/457933350b28a3d1e752/raw/3888694aa109e0928a93ddd414b9acadaf578dc5/index Embed results with markdown: [View Tool Test Results](http://galaxyproject.github.io/planemo/tool_test_viewer.html?test_data_url=https://gist.githubusercontent.com/jmchilton/457933350b28a3d1e752/raw/3888694aa109e0928a93ddd414b9acadaf578dc5/index) ```
- Loading branch information
Showing
9 changed files
with
183 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
``share_test`` command | ||
=============================== | ||
|
||
This section is auto-generated from the help text for the planemo command | ||
``share_test``. This help message can be generated with ``planemo share_test | ||
--help``. | ||
|
||
**Usage**:: | ||
|
||
planemo share_test [OPTIONS] FILE_PATH | ||
|
||
**Help** | ||
|
||
Publish JSON test results to Github Gist and produce sharable URL. | ||
|
||
Sharable URL can be used to share an HTML version of the report that | ||
can be easily embedded in pull requests or commit messages. Requires | ||
a ~/.planemo.yml with Github 'username' and 'password' defined in a | ||
'github' section of that configuration file. | ||
|
||
**Options**:: | ||
|
||
|
||
--help Show this message and exit. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
planemo.reports package | ||
======================= | ||
|
||
Submodules | ||
---------- | ||
|
||
planemo.reports.build_report module | ||
----------------------------------- | ||
|
||
.. automodule:: planemo.reports.build_report | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: planemo.reports | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
""" | ||
""" | ||
import click | ||
|
||
from planemo.cli import pass_context | ||
from planemo.io import info | ||
from planemo import github_util | ||
|
||
target_path = click.Path( | ||
file_okay=True, | ||
dir_okay=False, | ||
resolve_path=True, | ||
) | ||
|
||
|
||
@click.command("create_gist") | ||
@click.argument( | ||
'path', | ||
metavar="FILE_PATH", | ||
type=target_path, | ||
) | ||
@click.option( | ||
"--link_type", | ||
type=click.Choice(["raw", "html"]), | ||
default="raw", | ||
help=("Link type to generate for the file.") | ||
) | ||
@pass_context | ||
def cli(ctx, path, **kwds): | ||
"""Download a tool repository as a tarball from the tool shed and extract | ||
to the specified directory. | ||
""" | ||
file_url = github_util.publish_as_gist_file(ctx, path) | ||
if kwds.get("link_type") == "raw": | ||
share_url = file_url | ||
else: | ||
share_url = "http://htmlpreview.github.io/?%s" % file_url | ||
info("File published to Github Gist - share with %s" % share_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
""" | ||
import click | ||
|
||
from planemo.cli import pass_context | ||
from planemo.io import info | ||
from planemo import github_util | ||
|
||
PLANEMO_TEST_VIEWER_URL_TEMPLATE = ( | ||
"http://galaxyproject.github.io/planemo/tool_test_viewer.html" | ||
"?test_data_url=%s" | ||
) | ||
|
||
target_path = click.Path( | ||
file_okay=True, | ||
dir_okay=False, | ||
resolve_path=True, | ||
) | ||
|
||
|
||
@click.command("share_test") | ||
@click.argument( | ||
'path', | ||
metavar="FILE_PATH", | ||
type=target_path, | ||
default="tool_test_output.json", | ||
) | ||
@pass_context | ||
def cli(ctx, path, **kwds): | ||
"""Publish JSON test results to Github Gist and produce sharable URL. | ||
Sharable URL can be used to share an HTML version of the report that | ||
can be easily embedded in pull requests or commit messages. Requires | ||
a ~/.planemo.yml with Github 'username' and 'password' defined in a | ||
'github' section of that configuration file. | ||
""" | ||
file_url = github_util.publish_as_gist_file(ctx, path) | ||
share_url = PLANEMO_TEST_VIEWER_URL_TEMPLATE % file_url | ||
info("File published to Github Gist.") | ||
info("Raw URL: %s" % file_url) | ||
info("Share results with URL: %s" % share_url) | ||
markdown = "[View Tool Test Results](%s)" % share_url | ||
info("Embed results with markdown: %s" % markdown) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
""" | ||
|
||
try: | ||
import github | ||
has_github_lib = True | ||
except ImportError: | ||
github = None | ||
has_github_lib = False | ||
|
||
NO_GITHUB_DEP_ERROR = ("Cannot use github functionality - " | ||
"PyGithub library not available.") | ||
|
||
|
||
def get_github_config(ctx): | ||
if "github" not in ctx.global_config: | ||
return None | ||
global_github_config = ctx.global_config["github"] | ||
return GithubConfig(global_github_config) | ||
|
||
|
||
class GithubConfig(object): | ||
|
||
def __init__(self, config): | ||
if not has_github_lib: | ||
raise Exception(NO_GITHUB_DEP_ERROR) | ||
self._github = github.Github(config["username"], config["password"]) | ||
|
||
|
||
def publish_as_gist_file(ctx, path, name="index"): | ||
github_config = get_github_config(ctx) | ||
user = github_config._github.get_user() | ||
content = open(path, "r").read() | ||
content_file = github.InputFileContent(content) | ||
gist = user.create_gist(False, {name: content_file}) | ||
return gist.files[name].raw_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters