From 1c16cf58fa6a3e49dc5a960db76260d3d2c4c1c0 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Wed, 13 Sep 2023 19:13:58 -0500 Subject: [PATCH 1/7] Test --- code/modules/unit_tests/_unit_tests.dm | 2 ++ tools/ci/check_regex.py | 28 +++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 1607229a790a..45e1d970a105 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -20,6 +20,8 @@ /// Intended to be used in the manner of `TEST_FOCUS(/datum/unit_test/math)` #define TEST_FOCUS(test_path) ##test_path { focus = TRUE; } +text2path("test") + #include "anchored_mobs.dm" #include "autowiki.dm" #include "bespoke_id.dm" diff --git a/tools/ci/check_regex.py b/tools/ci/check_regex.py index 279d8236cbd6..9c2e9e838c33 100644 --- a/tools/ci/check_regex.py +++ b/tools/ci/check_regex.py @@ -31,6 +31,10 @@ modification, or removal. Good if you want to track down errors caused by commit or PR changes. + --github-actions + An output option to format the output in a way that Github Actions + can parse and show as annotations in the PR. + Copyright 2021 Martin Lyrå Permission is hereby granted, free of charge, to any person obtaining a copy @@ -99,6 +103,12 @@ dest="log_changes_only", default=False, action="store_true") +options.add_argument( + "--github-actions", + dest="github_actions", + default=False, + action="store_true" +) args = options.parse_args() @@ -790,9 +800,25 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: show_items.append("Current (%4i): %s" % (len(matches), matches)) if len(adds): show_items.append("+++++++ (%4i): %s" % (len(adds), adds)) + #Github actions annotations + if args.github_actions and matching != RESULT_OK: + for line_no in adds: + output_write("::error file=%s,line=%i,title=%s" % ( + f, + line_no, + standard.message + ), to_stdout=True, to_file=False) inner_prefix = prefix if len(removes): show_items.append("------- (%4i): %s" % (len(removes), removes)) + #Github actions annotations + if args.github_actions and matching != RESULT_OK: + for line_no in removes: + output_write("::error file=%s,line=%i,title=%s" % ( + f, + line_no, + standard.message + ), to_stdout=True, to_file=False) inner_prefix = prefix lines.append("%2s %s" % ("\u2500\u252C", f)) @@ -898,4 +924,4 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: output_file.close() output_file = None - exit(failure > 0 or fail_files > 0) \ No newline at end of file + exit(failure > 0 or fail_files > 0) From f0db47aaa0980f9fb6c37c0fbaeb92cae376634f Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Wed, 13 Sep 2023 19:19:24 -0500 Subject: [PATCH 2/7] oops --- .github/workflows/ci_suite.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_suite.yml b/.github/workflows/ci_suite.yml index 20378d43932b..f844f8da5747 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -59,7 +59,7 @@ jobs: python-version: "3.9" - name: Run Check Regex run: | - tools/bootstrap/python -m ci.check_regex --log-changes-only + tools/bootstrap/python -m ci.check_regex --log-changes-only --github-actions - name: Annotate Regex Matches if: always() run: | From f0e8014d77c001965bfe85a25d4155bb262dcfb2 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Wed, 13 Sep 2023 19:24:31 -0500 Subject: [PATCH 3/7] whoops --- tools/ci/check_regex.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/ci/check_regex.py b/tools/ci/check_regex.py index 9c2e9e838c33..b68ecadb5676 100644 --- a/tools/ci/check_regex.py +++ b/tools/ci/check_regex.py @@ -803,10 +803,11 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in adds: - output_write("::error file=%s,line=%i,title=%s" % ( + output_write("::error file=%s,line=%i,title=%s::%s" % ( f, line_no, - standard.message + standard.message, + diff_added_content[f][line_no] ), to_stdout=True, to_file=False) inner_prefix = prefix if len(removes): @@ -814,10 +815,11 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in removes: - output_write("::error file=%s,line=%i,title=%s" % ( + output_write("::error file=%s,line=%i,title=%s::%s" % ( f, line_no, - standard.message + standard.message, + diff_removed_content[f][line_no] ), to_stdout=True, to_file=False) inner_prefix = prefix From 3d41a9c132894501e427f8f6900d852fbad424e0 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Wed, 13 Sep 2023 21:08:28 -0500 Subject: [PATCH 4/7] goowah --- code/modules/unit_tests/_unit_tests.dm | 2 -- code/modules/unit_tests/unit_test.dm | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 45e1d970a105..1607229a790a 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -20,8 +20,6 @@ /// Intended to be used in the manner of `TEST_FOCUS(/datum/unit_test/math)` #define TEST_FOCUS(test_path) ##test_path { focus = TRUE; } -text2path("test") - #include "anchored_mobs.dm" #include "autowiki.dm" #include "bespoke_id.dm" diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index 4a1e5f37906e..a2e008c97da7 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -37,6 +37,7 @@ GLOBAL_VAR(test_log) var/static/datum/map_zone/mapzone /datum/unit_test/New() + var/error = text2path("/obj") if (isnull(mapzone)) var/height = 7 var/width = 7 From 9e87b03b3c0105f2f0ad6f5b64d3e9aa62d6c543 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Wed, 13 Sep 2023 21:12:22 -0500 Subject: [PATCH 5/7] waaugh --- tools/ci/check_regex.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/ci/check_regex.py b/tools/ci/check_regex.py index b68ecadb5676..186e5a51bf45 100644 --- a/tools/ci/check_regex.py +++ b/tools/ci/check_regex.py @@ -803,11 +803,10 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in adds: - output_write("::error file=%s,line=%i,title=%s::%s" % ( + output_write("::error file=%s,line=%i,title=Check Regex::%s" % ( f, line_no, - standard.message, - diff_added_content[f][line_no] + standard.message ), to_stdout=True, to_file=False) inner_prefix = prefix if len(removes): @@ -815,11 +814,10 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in removes: - output_write("::error file=%s,line=%i,title=%s::%s" % ( + output_write("::error file=%s,line=%i,title=Check Regex::%s" % ( f, line_no, - standard.message, - diff_removed_content[f][line_no] + standard.message ), to_stdout=True, to_file=False) inner_prefix = prefix From 61f39a3866fc31edde0409329f99626afe9456e5 Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Thu, 14 Sep 2023 10:58:15 -0500 Subject: [PATCH 6/7] More descriptive annotations --- tools/ci/check_regex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ci/check_regex.py b/tools/ci/check_regex.py index 186e5a51bf45..0ff2e6443152 100644 --- a/tools/ci/check_regex.py +++ b/tools/ci/check_regex.py @@ -803,7 +803,7 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in adds: - output_write("::error file=%s,line=%i,title=Check Regex::%s" % ( + output_write("::error file=%s,line=%i,title=Check Regex::`%s` added here, remove or update check_regex.yml" % ( f, line_no, standard.message @@ -814,7 +814,7 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in removes: - output_write("::error file=%s,line=%i,title=Check Regex::%s" % ( + output_write("::error file=%s,line=%i,title=Check Regex::`%s` removed here, update check_regex.yml" % ( f, line_no, standard.message From 4c6db45d27a50bbcd4569bdcc48d3ab5f983a69f Mon Sep 17 00:00:00 2001 From: Mark Suckerberg Date: Thu, 14 Sep 2023 11:07:41 -0500 Subject: [PATCH 7/7] Final tweak --- code/modules/unit_tests/unit_test.dm | 1 - tools/ci/check_regex.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/code/modules/unit_tests/unit_test.dm b/code/modules/unit_tests/unit_test.dm index a2e008c97da7..4a1e5f37906e 100644 --- a/code/modules/unit_tests/unit_test.dm +++ b/code/modules/unit_tests/unit_test.dm @@ -37,7 +37,6 @@ GLOBAL_VAR(test_log) var/static/datum/map_zone/mapzone /datum/unit_test/New() - var/error = text2path("/obj") if (isnull(mapzone)) var/height = 7 var/width = 7 diff --git a/tools/ci/check_regex.py b/tools/ci/check_regex.py index 0ff2e6443152..f104139b7e18 100644 --- a/tools/ci/check_regex.py +++ b/tools/ci/check_regex.py @@ -803,7 +803,7 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in adds: - output_write("::error file=%s,line=%i,title=Check Regex::`%s` added here, remove or update check_regex.yml" % ( + output_write("::error file=%s,line=%i,title=Check Regex::%s added to here, remove or update check_regex.yml" % ( f, line_no, standard.message @@ -814,7 +814,7 @@ def git_get_detached_head_ref(head: Head, ref_info: str) -> str: #Github actions annotations if args.github_actions and matching != RESULT_OK: for line_no in removes: - output_write("::error file=%s,line=%i,title=Check Regex::`%s` removed here, update check_regex.yml" % ( + output_write("::error file=%s,line=%i,title=Check Regex::%s removed from here, update check_regex.yml" % ( f, line_no, standard.message