From e283eb5eb51fc5ab4c0b24dfbc881ae1138c4e29 Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 16:53:34 -0600 Subject: [PATCH 01/11] first commit of stufferings --- .github/workflows/ci_suite.yml | 2 +- tools/ci/annotate_od.sh | 4 ++++ tools/od_annotator/__main__.py | 40 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tools/ci/annotate_od.sh create mode 100644 tools/od_annotator/__main__.py diff --git a/.github/workflows/ci_suite.yml b/.github/workflows/ci_suite.yml index a092a01901d95..095da7cb354f4 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -132,7 +132,7 @@ jobs: extract: true - name: Run OpenDream run: | - ./DMCompiler_linux-x64/DMCompiler tgstation.dme --suppress-unimplemented --define=CIBUILDING + ./DMCompiler_linux-x64/DMCompiler tgstation.dme --suppress-unimplemented --define=CIBUILDING | bash tools/ci/annotate_od.sh compile_all_maps: if: ( !contains(github.event.head_commit.message, '[ci skip]') ) diff --git a/tools/ci/annotate_od.sh b/tools/ci/annotate_od.sh new file mode 100644 index 0000000000000..12390908074c0 --- /dev/null +++ b/tools/ci/annotate_od.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +set -euo pipefail +tools/bootstrap/python -m od_annotator "$@" diff --git a/tools/od_annotator/__main__.py b/tools/od_annotator/__main__.py new file mode 100644 index 0000000000000..3b295f4667e76 --- /dev/null +++ b/tools/od_annotator/__main__.py @@ -0,0 +1,40 @@ +import sys +import re +import os.path as path + +# Usage: tools/bootstrap/python -m dm_annotator [filename] +# If filename is not provided, stdin is checked instead + +def red(text): + return "\033[31m" + str(text) + "\033[0m" + +def green(text): + return "\033[32m" + str(text) + "\033[0m" + +def yellow(text): + return "\033[33m" + str(text) + "\033[0m" + +def annotate(raw_output): + # Remove ANSI escape codes + raw_output = re.sub(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]', '', raw_output) + + print("::group::OpenDream Output") + print(raw_output) + print("::endgroup::") + + annotation_regex = r'((?PError|Warning) (?POD(?P\d{4})) at (?P(?P.+):(?P\d+):(?P\d+)|): (?P.+))' + has_issues = False + + print("OpenDream Code Annotations:") + for annotation in re.finditer(annotation_regex, raw_output): + if annotation['errornumber'] is "0000" and annotation['message'] is "Unimplemented proc & var warnings are currently suppressed": + continue # snowflake case, we do need to care about this and it does print in the raw_output earlier but it's a nothingburger to actually annotate and it happens every run for the time being + + error_string = f"{annotation['errorcode']}: {annotation['message']}" + print(f"::{annotation['type']} file={annotation['filename']},line={annotation['line']},col={annotation['column']}::{error_string}") + has_issues = True + + if not has_issues: + print(green("No OpenDream issues found")) + +annotate(sys.stdin.read()) From 2c464a0176b93632dc3fd08e6801ff28cf824008 Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 16:53:59 -0600 Subject: [PATCH 02/11] revertable test --- code/datums/components/keep_me_secure.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/datums/components/keep_me_secure.dm b/code/datums/components/keep_me_secure.dm index 84e295db1786c..f12a1a7e5d9f4 100644 --- a/code/datums/components/keep_me_secure.dm +++ b/code/datums/components/keep_me_secure.dm @@ -25,6 +25,7 @@ /datum/component/keep_me_secure/Destroy(force) secured_callback = null unsecured_callback = null + var/random_string = "\The san7890 is cool" return ..() /datum/component/keep_me_secure/RegisterWithParent() From 325623e70b5bebba30138f6c366c1c72c33cf906 Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 17:52:42 -0600 Subject: [PATCH 03/11] uses `==` --- tools/od_annotator/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/od_annotator/__main__.py b/tools/od_annotator/__main__.py index 3b295f4667e76..e172203de0e2d 100644 --- a/tools/od_annotator/__main__.py +++ b/tools/od_annotator/__main__.py @@ -27,7 +27,7 @@ def annotate(raw_output): print("OpenDream Code Annotations:") for annotation in re.finditer(annotation_regex, raw_output): - if annotation['errornumber'] is "0000" and annotation['message'] is "Unimplemented proc & var warnings are currently suppressed": + if annotation['errornumber'] == "0000" and annotation['message'] == "Unimplemented proc & var warnings are currently suppressed": continue # snowflake case, we do need to care about this and it does print in the raw_output earlier but it's a nothingburger to actually annotate and it happens every run for the time being error_string = f"{annotation['errorcode']}: {annotation['message']}" From ae4ee171b78ff1949a2379a0ebf68a92812cf3c0 Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 17:53:08 -0600 Subject: [PATCH 04/11] scraps old dependencies --- tools/od_annotator/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/od_annotator/__main__.py b/tools/od_annotator/__main__.py index e172203de0e2d..4fcd119db9e5b 100644 --- a/tools/od_annotator/__main__.py +++ b/tools/od_annotator/__main__.py @@ -1,6 +1,5 @@ import sys import re -import os.path as path # Usage: tools/bootstrap/python -m dm_annotator [filename] # If filename is not provided, stdin is checked instead From 73892eb64a991a125ccda000fb9ad427abcf0ecf Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 17:54:06 -0600 Subject: [PATCH 05/11] add python cache --- .github/workflows/ci_suite.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci_suite.yml b/.github/workflows/ci_suite.yml index 095da7cb354f4..320c84f930afa 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -123,6 +123,13 @@ jobs: group: odlint-${{ github.head_ref || github.run_id }} cancel-in-progress: true steps: + - name: Restore Bootstrap cache + uses: actions/cache@v4 + with: + path: tools/bootstrap/.cache + key: ${{ runner.os }}-bootstrap-${{ hashFiles('tools/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-bootstrap- - uses: actions/checkout@v4 - uses: robinraju/release-downloader@v1.9 with: From fff5b4f0ca2529358807f883a79e11d1283a90bd Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 17:55:38 -0600 Subject: [PATCH 06/11] culls useless defs --- tools/od_annotator/__main__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/od_annotator/__main__.py b/tools/od_annotator/__main__.py index 4fcd119db9e5b..3e4da181af71c 100644 --- a/tools/od_annotator/__main__.py +++ b/tools/od_annotator/__main__.py @@ -4,15 +4,9 @@ # Usage: tools/bootstrap/python -m dm_annotator [filename] # If filename is not provided, stdin is checked instead -def red(text): - return "\033[31m" + str(text) + "\033[0m" - def green(text): return "\033[32m" + str(text) + "\033[0m" -def yellow(text): - return "\033[33m" + str(text) + "\033[0m" - def annotate(raw_output): # Remove ANSI escape codes raw_output = re.sub(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]', '', raw_output) From fb59e645151454da79309aea3ef686f2b2ec98dd Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 18:05:43 -0600 Subject: [PATCH 07/11] handles "expected failure case" gracefully --- tools/od_annotator/__main__.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/tools/od_annotator/__main__.py b/tools/od_annotator/__main__.py index 3e4da181af71c..17a5b78d29d01 100644 --- a/tools/od_annotator/__main__.py +++ b/tools/od_annotator/__main__.py @@ -7,6 +7,9 @@ def green(text): return "\033[32m" + str(text) + "\033[0m" +def red(text): + return "\033[31m" + str(text) + "\033[0m" + def annotate(raw_output): # Remove ANSI escape codes raw_output = re.sub(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]', '', raw_output) @@ -16,18 +19,31 @@ def annotate(raw_output): print("::endgroup::") annotation_regex = r'((?PError|Warning) (?POD(?P\d{4})) at (?P(?P.+):(?P\d+):(?P\d+)|): (?P.+))' - has_issues = False + failures_detected = False + expected_failure_case_detected = False # this is just here so this script breaks if we forget to set it to True when we expect a failure. remove this when we have handled the expected failure print("OpenDream Code Annotations:") for annotation in re.finditer(annotation_regex, raw_output): - if annotation['errornumber'] == "0000" and annotation['message'] == "Unimplemented proc & var warnings are currently suppressed": - continue # snowflake case, we do need to care about this and it does print in the raw_output earlier but it's a nothingburger to actually annotate and it happens every run for the time being + message = annotation['message'] + if message == "Unimplemented proc & var warnings are currently suppressed": # this happens every single run, it's important to know about it but we don't need to throw an error + message += " (This is expected and can be ignored)" + expected_failure_case_detected = True + + if annotation['type'] == "Error": + failures_detected = True - error_string = f"{annotation['errorcode']}: {annotation['message']}" + error_string = f"{annotation['errorcode']}: {message}" print(f"::{annotation['type']} file={annotation['filename']},line={annotation['line']},col={annotation['column']}::{error_string}") - has_issues = True - if not has_issues: - print(green("No OpenDream issues found")) + if failures_detected: + sys.exit(1) + return + + if not expected_failure_case_detected: + print(red("Failed to detect the expected failure case! If you have recently changed how we work with OpenDream Pragmas, please fix the od_annotator script!")) + sys.exit(1) + return + + print(green("No OpenDream issues found!")) annotate(sys.stdin.read()) From 649f5ea247af72acf15e801431d338eb5f95dba2 Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 18:07:12 -0600 Subject: [PATCH 08/11] internal OD failure handling as well --- tools/od_annotator/__main__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/od_annotator/__main__.py b/tools/od_annotator/__main__.py index 17a5b78d29d01..054716265d2eb 100644 --- a/tools/od_annotator/__main__.py +++ b/tools/od_annotator/__main__.py @@ -26,14 +26,18 @@ def annotate(raw_output): for annotation in re.finditer(annotation_regex, raw_output): message = annotation['message'] if message == "Unimplemented proc & var warnings are currently suppressed": # this happens every single run, it's important to know about it but we don't need to throw an error - message += " (This is expected and can be ignored)" + message += " (This is expected and can be ignored)" # also there's no location for it to annotate to since it's an failure. expected_failure_case_detected = True if annotation['type'] == "Error": failures_detected = True error_string = f"{annotation['errorcode']}: {message}" - print(f"::{annotation['type']} file={annotation['filename']},line={annotation['line']},col={annotation['column']}::{error_string}") + + if annotation['location'] == "": + print(f"::{annotation['type']} file=,line=,col=::{error_string}") + else: + print(f"::{annotation['type']} file={annotation['filename']},line={annotation['line']},col={annotation['column']}::{error_string}") if failures_detected: sys.exit(1) From e14b4bbe35af0f8762a34bae96d65e72e6626327 Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 18:13:59 -0600 Subject: [PATCH 09/11] folds opendream linting into Run Linters --- .github/workflows/ci_suite.yml | 36 ++++++++++------------------------ 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci_suite.yml b/.github/workflows/ci_suite.yml index 320c84f930afa..4be1768c03e81 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -63,6 +63,13 @@ jobs: with: path: tools/icon_cutter/cache key: ${{ runner.os }}-cutter-${{ hashFiles('dependencies.sh') }} + - name: Install OpenDream + uses: robinraju/release-downloader@v1.9 + with: + repository: "OpenDreamProject/OpenDream" + tag: "latest" + fileName: "DMCompiler_linux-x64.tar.gz" + extract: true - name: Install Tools run: | pip3 install setuptools @@ -91,6 +98,9 @@ jobs: if: steps.linter-setup.conclusion == 'success' && !cancelled() shell: bash run: ~/dreamchecker 2>&1 | bash tools/ci/annotate_dm.sh + - name: Lint with OpenDream + if: steps.linter-setup.conclusion == 'success' && !cancelled() + run: ./DMCompiler_linux-x64/DMCompiler tgstation.dme --suppress-unimplemented --define=CIBUILDING | bash tools/ci/annotate_od.sh - name: Run Map Checks if: steps.linter-setup.conclusion == 'success' && !cancelled() run: | @@ -115,32 +125,6 @@ jobs: if: steps.linter-setup.conclusion == 'success' && !cancelled() run: tools/build/build --ci lint tgui-test - odlint: - if: ( !contains(github.event.head_commit.message, '[ci skip]') ) - name: "Lint with OpenDream" - runs-on: ubuntu-22.04 - concurrency: - group: odlint-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - steps: - - name: Restore Bootstrap cache - uses: actions/cache@v4 - with: - path: tools/bootstrap/.cache - key: ${{ runner.os }}-bootstrap-${{ hashFiles('tools/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-bootstrap- - - uses: actions/checkout@v4 - - uses: robinraju/release-downloader@v1.9 - with: - repository: "OpenDreamProject/OpenDream" - tag: "latest" - fileName: "DMCompiler_linux-x64.tar.gz" - extract: true - - name: Run OpenDream - run: | - ./DMCompiler_linux-x64/DMCompiler tgstation.dme --suppress-unimplemented --define=CIBUILDING | bash tools/ci/annotate_od.sh - compile_all_maps: if: ( !contains(github.event.head_commit.message, '[ci skip]') ) name: Compile Maps From b9bee0bf90c809a69a2ed0e900a989bf738388ab Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 18:15:29 -0600 Subject: [PATCH 10/11] rename for consistency --- .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 4be1768c03e81..960bb10dcdab7 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -98,7 +98,7 @@ jobs: if: steps.linter-setup.conclusion == 'success' && !cancelled() shell: bash run: ~/dreamchecker 2>&1 | bash tools/ci/annotate_dm.sh - - name: Lint with OpenDream + - name: Run OpenDream if: steps.linter-setup.conclusion == 'success' && !cancelled() run: ./DMCompiler_linux-x64/DMCompiler tgstation.dme --suppress-unimplemented --define=CIBUILDING | bash tools/ci/annotate_od.sh - name: Run Map Checks From b5485136b21228aa3e45508497f2025ea26a9378 Mon Sep 17 00:00:00 2001 From: san7890 Date: Fri, 15 Mar 2024 18:15:43 -0600 Subject: [PATCH 11/11] Revert "revertable test" This reverts commit 2c464a0176b93632dc3fd08e6801ff28cf824008. --- code/datums/components/keep_me_secure.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/datums/components/keep_me_secure.dm b/code/datums/components/keep_me_secure.dm index f12a1a7e5d9f4..84e295db1786c 100644 --- a/code/datums/components/keep_me_secure.dm +++ b/code/datums/components/keep_me_secure.dm @@ -25,7 +25,6 @@ /datum/component/keep_me_secure/Destroy(force) secured_callback = null unsecured_callback = null - var/random_string = "\The san7890 is cool" return ..() /datum/component/keep_me_secure/RegisterWithParent()