Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clang tidy review action #252

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
147 changes: 147 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Generated from CLion Inspection settings
---
Checks: '-*,
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bad-signal-to-kill-thread,
bugprone-branch-clone,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-dynamic-static-initializers,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-integer-division,
bugprone-lambda-function-name,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-pointer-arithmetic-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-no-escape,
bugprone-parent-virtual-call,
bugprone-posix-return,
bugprone-reserved-identifier,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-spuriously-wake-up-functions,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-enum-usage,
bugprone-suspicious-include,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-suspicious-memory-comparison,
bugprone-suspicious-realloc-usage,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unhandled-self-assignment,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
cert-dcl21-cpp,
cert-dcl58-cpp,
cert-err34-c,
cert-err52-cpp,
cert-err60-cpp,
cert-flp30-c,
cert-msc50-cpp,
cert-msc51-cpp,
cert-str34-c,
cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-slicing,
google-default-arguments,
google-explicit-constructor,
google-runtime-operator,
hicpp-exception-baseclass,
hicpp-multiway-paths-covered,
misc-misplaced-const,
misc-new-delete-overloads,
misc-no-recursion,
misc-non-copyable-objects,
misc-throw-by-value-catch-by-reference,
misc-unconventional-assign-operator,
misc-uniqueptr-reset-release,
modernize-avoid-bind,
modernize-concat-nested-namespaces,
modernize-deprecated-headers,
modernize-deprecated-ios-base-aliases,
modernize-loop-convert,
modernize-make-shared,
modernize-make-unique,
modernize-pass-by-value,
modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-replace-auto-ptr,
modernize-replace-disallow-copy-and-assign-macro,
modernize-replace-random-shuffle,
modernize-return-braced-init-list,
modernize-shrink-to-fit,
modernize-unary-static-assert,
modernize-use-auto,
modernize-use-bool-literals,
modernize-use-emplace,
modernize-use-equals-default,
modernize-use-equals-delete,
modernize-use-nodiscard,
modernize-use-noexcept,
modernize-use-nullptr,
modernize-use-override,
modernize-use-transparent-functors,
modernize-use-uncaught-exceptions,
mpi-buffer-deref,
mpi-type-mismatch,
openmp-use-default-none,
performance-faster-string-find,
performance-for-range-copy,
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-string-concatenation,
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move,
performance-noexcept-move-constructor,
performance-trivially-destructible,
performance-type-promotion-in-math-fn,
performance-unnecessary-copy-initialization,
performance-unnecessary-value-param,
portability-simd-intrinsics,
readability-avoid-const-params-in-decls,
readability-const-return-type,
readability-container-size-empty,
readability-convert-member-functions-to-static,
readability-delete-null-pointer,
readability-deleted-default,
readability-inconsistent-declaration-parameter-name,
readability-make-member-function-const,
readability-misleading-indentation,
readability-misplaced-array-index,
readability-non-const-parameter,
readability-redundant-control-flow,
readability-redundant-declaration,
readability-redundant-function-ptr-dereference,
readability-redundant-smartptr-get,
readability-redundant-string-cstr,
readability-redundant-string-init,
readability-simplify-subscript-expr,
readability-static-accessed-through-instance,
readability-static-definition-in-anonymous-namespace,
readability-string-compare,
readability-uniqueptr-delete-release,
readability-use-anyofallof'
16 changes: 16 additions & 0 deletions .github/workflows/post-clang-tidy-review-comments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Post clang-tidy review comments

on:
workflow_run:
# The name field of the lint action
workflows: ["pull-request"]
types:
- completed

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: ZedThree/clang-tidy-review/[email protected]
# lgtm_comment_body, max_comments, and annotations need to be set on the posting workflow in a split setup
213 changes: 124 additions & 89 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- uses: pre-commit/[email protected]
with:
extra_args: --files ${{ steps.file_changes.outputs.all_changed_files}}

build-linux:
name: Build Linux
needs: pre-commit
Expand Down Expand Up @@ -69,97 +70,131 @@ jobs:
- name: "Install wheel and conan package"
run: source .venv/bin/activate && pip3 install wheel conan==1.61.0 pytest datashader holoviews pytest-xdist
- name: "Build basilisk"
run: source .venv/bin/activate && python3 conanfile.py --opNav True
- name: "Run Python Tests"
run: |
source .venv/bin/activate
cd src && pytest -n 2 -m "not scenarioTest" --junitxml=../junit/test-results-${{ matrix.python-version }}.xml
- name: "Upload pytest test results"
uses: actions/upload-artifact@v4
with:
name: pytest-results-${{ matrix.python-version }}
path: junit/test-results-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: "Run C/C++ Tests"
working-directory: ./dist3
run: ctest --gtest_output "json:../ctest/ctest-results-linux-${{ matrix.python-version }}.json"
- name: "Upload Google Test CTest results"
uses: actions/upload-artifact@v4
run: source .venv/bin/activate && python3 conanfile.py --vizInterface False
# run: source .venv/bin/activate && python3 conanfile.py --opNav True

- name: Run clang-tidy
uses: ZedThree/[email protected]
id: static-analysis
with:
name: ctest-results-${{ matrix.python-version }}
path: ctest/ctest-results-${{ matrix.python-version }}.json
if: ${{ always() }}
build_dir: dist3
# apt_packages: "libfftw3-dev,libnetcdf-c++4-dev,libopenmpi-dev,petsc-dev,slepc-dev,liblapack-dev,libparpack2-dev,libsundials-dev,uuid-dev"
config_file: ".clang-tidy"
# Googletest triggers a _lot_ of clang-tidy warnings, so ignore all
# the unit tests until they're fixed
exclude: "src/achitecture/utilities/test/*cxx"
cmake_command: ""
split_workflow: true

build-windows:
name: Build Windows
needs: pre-commit
runs-on: windows-2019
strategy:
matrix:
python-version: ["3.9"]
- name: Upload clang-tidy fixes
uses: ZedThree/clang-tidy-review/[email protected]
id: upload-static-analysis-review

post-clang-tidy-review-comments:
name: Post clang-tidy review comments
needs: build-linux
runs-on: ubuntu-20.04
permissions:
actions: read
contents: read
security-events: write
env:
MPLBACKEND: agg
issues: write

steps:
- name: Checkout code
uses: nschloe/action-checkout-with-lfs-cache@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/requirements.txt'
- name: Choco help
uses: crazy-max/ghaction-chocolatey@v3
- uses: ZedThree/clang-tidy-review/[email protected]
with:
args: -h
- name: "Install swig and cmake"
shell: pwsh
run: choco install swig cmake -y
- name: "Create python virtual env"
shell: pwsh
run: python -m venv venv
- name: "Install wheel and conan package"
shell: pwsh
run: |
venv\Scripts\activate
pip install wheel conan==1.61.0 parse six pytest-xdist
- name: "Add basilisk and cmake path to env path"
shell: pwsh
run: |
$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
$newpath = “$oldpath;${{ env.GITHUB_WORKSPACE }}\dist3\Basilisk;C:\Program Files\CMake\bin”
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
- name: "Build basilisk"
shell: pwsh
run: |
venv\Scripts\activate
python conanfile.py --opNav True
- name: "Test Simulation Python"
shell: pwsh
run: |
Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name MPLBACKEND -Value ${MPLBACKEND}
venv\Scripts\activate
cd src\simulation
(Get-ChildItem -Directory).FullName | ForEach-Object { cd $_; pytest -n 2 -m "not scenarioTest"; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}}
- name: "Python Architecture Tests"
shell: pwsh
run: |
venv\Scripts\activate
cd src\architecture
(Get-ChildItem -Directory).FullName | ForEach-Object { cd $_; pytest -n 2; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}}
- name: "Python FswAlgorithms Tests"
shell: pwsh
run: |
venv\Scripts\activate
cd src\fswAlgorithms
(Get-ChildItem -Directory).FullName | ForEach-Object { cd $_; pytest -n 2; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}}
- name: "C/C++ Tests"
shell: pwsh
run: |
cd dist3
ctest --gtest_output "json:../ctest/ctest-results-windows-${{ matrix.python-version }}.json"; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}
workflow_id: ${{github.event.workflow_run.id }}
# lgtm_comment_body, max_comments, and annotations need to be set on the posting workflow in a split setup



# - name: "Run Python Tests"
# run: |
# source .venv/bin/activate
# cd src && pytest -n 2 -m "not scenarioTest" --junitxml=../junit/test-results-${{ matrix.python-version }}.xml
# - name: "Upload pytest test results"
# uses: actions/upload-artifact@v4
# with:
# name: pytest-results-${{ matrix.python-version }}
# path: junit/test-results-${{ matrix.python-version }}.xml
# # Use always() to always run this step to publish test results when there are test failures
# if: ${{ always() }}
# - name: "Run C/C++ Tests"
# working-directory: ./dist3
# run: ctest --gtest_output "json:../ctest/ctest-results-linux-${{ matrix.python-version }}.json"
# - name: "Upload Google Test CTest results"
# uses: actions/upload-artifact@v4
# with:
# name: ctest-results-${{ matrix.python-version }}
# path: ctest/ctest-results-${{ matrix.python-version }}.json
# if: ${{ always() }}

# build-windows:
# name: Build Windows
# needs: pre-commit
# runs-on: windows-2019
# strategy:
# matrix:
# python-version: ["3.9"]
# permissions:
# actions: read
# contents: read
# security-events: write
# env:
# MPLBACKEND: agg
# steps:
# - name: Checkout code
# uses: nschloe/action-checkout-with-lfs-cache@v1
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# cache: 'pip'
# cache-dependency-path: '**/requirements.txt'
# - name: Choco help
# uses: crazy-max/ghaction-chocolatey@v3
# with:
# args: -h
# - name: "Install swig and cmake"
# shell: pwsh
# run: choco install swig cmake -y
# - name: "Create python virtual env"
# shell: pwsh
# run: python -m venv venv
# - name: "Install wheel and conan package"
# shell: pwsh
# run: |
# venv\Scripts\activate
# pip install wheel conan==1.61.0 parse six pytest-xdist
# - name: "Add basilisk and cmake path to env path"
# shell: pwsh
# run: |
# $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
# $newpath = “$oldpath;${{ env.GITHUB_WORKSPACE }}\dist3\Basilisk;C:\Program Files\CMake\bin”
# Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath
# - name: "Build basilisk"
# shell: pwsh
# run: |
# venv\Scripts\activate
# python conanfile.py --opNav True
# - name: "Test Simulation Python"
# shell: pwsh
# run: |
# Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name MPLBACKEND -Value ${MPLBACKEND}
# venv\Scripts\activate
# cd src\simulation
# (Get-ChildItem -Directory).FullName | ForEach-Object { cd $_; pytest -n 2 -m "not scenarioTest"; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}}
# - name: "Python Architecture Tests"
# shell: pwsh
# run: |
# venv\Scripts\activate
# cd src\architecture
# (Get-ChildItem -Directory).FullName | ForEach-Object { cd $_; pytest -n 2; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}}
# - name: "Python FswAlgorithms Tests"
# shell: pwsh
# run: |
# venv\Scripts\activate
# cd src\fswAlgorithms
# (Get-ChildItem -Directory).FullName | ForEach-Object { cd $_; pytest -n 2; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}}
# - name: "C/C++ Tests"
# shell: pwsh
# run: |
# cd dist3
# ctest --gtest_output "json:../ctest/ctest-results-windows-${{ matrix.python-version }}.json"; if(($LastExitCode -ne 0) -and ($LastExitCode -ne 5)) {exit 1}
Loading
Loading