Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TESTING: Hit Class #331

Merged
merged 9 commits into from
Jun 17, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@ jobs:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
MAXIMUM_ISSUES_GENERATED: 10
run: |
echo "Generate GitHub issues for each problem found, but don't fail the workflow"
todoon -is
echo "Generate GitHub issues for each problem found, but don't fail the workflow unless one is found that has already been closed."
todoon -si
- name: Check duplicate closed issues
run: |
if [ "${{ env.TODOON_DUPLICATE_CLOSED_ISSUES }}" != "1" ]; then
echo "Detected ${{ env.TODOON_DUPLICATE_CLOSED_ISSUES }} duplicate closed issues where we expected exactly one (an example), failing this workflow!"
exit 1
fi
37 changes: 37 additions & 0 deletions .github/workflows/todoon-issues-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Generate issues with UNSTABLE VERSION of TODO-or-not from test.PyPi

on:
workflow_dispatch:
jobs:
run_todoon:
runs-on: ubuntu-latest
environment: testing
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11.7
uses: actions/setup-python@v3
with:
python-version: "3.11.7"
- name: Install UNSTABLE TODO-or-not from test.PyPi
run: |
python -m pip install --upgrade pip
python -m pip install -i https://test.pypi.org/simple/ todo-or-not - name: Generate GH Token for todoon app
- name: Generate GH Token for todoon app
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: 853479
private-key: ${{ secrets.TODOON_CLIENT_PEM }}
- name: Run TODO-or-not
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
MAXIMUM_ISSUES_GENERATED: 10
run: |
echo "Generate GitHub issues for each problem found, but don't fail the workflow unless one is found that has already been closed."
todoon -si
- name: Check duplicate closed issues
run: |
if [ "${{ env.TODOON_DUPLICATE_CLOSED_ISSUES }}" != "1" ]; then
echo "Detected ${{ env.TODOON_DUPLICATE_CLOSED_ISSUES }} duplicate closed issues where we expected exactly one (an example), failing this workflow!"
exit 1
fi
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "todo-or-not"
version = "0.13.0"
version = "0.13.9"
description = "todoon integrates the TODOs in your codebase with your GitHub repository"
authors = ["TrentonYo <trentonyo@gmail.com>"]
license = "GPL-3.0-only"
Expand Down
19 changes: 19 additions & 0 deletions tests/test_todo_hit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import unittest

from todo_or_not.todo_hit import Hit


class TestTodoHit(unittest.TestCase):
def setUp(self):
self.hit_a = Hit("file", 1, ["todo"], ["code"], 0)
self.hit_a.structured_labels = ["test"]

def test_eq_with_wrong_type(self):
assert 1 != self.hit_a

def test_labels_with_issue_generation(self):
self.hit_a.generate_issue(True)


if __name__ == "__main__":
unittest.main()
4 changes: 2 additions & 2 deletions tests/test_todoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def test_plural_passages_in_summary(self):
# number of issues
assert os.environ["TODOON_ISSUES_GENERATED"] == "0"
# number of duplicate issues
assert os.environ["TODOON_DUPLICATE_ISSUES_AVOIDED"] == "2"
assert os.environ["TODOON_DUPLICATE_ISSUES_AVOIDED"] == "3"
# number of closed issues
assert os.environ["TODOON_DUPLICATE_CLOSED_ISSUES"] == "2"
assert os.environ["TODOON_DUPLICATE_CLOSED_ISSUES"] == "1"

self._environment_down()

Expand Down
2 changes: 1 addition & 1 deletion todo_or_not/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
#####################################################

__version__ = "0.13.0"
__version__ = "0.13.9"
iso_string = "2024-06-16"

version_date = datetime.date.fromisoformat(iso_string)
2 changes: 1 addition & 1 deletion todo_or_not/localize.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"warning_duplicate_closed_issue": f"경고: 이미 닫힌 깃허브 이슈를 찾았습니다",
"warning_nonissue_mode_closed_duplicate_used": "경고: 설정한 옵션 '--closed-duplicates-fail/-c'은 '--issue/-i' 모드가 아니라면 아무런 영향을 끼치지 못합니다",
"progress_bar_run_unit": "파일",
"progress_bar_run_desc": "파일들을 스캔하고 있음"
"progress_bar_run_desc": "파일들을 스캔하고 있음",
},
"bu_mm": {
"general_done": "ပြီးပါပြီ။",
Expand Down
24 changes: 15 additions & 9 deletions todo_or_not/todo_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def find_hits(
file_extension = filename.rsplit(".", 1)[-1]
file_language = find_language(file_extension)

# If that language does not yet have a parser built, we must build one (note that calling the TodoGrammar
# constructor with the file_extension will functional identically between different file extensions for
# the same language)
# If that language does not yet have a parser built, we must build one (note that calling the
# TodoGrammar constructor with the file_extension will functional identically between different # todoon
# file extensions for the same language)
if file_language not in parsers.keys():
parsers[file_language] = TodoGrammar(file_extension)
parsers[file_language].build()
Expand Down Expand Up @@ -482,8 +482,6 @@ def todoon(
_i = 0
_target_iterator = targets

# TODO NEW Localization 'progress_bar_run_unit' | "file" #localization
# TODO NEW Localization 'progress_bar_run_desc' | "scanning files" #localization
if show_progress_bar:
_target_iterator = tqdm(targets, unit=LOCALIZE[util.get_region()]['progress_bar_run_unit'],
desc=LOCALIZE[util.get_region()]['progress_bar_run_desc'])
Expand Down Expand Up @@ -573,8 +571,8 @@ def todoon(
else:
summary += "# (ISSUE MODE)\n"

# Number of TODOs and FIXMEs found
summary += f"# {number_of_todo} TODO | {number_of_fixme} FIXME\n"
# Number of TODOs and FIXMEs found # todoon
summary += f"# {number_of_todo} TODO | {number_of_fixme} FIXME\n" # todoon

# Number of encoding failures
if number_of_encoding_failures > 1:
Expand Down Expand Up @@ -624,7 +622,6 @@ def todoon(
# Overall results of the run
if number_of_hits > 0:
if silent:
# TODO NEW Localization 'summary_found_issues_silent' | "INFO: New issues detected, but todoon ran in --silent mode" #localization
summary += f" * {LOCALIZE[util.get_region()]['summary_found_issues_silent']}\n"
else:
summary += f" * {LOCALIZE[util.get_region()]['summary_fail_issues_no_silent']}\n"
Expand All @@ -634,7 +631,6 @@ def todoon(

# Total success
if number_of_hits == 0:
# TODO NEW Localization 'summary_success' | "SUCCESS: No new issues detected" #localization
summary += f" * {LOCALIZE[util.get_region()]['summary_success']}\n"

os.environ["TODOON_STATUS"] = "finished"
Expand All @@ -651,6 +647,16 @@ def todoon(
number_of_closed_issues
)

os.system(f'TODOON_STATUS={"finished"} >> $GITHUB_ENV')
os.system(f'TODOON_PROGRESS={"100.0"} >> $GITHUB_ENV')
os.system(f'TODOON_FILES_SCANNED={str(number_of_files_scanned)} >> $GITHUB_ENV')
os.system(f'TODOON_TODOS_FOUND={str(number_of_todo)} >> $GITHUB_ENV')
os.system(f'TODOON_FIXMES_FOUND={str(number_of_fixme)} >> $GITHUB_ENV')
os.system(f'TODOON_ENCODING_ERRORS={str(number_of_encoding_failures)} >> $GITHUB_ENV')
os.system(f'TODOON_ISSUES_GENERATED={str(number_of_issues)} >> $GITHUB_ENV')
os.system(f'TODOON_DUPLICATE_ISSUES_AVOIDED={str(number_of_duplicate_issues_avoided)} >> $GITHUB_ENV')
os.system(f'TODOON_DUPLICATE_CLOSED_ISSUES={str(number_of_closed_issues)} >> $GITHUB_ENV')

util.print_wrap(log_level=log_level, msg_level=util.LOG_LEVEL_SUMMARY_ONLY,
msg=summary, file=sys.stderr)

Expand Down
27 changes: 0 additions & 27 deletions todo_or_not/todo_hit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,6 @@ def __init__(
self.structured_body = None
self.structured_labels = None

####################################################################
# DEPRECATED: Formatting hits is now handled at todo_grammar.py
####################################################################

# If this is a structured comment, parse out the title, body, and labels
# if "|" in self.pertinent_lines[trigger_line_index]:
# head, body = self.pertinent_lines[trigger_line_index].split("|", 1)
#
# self.structured_title = head.strip()
# self.structured_body = body.strip()
#
# # If there is an # in the body, there may be labels to find
# if "#" in self.structured_body:
# self.structured_labels = []
#
# _potential_tags = self.structured_body.split("#")
#
# # Skip the first item in this list, because the labels will come after the #
# for _potential in _potential_tags[1:]:
# _label = _potential.split(" ", 1)[0]
#
# if len(_label) > 0:
# self.structured_labels.append(_label)
#
# if len(self.structured_labels) == 0:
# self.structured_labels = None

def __repr__(self):

if self.structured_title is not None:
Expand Down
Loading