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

ci: add clang-tidy job #4408

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions codebuild/spec/buildspec_lints.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use
# this file except in compliance with the License. A copy of the License is
# located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions and
# limitations under the License.
version: 0.2

batch:
build-list:
- identifier: clang_tidy
buildspec: codebuild/spec/lints/clang_tidy.yml
env:
compute-type: BUILD_GENERAL1_LARGE
image: 024603541914.dkr.ecr.us-west-2.amazonaws.com/docker:lints
privileged-mode: true
40 changes: 40 additions & 0 deletions codebuild/spec/lints/clang_tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use
# this file except in compliance with the License. A copy of the License is
# located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing permissions and
# limitations under the License.
version: 0.2

phases:
pre_build:
on-failure: ABORT
commands:
# The exported compile commands will by used by clang-tidy to "build" the
# project for static analysis.
- cmake . -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
build:
on-failure: ABORT
commands:
# The ugly sed command is used to remove ANSI color from clang-tidy output,
# since run-clang-tidy turns that on by default the and the version that we
# use doesn't have an option to disable it.
- |
run-clang-tidy . \
-p build/ \
-quiet \
-checks=-*,cppcoreguidelines-init-variables,clang-analyzer-core.NullDereference,clang-analyzer-core.UndefinedBinaryOperatorResult | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' > clang-tidy.report
- cat clang-tidy.report | grep warning
# This if statement will exit with a non-zero code if grep found any warnings
# in the clang-tidy report.
- |
if [ $? -eq 0 ]; then
exit 1
fi