Skip to content

Conversation

@ReginaldWang
Copy link
Contributor

@ReginaldWang ReginaldWang commented Jan 7, 2026

Clang-Tidy Linter

Problem and Scope

Meant to solve issue #163. Clang-tidy system is set up.

Description

Default clang-tidy file is added. Should cover most limitations of CodeQL. Github action is added (pretty simple, runs on pull request).

Gotchas and Limitations

I have no idea how it interacts with the other .yml files.

Testing

  • HOOTL testing
  • HITL testing
  • Human tested

Testing Details

Larger Impact

Additional Context and Ticket

@ReginaldWang ReginaldWang marked this pull request as draft January 7, 2026 18:11
@dchansen06 dchansen06 linked an issue Jan 7, 2026 that may be closed by this pull request
@dchansen06 dchansen06 added this to the Monorepo Niceties milestone Jan 7, 2026
@dchansen06 dchansen06 added Enhancement New feature or request GitHub Meta, anything related to or dealing with GitHub HOOTL Testing Having to do with or interacting with HOOTL testing Big Fry Something that is complex and/or large Pipe Dream Would be amazing... but realistically... it might be dubious to get it on the car 4 REDUCED Explicitly not a priority but would be nice to do down the road labels Jan 7, 2026
@dchansen06 dchansen06 added 3 NORMAL Important but not really a priority and removed 4 REDUCED Explicitly not a priority but would be nice to do down the road labels Jan 7, 2026
@dchansen06
Copy link
Contributor

Updated your branch with a rebase to keep it updated in prep for #165

@dchansen06 dchansen06 changed the title Add .clang-tidy configuration file Add Clang-Tidy GitHub Action Linter Jan 9, 2026
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy cmake ninja-build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 pieces of software are installed by default on the ubuntu-latest runner you do not need to install them again see the docs for a list of other installed packages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine as part of this you will find actual bugs in our codebase, when you do please document them to the best of your ability in a new GitHub issue for each, thanks!

@dchansen06
Copy link
Contributor

Updating with rebase again

Comment on lines +7 to +29
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Arm Toolchain
uses: carlosperate/arm-none-eabi-gcc-action@v1
with:
release: '12.2.Rel1'

- name: Configure
run: cmake --preset Debug

- name: Run clang-tidy
run: |
files=$(git diff --name-only origin/${{ github.base_ref }} | grep -E '\.(cpp|cc|cxx|c)$' || true)
if [ -z "$files" ]; then
echo "No C/C++ source files changed"
exit 0
fi
clang-tidy -p build $files

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 3 days ago

In general, the fix is to explicitly declare a minimal permissions: block for the workflow or the specific job so that the GITHUB_TOKEN does not inherit potentially broad repository defaults. For this workflow, the job only needs to read the repository contents and diff, so contents: read is sufficient.

The best fix with minimal functional impact is to add a permissions: block at the top (root) level of .github/workflows/Linter.yml, right after the on: declaration and before jobs:. This will apply to all jobs in the workflow (currently just build) and constrain the token to read-only access to repository contents. No steps depend on write permissions (no commenting on PRs, status updates beyond what GitHub does automatically, or pushes), so this change should not break existing behavior.

Concretely: edit .github/workflows/Linter.yml to insert

permissions:
  contents: read

between line 3 (on: [pull_request]) and line 5 (jobs:). No imports or additional methods are needed.

Suggested changeset 1
.github/workflows/Linter.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml
--- a/.github/workflows/Linter.yml
+++ b/.github/workflows/Linter.yml
@@ -2,6 +2,9 @@
 
 on: [pull_request]
 
+permissions:
+  contents: read
+
 jobs:
   build:
     runs-on: ubuntu-latest
EOF
@@ -2,6 +2,9 @@

on: [pull_request]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
Copilot is powered by AI and may make mistakes. Always verify output.
@dchansen06
Copy link
Contributor

Updated with rebase

Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Added steps to install dependencies and configure the build.

Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Replaced clang-tidy-review actions with a direct clang-tidy command.

Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Removed installation of clang-tidy and cmake from dependencies.

Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Removed the 'Configure' step from the Linter workflow.

Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Removed AnalyzeTemporaryDtors option from clang-tidy configuration.

Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Added a configuration step and improved clang-tidy invocation.

Signed-off-by: ReginaldWang <114448545+ReginaldWang@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 NORMAL Important but not really a priority Big Fry Something that is complex and/or large Enhancement New feature or request GitHub Meta, anything related to or dealing with GitHub HOOTL Testing Having to do with or interacting with HOOTL testing Pipe Dream Would be amazing... but realistically... it might be dubious to get it on the car

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup Clang-Tidy System and Incorporate A GitHub Action

2 participants