Skip to content

Commit 3ff2176

Browse files
committed
Tools: Raise Artistic Style errors in CI
1 parent 9d6d875 commit 3ff2176

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

.github/workflows/test_scripts.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ jobs:
3232
cache: 'pip' # caching pip dependencies
3333
pip-install: flake8 lxml popen pexpect
3434

35-
- name: Install checker stuffs
35+
- name: Install astyle
36+
if: matrix.config == 'astyle-cleanliness'
3637
shell: bash
3738
run: |
3839
sudo apt-get update
39-
sudo apt-get install -y astyle
40+
sudo apt-get install --yes astyle
4041
4142
- name: test ${{matrix.config}}
4243
env:

Tools/scripts/build_ci.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,6 @@ for t in $CI_BUILD_TARGET; do
518518
echo "Checking AStyle code cleanliness"
519519

520520
./Tools/scripts/run_astyle.py --dry-run
521-
if [ $? -ne 0 ]; then
522-
echo The code failed astyle cleanliness checks. Please run ./Tools/scripts/run_astyle.py
523-
fi
524521
continue
525522
fi
526523

Tools/scripts/run_astyle.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"""
88

99
import argparse
10+
import contextlib
1011
import os
1112
import pathlib
1213
import subprocess
@@ -37,13 +38,16 @@ def __init__(self, *, dry_run=DRY_RUN_DEFAULT):
3738
self.dry_run = dry_run
3839

3940
def progress(self, string):
40-
print("****** %s" % (string,))
41+
print(f"****** {string}")
4142

4243
def check(self):
4344
'''run astyle on all files in self.files_to_check'''
4445
# for path in self.files_to_check:
4546
# self.progress("Checking (%s)" % path)
4647
astyle_command = ["astyle"]
48+
# Show the astyle version suppressing all exceptions
49+
with contextlib.suppress():
50+
_ = subprocess.run(astyle_command + ["--version"])
4751
if self.dry_run:
4852
astyle_command.append("--dry-run")
4953

@@ -56,7 +60,7 @@ def check(self):
5660
text=True
5761
)
5862
if ret.returncode != 0:
59-
self.progress("astyle check failed: (%s)" % (ret.stdout))
63+
self.progress(f"astyle check failed: ({ret.stdout})")
6064
self.retcode = 1
6165
if "Formatted" in ret.stdout:
6266
self.progress("Files needing formatting found.")
@@ -72,7 +76,7 @@ def run(self):
7276

7377

7478
if __name__ == '__main__':
75-
parser = argparse.ArgumentParser(description='Check all Python files for astyle cleanliness')
79+
parser = argparse.ArgumentParser(description='Check C and C++ files for astyle cleanliness')
7680
parser.add_argument('--dry-run',
7781
action='store_true',
7882
default=DRY_RUN_DEFAULT,

0 commit comments

Comments
 (0)