-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trello release status subcommand (#6628)
* Add count option for trello cards * Add separate status subcommand * Fix style * Add the actual script * Format docstrings and add totals row * Refactor scripts under trello subcommand * Reformat output and copy to clipboard * Include init * Cleanup and add clipboard option * fix tox
- Loading branch information
1 parent
12fb73c
commit 7196c7f
Showing
6 changed files
with
154 additions
and
19 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
32 changes: 32 additions & 0 deletions
32
datadog_checks_dev/datadog_checks/dev/tooling/commands/release/trello/__init__.py
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,32 @@ | ||
# (C) Datadog, Inc. 2020-present | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
|
||
import click | ||
|
||
from ...console import CONTEXT_SETTINGS | ||
from .status import status | ||
from .testable import testable | ||
|
||
ALL_COMMANDS = [status, testable] | ||
|
||
|
||
@click.group(context_settings=CONTEXT_SETTINGS, short_help='Tools for interacting with Trello') | ||
def trello(): | ||
""" | ||
Subcommands for interacting with Trello Release boards. | ||
\b | ||
To use Trello: | ||
1. Go to `https://trello.com/app-key` and copy your API key. | ||
2. Run `ddev config set trello.key` and paste your API key. | ||
3. Go to `https://trello.com/1/authorize?key=key&name=name&scope=read,write&expiration=never&response_type=token`, | ||
where `key` is your API key and `name` is the name to give your token, e.g. ReleaseTestingYourName. | ||
Authorize access and copy your token. | ||
4. Run `ddev config set trello.token` and paste your token. | ||
""" | ||
pass | ||
|
||
|
||
for command in ALL_COMMANDS: | ||
trello.add_command(command) |
65 changes: 65 additions & 0 deletions
65
datadog_checks_dev/datadog_checks/dev/tooling/commands/release/trello/status.py
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,65 @@ | ||
# (C) Datadog, Inc. 2018-present | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
|
||
import json | ||
|
||
import click | ||
import pyperclip | ||
|
||
from ....trello import TrelloClient | ||
from ...console import CONTEXT_SETTINGS, echo_info, echo_success | ||
|
||
|
||
@click.command(context_settings=CONTEXT_SETTINGS, short_help='Gather statistics from the Trello release board') | ||
@click.option('--json', '-j', 'as_json', is_flag=True, help='Return as raw JSON instead') | ||
@click.option('--clipboard', '-c', is_flag=True, help='Copy output to clipboard') | ||
@click.pass_context | ||
def status(ctx: click.Context, as_json: bool, clipboard: bool) -> None: | ||
"""Print tabular status of Agent Release based on Trello columns. | ||
See trello subcommand for details on how to setup access: | ||
`ddev release trello -h`. | ||
""" | ||
|
||
user_config = ctx.obj | ||
trello = TrelloClient(user_config) | ||
|
||
counts = trello.count_by_columns() | ||
|
||
row_format = '{:30} | {:<15} | {:<15} | {:<15} | {:<15} | {}' | ||
headers = ('Total', 'In Progress', 'Issues Found', 'Awaiting Build', 'Done') | ||
|
||
if as_json: | ||
print(json.dumps(counts, indent=2)) | ||
return | ||
|
||
totals = dict(zip(headers, [0] * len(headers))) | ||
|
||
output = [] | ||
output.append(row_format.format('Team', *headers)) | ||
output.append(row_format.format('--', *['--' for _ in headers])) | ||
|
||
for team, data in counts.items(): | ||
for header in headers: | ||
totals[header] += data[header] | ||
row = row_format.format(team, *[data[header] for header in headers]) | ||
output.append(row) | ||
|
||
output.append(row_format.format('--', *['--' for _ in headers])) | ||
row = row_format.format('TOTALS', *[totals[header] for header in headers]) | ||
output.append(row) | ||
|
||
out = '\n'.join(output) | ||
|
||
msg = '\nTrello Status Report:\n' | ||
if clipboard: | ||
try: | ||
pyperclip.copy(out) | ||
msg = '\nTrello Status Report (copied to your clipboard):\n' | ||
except Exception: | ||
pass | ||
|
||
echo_success(msg) | ||
echo_info(out) |
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
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