Skip to content

Commit

Permalink
test: Support global ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Sep 16, 2024
1 parent 5008bf2 commit a7f5a28
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/lint_comp_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def compare_file_with_template(filepath, targetpath=None, ignored_workspaces=[])
# Skip certain cases intentionally
if any(ws in filename for ws in ignored_workspaces):
continue
# Global ignore
if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()):
continue
logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...")
content = Path(filename).read_text().splitlines(keepends=True)
diff = list(filter(lambda x: x.startswith('- ') or x.startswith('+ ') or x.startswith(' '), difflib.ndiff(template, content)))
Expand Down
3 changes: 3 additions & 0 deletions tests/lint_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

logging.info("Checking `compose.yaml` files...")
for filename in glob.glob(f"{repo_dir}/*_ws/docker/compose*.yaml"):
# Global ignore
if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()):
continue
logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...")
content = Path(filename).read_text()
if "version:" in content:
Expand Down
3 changes: 3 additions & 0 deletions tests/lint_dockerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

logging.info("Checking `Dockerfile` files...")
for filename in glob.glob(f"{repo_dir}/*_ws/docker/Dockerfile*"):
# Global ignore
if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()):
continue
logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...")
# Skip certain cases intentionally
if "ros1_bridge_ws" in filename:
Expand Down
6 changes: 6 additions & 0 deletions tests/lint_filenames.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
for filename in DEFAULT_FILES:
logging.debug(f"Checking existence of: '{filename}'...")
for workspace_path in glob.glob(f"{repo_dir}/*_ws"):
# Global ignore
if any(ws in workspace_path for ws in os.getenv('IGNORED_WORKSPACES', '').split()):
continue
if not os.path.isfile(f"{workspace_path}/{filename}"):
# Skip certain cases intentionally
if filename in (".gitignore", "docker/.bashrc") and os.path.basename(workspace_path) == "ros1_bridge_ws":
Expand All @@ -37,5 +40,8 @@
for filename in OBSOLETE_FILES:
logging.debug(f"Checking non-existence of: '{filename}'...")
for workspace_path in glob.glob(f"{repo_dir}/*_ws"):
# Global ignore
if any(ws in workspace_path for ws in os.getenv('IGNORED_WORKSPACES', '').split()):
continue
if os.path.isfile(f"{workspace_path}/{filename}"):
raise ValueError(f"'{filename}' exists in: '{workspace_path}'")
3 changes: 3 additions & 0 deletions tests/lint_gitignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

logging.info("Checking `.gitignore` files...")
for filename in glob.glob(f"{repo_dir}/*_ws/.gitignore"):
# Global ignore
if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()):
continue
logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...")
content = Path(filename).read_text()
if "gazebo" in content:
Expand Down
3 changes: 3 additions & 0 deletions tests/lint_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

logging.info("Checking `README.md` files...")
for filename in glob.glob(f"{repo_dir}/*_ws/README.md"):
# Global ignore
if any(ws in filename for ws in os.getenv('IGNORED_WORKSPACES', '').split()):
continue
logging.debug(f"Checking: '{filename[len(repo_dir)+1:]}'...")
content = Path(filename).read_text()
if "ros2-agv-essentials" in content:
Expand Down
1 change: 1 addition & 0 deletions tests/test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Reference: https://stackoverflow.com/q/59895
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
cd $SCRIPT_DIR
# export IGNORED_WORKSPACES="temp_ws tmp_ws"
# Loop through all Python files in the current directory
for script in *.py; do
echo "Running $script..."
Expand Down

0 comments on commit a7f5a28

Please sign in to comment.