Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test_scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ jobs:
pip-install: flake8 lxml pexpect

- name: Install astyle
if: matrix.config == 'astyle-cleanliness'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y astyle
sudo apt-get install --yes astyle

- name: Install shellcheck
if: matrix.config == 'shellcheck'
Expand Down
3 changes: 0 additions & 3 deletions Tools/scripts/build_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,6 @@ for t in $CI_BUILD_TARGET; do
echo "Checking AStyle code cleanliness"

./Tools/scripts/run_astyle.py --dry-run
if [ $? -ne 0 ]; then
echo The code failed astyle cleanliness checks. Please run ./Tools/scripts/run_astyle.py
fi
Comment thread
peterbarker marked this conversation as resolved.
continue
fi

Expand Down
10 changes: 7 additions & 3 deletions Tools/scripts/run_astyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import argparse
import contextlib
import os
import pathlib
import subprocess
Expand Down Expand Up @@ -37,13 +38,16 @@ def __init__(self, *, dry_run=DRY_RUN_DEFAULT):
self.dry_run = dry_run

def progress(self, string):
print("****** %s" % (string,))
print(f"****** {string}")

def check(self):
'''run astyle on all files in self.files_to_check'''
# for path in self.files_to_check:
# self.progress("Checking (%s)" % path)
astyle_command = ["astyle"]
# Show the astyle version suppressing all exceptions
with contextlib.suppress():
_ = subprocess.run(astyle_command + ["--version"])
if self.dry_run:
astyle_command.append("--dry-run")

Expand All @@ -56,7 +60,7 @@ def check(self):
text=True
)
if ret.returncode != 0:
self.progress("astyle check failed: (%s)" % (ret.stdout))
self.progress(f"astyle check failed: ({ret.stdout})")
self.retcode = 1
if "Formatted" in ret.stdout:
self.progress("Files needing formatting found.")
Expand All @@ -72,7 +76,7 @@ def run(self):


if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Check all Python files for astyle cleanliness')
parser = argparse.ArgumentParser(description='Check C and C++ files for astyle cleanliness')
parser.add_argument('--dry-run',
action='store_true',
default=DRY_RUN_DEFAULT,
Expand Down
Loading