From eb54090eebc7781d1837b6041df2481adff8e502 Mon Sep 17 00:00:00 2001 From: warriorstar-orion Date: Sun, 6 Nov 2022 07:24:47 -0500 Subject: [PATCH] Add untick file check to CI. (#19618) * Add untick file check to CI. * Time for some caveman debugging * Software's real neat --- .github/workflows/ci.yml | 1 + tools/ci/unticked_files.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff2b4fbf7b3..6693b3684ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,7 @@ jobs: tools/ci/build_tgui.sh tools/ci/check_grep.sh python3 tools/ci/check_line_endings.py + python3 tools/ci/unticked_files.py ${GITHUB_WORKSPACE} ~/dreamchecker > ${GITHUB_WORKSPACE}/output-annotations.txt 2>&1 - name: Annotate Lints uses: yogstation13/DreamAnnotate@v2 diff --git a/tools/ci/unticked_files.py b/tools/ci/unticked_files.py index 528dd7777b9..053bf14878e 100644 --- a/tools/ci/unticked_files.py +++ b/tools/ci/unticked_files.py @@ -6,7 +6,15 @@ # # Returns 0 if all existing files are considered ticked, 1 otherwise. -from pathlib import Path +# When running in POSIX environments, the include paths in the codebase need to +# be munged into PureWindowsPaths before being spit back out. Otherwise, the +# checker will attempt to find files named e.g. /workspace/code\\foo.dm, which +# translates to the (completely legitimate) filename "code\foo.dm" in the +# /workspace directory. +# +# For more information, see the discussion of pure paths in the pathlib +# documentation. +from pathlib import Path, PureWindowsPath import argparse import sys @@ -28,7 +36,7 @@ def get_unticked_files(root:Path): lines = [line for line in f.readlines() if line.startswith('#include')] included = [line.replace('#include ', '').rstrip('\r\n').strip('"') for line in lines] print(f'Found {len(included)} includes in {root / includer}') - ticked_files.update([root / Path(includer).parent / i for i in included]) + ticked_files.update([root / Path(includer).parent / Path(PureWindowsPath(i)) for i in included]) all_dm_files = {f for f in root.glob('**/*.dm')} return all_dm_files - ticked_files - {root / f for f in IGNORE_FILES}