Skip to content

Commit

Permalink
Merge pull request #77 from launchableinc/touchup
Browse files Browse the repository at this point in the history
One more round of touch-ups
  • Loading branch information
kohsuke authored Dec 29, 2020
2 parents d2b6b0e + 187c38b commit 9648410
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
23 changes: 10 additions & 13 deletions launchable/commands/record/build.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import click
import subprocess
import urllib.request
import json
import os
from ...utils.token import parse_token
Expand All @@ -13,33 +12,31 @@
@click.command()
@click.option(
'--name',
'build_number',
help='build identifier',
'build_name',
help='build name',
required=True,
type=str,
metavar='BUILD_ID'
metavar='BUILD_NAME'
)
@click.option(
'--source',
help='repository name and repository district. please specify'
'REPO_DIST like --source . '
'or REPO_NAME=REPO_DIST like --source main=./main --source lib=./main/lib',
help='path to local Git workspace, optionally prefixed by a label. '
' like --source path/to/ws or --source main=path/to/ws',
default=["."],
metavar="REPO_NAME",
multiple=True
)
@click.option('--with-commit/--without-commit', help='', default=True)
@click.pass_context
def build(ctx, build_number, source, with_commit):
def build(ctx, build_name, source):
token, org, workspace = parse_token()

# This command accepts REPO_NAME=REPO_DIST and REPO_DIST
repos = [s.split('=') if re.match(r'[^=]+=[^=]+', s) else (s, s)
for s in source]
# TODO: if repo_dist is absolute path, warn the user that that's probably not what they want to do

if with_commit:
for (name, repo_dist) in repos:
ctx.invoke(commit, source=repo_dist)
for (name, repo_dist) in repos:
ctx.invoke(commit, source=repo_dist)

sources = [(
name,
Expand Down Expand Up @@ -82,7 +79,7 @@ def build(ctx, build_number, source, with_commit):
exit('Please specify --source as --source .')

payload = {
"buildNumber": build_number,
"buildNumber": build_name,
"commitHashes": commitHashes
}

Expand Down
2 changes: 1 addition & 1 deletion launchable/commands/record/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@click.option('--source',
help="repository path",
default=os.getcwd(),
type=str
type=click.Path(exists=True, file_okay=False),
)
@click.option('--executable',
help="collect commits with Jar or Docker",
Expand Down
6 changes: 3 additions & 3 deletions launchable/commands/record/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

@click.command()
@click.option(
'--name',
'--build',
'build_name',
help='build identifier',
help='build name',
required=True,
type=str,
metavar='BUILD_ID'
metavar='BUILD_NAME'
)
def session(build_name):
token, org, workspace = parse_token()
Expand Down
14 changes: 7 additions & 7 deletions launchable/commands/record/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

@click.group()
@click.option(
'--source',
help='repository district'
'REPO_DIST like --source . ',
default=".",
metavar="REPO_NAME",
'--base',
'base_path',
help='(Advanced) base directory to make test names portable',
type=click.Path(exists=True, file_okay=False),
metavar="DIR",
)
@click.option(
'--session',
Expand All @@ -28,7 +28,7 @@
type=str,
)
@click.pass_context
def tests(context, source, session_id: str):
def tests(context, base_path, session_id: str):
if not session_id:
click.echo(
"Session ID in --session is missing. It might be caused by Launchable API errors.", err=True)
Expand All @@ -52,7 +52,7 @@ def path_builder(self, v: CaseEvent.TestPathBuilder):

def __init__(self):
self.reports = []
self.path_builder = CaseEvent.default_path_builder(source)
self.path_builder = CaseEvent.default_path_builder(base_path)

def report(self, junit_report_file: str):
"""Add one report file by its path name"""
Expand Down
4 changes: 2 additions & 2 deletions launchable/commands/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
help='subsetting target from 0% to 100%',
required=True,
type=PERCENTAGE,
default='80%',
)
@click.option(
'--session',
Expand All @@ -34,7 +33,8 @@
'--base',
'base_path',
help='(Advanced) base directory to make test names portable',
metavar="PATH",
type=click.Path(exists=True, file_okay=False),
metavar="DIR",
)
@click.pass_context
def subset(context, target, session_id, base_path):
Expand Down
6 changes: 5 additions & 1 deletion launchable/test_runners/minitest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ def parse(fname: str):
@launchable.record.tests
def record_tests(client, report_dirs):
for root in report_dirs:
client.scan(root, "*.xml")
if os.path.isdir(root):
client.scan(root, "*.xml")
else:
client.report(root)

client.run()

0 comments on commit 9648410

Please sign in to comment.