-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add the cppcheck runner #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
6450c57
feat: add the cppcheck runner
swarnim-deepsource 13d2101
feat: add the Dockerfile
swarnim-deepsource 2a021e7
feat: add cloudbuild to push image to dev
swarnim-deepsource 461e663
fix: dockerfile target binary path
swarnim-deepsource e5c5ecc
fix: naming
swarnim-deepsource 0d4a9b5
add: OWNERS list & enable DeepSource
swarnim-deepsource d7cdd5a
add: base image
swarnim-deepsource aebe3ff
fix: Dockerfile
swarnim-deepsource f6a14c5
fix: add proper issue code mapping
swarnim-deepsource 8c8b56b
add: spdlog to image
swarnim-deepsource a9d11a2
chore: log cppcheck start and end time
swarnim-deepsource 2eebe92
fix
swarnim-deepsource 6df4118
log more
swarnim-deepsource 3af37b6
use multi threading for cppcheck
swarnim-deepsource c69d6b2
chore: only lint on c family of files
swarnim-deepsource 2f18e4b
pipe command output to stdout & stderr
swarnim-deepsource f67f3b2
feat: add support for caching
swarnim-deepsource 03acaad
fix: add comments and cleanup
swarnim-deepsource 53cf507
ci: add production cloudbuild depl
swarnim-deepsource 78c18c1
fix: install cppcheck from source
swarnim-deepsource 4a7845f
fix: pin version of cppcheck
swarnim-deepsource 150f4ce
chore: update dockerfile
swarnim-deepsource 64236af
chore: cleanup dockerfile & don't run on header files
swarnim-deepsource File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version = 1 | ||
|
||
test_patterns = [ | ||
"**/tests/**", | ||
"**/*tests.rs" | ||
] | ||
|
||
exclude_patterns = [ | ||
"tests/**", | ||
"**/tests/**", | ||
] | ||
|
||
[[analyzers]] | ||
name = "rust" | ||
|
||
[analyzers.meta] | ||
msrv = "stable" | ||
|
||
[[analyzers]] | ||
name = "secrets" | ||
|
||
[[transformers]] | ||
name = "rustfmt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @raghav-deepsource @srijan-deepsource @swarnim-deepsource @prajwal-deepsource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/target | ||
/cppcheck_result.json | ||
/cppcheck_error.xml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "cppcheck-deepsource" | ||
version = "0.2.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
# serialize & deserialize | ||
serde = { version = "1.0.144", features = ["derive"] } | ||
# json support | ||
serde_json = "1.0.85" | ||
log = { version = "0.4.17" } | ||
atty = "0.2.14" | ||
walkdir = "2.3.2" | ||
quick-xml = { version = "0.28.0", features = ["serialize"] } | ||
|
||
env_struct = "0.1.3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# ----------------------------------------------------------- | ||
# Base Image with LLVM | ||
# ----------------------------------------------------------- | ||
FROM ubuntu:22.04 as ubuntu_llvm | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
# update the system and install any dependencies | ||
RUN apt-get update \ | ||
&& apt-get upgrade -y libksba-dev \ | ||
&& apt-get install -y git cmake build-essential byacc libpcre3 libpcre3-dev grep lsb-release wget software-properties-common gnupg libcurl4-openssl-dev unzip lcov --no-install-recommends # skipcq: DOK-DL3018 | ||
|
||
# Get LLVM | ||
ARG LLVM_VER=15 | ||
RUN wget --no-verbose https://apt.llvm.org/llvm.sh | ||
RUN chmod +x ./llvm.sh \ | ||
&& ./llvm.sh ${LLVM_VER} \ | ||
&& apt-get -y install libclang-${LLVM_VER}-dev libclang-cpp${LLVM_VER}-dev --no-install-recommends \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Add environment variables for build | ||
ENV PATH="$PATH:/usr/lib/llvm-${LLVM_VER}/bin" | ||
ENV LLVM_INSTALL_DIR "/usr/lib/llvm-${LLVM_VER}" | ||
ENV SENTRY_INSTALL_DIR="/usr/lib/sentry-sdk" | ||
|
||
# Get Sentry | ||
ARG SENTRY_TAG=0.6.3 | ||
RUN mkdir /sentry-sdk \ | ||
&& cd /sentry-sdk \ | ||
&& wget --no-verbose "https://github.com/getsentry/sentry-native/releases/download/${SENTRY_TAG}/sentry-native.zip" \ | ||
&& unzip sentry-native.zip \ | ||
&& cmake -B ./build \ | ||
&& cmake --build ./build --parallel \ | ||
&& cmake --install ./build --prefix "${SENTRY_INSTALL_DIR}" | ||
|
||
# Install spdlog | ||
RUN git clone --depth=1 --branch v1.11.0 https://github.com/gabime/spdlog.git \ | ||
&& cd spdlog \ | ||
&& cmake -B build \ | ||
&& cmake --build build --parallel \ | ||
&& cd build && make install | ||
|
||
# Install cppcheck | ||
RUN git clone --depth=1 --branch 2.10.3 https://github.com/danmar/cppcheck.git \ | ||
&& cd cppcheck \ | ||
&& cmake -B build -DHAVE_RULES=ON -DUSE_MATCHCOMPILER=ON -DCMAKE_BUILD_TYPE=RELEASE \ | ||
&& cmake --build build --parallel 4 \ | ||
&& cd build && make install | ||
|
||
# ----------------------------------------------------------- | ||
# End | ||
# ----------------------------------------------------------- | ||
|
||
FROM rust:slim-bookworm AS rs_builder | ||
|
||
RUN mkdir -p /code | ||
ADD . /code | ||
WORKDIR /code | ||
|
||
RUN cargo b --release | ||
|
||
FROM ubuntu_llvm | ||
|
||
RUN mkdir -p /toolbox | ||
COPY --from=rs_builder /code/target/release/cppcheck-deepsource /toolbox/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "files": [ "test.c" ] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
timeout: 30m0s | ||
|
||
steps: | ||
- name: 'gcr.io/kaniko-project/executor:v1.0.0' | ||
args: | ||
- --destination=us.gcr.io/deepsource-production/cppcheck-deepsource:$TAG_NAME | ||
- --destination=us.gcr.io/deepsource-production/cppcheck-deepsource:latest | ||
- --dockerfile=Dockerfile | ||
- --cache=false | ||
- --snapshotMode=redo | ||
|
||
options: | ||
machineType: 'E2_HIGHCPU_8' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
timeout: 30m0s | ||
|
||
steps: | ||
- name: 'gcr.io/kaniko-project/executor:v1.0.0' | ||
args: | ||
- --destination=us.gcr.io/deepsource-dev/cppcheck-deepsource:dev | ||
- --dockerfile=Dockerfile | ||
- --cache=true | ||
- --cache-ttl=24h | ||
- --snapshotMode=redo | ||
|
||
options: | ||
machineType: 'E2_HIGHCPU_8' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use std::path::PathBuf; | ||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Default, Deserialize, Debug)] | ||
pub struct AnalyzerConfig { | ||
files: Vec<PathBuf>, | ||
#[serde(default)] | ||
pub analyzer_meta: AnalyzerMeta, | ||
} | ||
|
||
impl AnalyzerConfig { | ||
pub fn cxx_files(self) -> Vec<PathBuf> { | ||
self.files | ||
.into_iter() | ||
.filter(|f| !f.is_symlink()) | ||
.filter(|f| f.is_file()) | ||
.filter(|f| { | ||
f.extension() | ||
.map(|x| x.eq("cpp") | x.eq("c")) | ||
.unwrap_or_default() | ||
}) | ||
// ignore files > ~25MB in size | ||
.filter(|f| { | ||
!f.metadata() | ||
.map(|x| x.len() > 25_000_000) | ||
.unwrap_or_default() | ||
}) | ||
.collect() | ||
} | ||
} | ||
|
||
#[derive(Deserialize, Default, Debug)] | ||
pub struct AnalyzerMeta { | ||
pub name: String, | ||
pub enabled: bool, | ||
// todo(swarnim): add misra_compliance: bool | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.