From 74f3b174843ce251eea6e2636763ade61628de7a Mon Sep 17 00:00:00 2001 From: Eddy Zhou <71026430+Edwardius@users.noreply.github.com> Date: Thu, 8 Feb 2024 04:10:45 +0900 Subject: [PATCH] Deduplicate Linter Workflows and make it smoother (#71) * giving the linter a name * trying to make the check a requirement * actually write the copyright * dedup linter * specify to run on all prs to main * test linter * more testing * Fix code style issues with Autopep8 * Fix code style issues with clang_format * fix auto-linter locking up ci * Fix code style issues with clang_format * testing * testing with different token * Fix code style issues with clang_format * adding auto-lint remove label script * capitalization * final test * whoops * rename * switch around ordering * maybe now? * Fix code style issues with Autopep8 * Fix code style issues with clang_format --------- Co-authored-by: WATonomousAdmin --- .github/workflows/linting_auto.yml | 23 ++++++++++-- .github/workflows/linting_check.yml | 35 ------------------- .../aggregator/aggregator/aggregator_node.py | 14 ++++---- .../transformer/transformer_node.py | 4 +-- 4 files changed, 29 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/linting_check.yml diff --git a/.github/workflows/linting_auto.yml b/.github/workflows/linting_auto.yml index 77140317..a02b3b0c 100644 --- a/.github/workflows/linting_auto.yml +++ b/.github/workflows/linting_auto.yml @@ -1,9 +1,15 @@ name: Monorepo Code Linting - Auto Linter on: + push: + branches: + - main pull_request: + branches: + - main types: - labeled + - synchronize jobs: run-linters: @@ -13,6 +19,8 @@ jobs: steps: - name: Check out Git repository uses: actions/checkout@v4 + with: + token: ${{ secrets.GHCR_PWD }} - name: Set up Python uses: actions/setup-python@v1 @@ -23,13 +31,24 @@ jobs: run: pip install autopep8 clang-format - name: Run linters, make changes + continue-on-error: true uses: WATonomous/wato-lint-action@v1 with: - git_name: WATonomousAdmin - git_email: admin@watonomous.ca auto_fix: ${{ contains(github.event.pull_request.labels.*.name, 'auto-lint') }} Autopep8: true Autopep8_args: "--max-line-length 100" clang_format: true clang_format_auto_fix: ${{ contains(github.event.pull_request.labels.*.name, 'auto-lint') }} clang_format_args: "-style=file" + + - name: Remove 'auto-lint' label to stop possible inf loop + if: contains(github.event.pull_request.labels.*.name, 'auto-lint') + uses: actions/github-script@v6 + with: + script: | + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: 'auto-lint' + }); \ No newline at end of file diff --git a/.github/workflows/linting_check.yml b/.github/workflows/linting_check.yml deleted file mode 100644 index 51395272..00000000 --- a/.github/workflows/linting_check.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Monorepo Code Linting - Checker - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - run-linters: - name: Run C++/Python linters - runs-on: ubuntu-latest - - steps: - - name: Check out Git repository - uses: actions/checkout@v4 - - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - - name: Install Python dependencies - run: pip install autopep8 clang-format - - - name: Run linters - uses: WATonomous/wato-lint-action@v1 - with: - check_name: "Check ${linter}" - Autopep8: true - Autopep8_args: "--max-line-length 100" - clang_format: true - clang_format_args: "-style=file" diff --git a/src/samples/python/aggregator/aggregator/aggregator_node.py b/src/samples/python/aggregator/aggregator/aggregator_node.py index 180e505c..f27ef9f6 100755 --- a/src/samples/python/aggregator/aggregator/aggregator_node.py +++ b/src/samples/python/aggregator/aggregator/aggregator_node.py @@ -30,14 +30,12 @@ def __init__(self): self.__aggregator = AggregatorCore(node_start_time) # Initialize ROS2 Constructs - self.unfiltered_subcriber = self.create_subscription(Unfiltered, - '/unfiltered_topic', - self.unfiltered_callback, - 10) - self.filtered_subscriber = self.create_subscription(FilteredArray, - '/filtered_topic', - self.filtered_callback, - 10) + self.unfiltered_subcriber = self.create_subscription( + Unfiltered, '/unfiltered_topic', + self.unfiltered_callback, 10) + self.filtered_subscriber = self.create_subscription( + FilteredArray, '/filtered_topic', + self.filtered_callback, 10) def unfiltered_callback(self, msg): self.__aggregator.update_raw_freq() diff --git a/src/samples/python/transformer/transformer/transformer_node.py b/src/samples/python/transformer/transformer/transformer_node.py index 6ce44ae4..f308e1bd 100755 --- a/src/samples/python/transformer/transformer/transformer_node.py +++ b/src/samples/python/transformer/transformer/transformer_node.py @@ -36,8 +36,8 @@ def __init__(self): # Initialize ROS2 Constructs self.publisher_ = self.create_publisher(FilteredArray, '/filtered_topic', 10) - self.subscription = self.create_subscription(Unfiltered, '/unfiltered_topic', - self.unfiltered_callback, 10) + self.subscription = self.create_subscription( + Unfiltered, '/unfiltered_topic', self.unfiltered_callback, 10) self.__filtered_array_packets = []