From 39fd981b17714f581cef1401661a371665509478 Mon Sep 17 00:00:00 2001 From: Dalton Verhagen Date: Wed, 8 Nov 2023 10:13:32 +0100 Subject: [PATCH] Add generated files for clang-format linter addition Direct follow-up of the previous commit. Just adds the generated files that are a result of adding clang-format. This closes #763 --- .automation/generated/linter-helps.json | 98 ++++++++ .../generated/linter-links-previews.json | 5 + .automation/generated/linter-versions.json | 1 + .github/workflows/deploy-BETA-linters.yml | 2 + .github/workflows/deploy-DEV-linters.yml | 2 + .github/workflows/deploy-RELEASE-linters.yml | 2 + Dockerfile | 1 + docs/standalone-linters.md | 2 + flavors/c_cpp/Dockerfile | 1 + flavors/c_cpp/flavor.json | 2 + linters/c_clang_format/Dockerfile | 211 ++++++++++++++++++ linters/cpp_clang_format/Dockerfile | 211 ++++++++++++++++++ megalinter/descriptors/all_flavors.json | 2 + .../megalinter-configuration.jsonschema.json | 2 + .../linters/c_clang_format_test.py | 14 ++ .../linters/cpp_clang_format_test.py | 14 ++ 16 files changed, 570 insertions(+) create mode 100644 linters/c_clang_format/Dockerfile create mode 100644 linters/cpp_clang_format/Dockerfile create mode 100644 megalinter/tests/test_megalinter/linters/c_clang_format_test.py create mode 100644 megalinter/tests/test_megalinter/linters/cpp_clang_format_test.py diff --git a/.automation/generated/linter-helps.json b/.automation/generated/linter-helps.json index df05ad2a29c..00e07206c6d 100644 --- a/.automation/generated/linter-helps.json +++ b/.automation/generated/linter-helps.json @@ -1232,6 +1232,104 @@ "Any of the above arguments can be made permanent by setting them in the", "chktexrc file (~/.chktexrc)." ], + "clang-format": [ + "OVERVIEW: A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.", + "", + "If no arguments are specified, it formats the code from standard input", + "and writes the result to the standard output.", + "If s are given, it reformats the files. If -i is specified", + "together with s, the files are edited in-place. Otherwise, the", + "result is written to the standard output.", + "", + "USAGE: clang-format [options] [ ...]", + "", + "OPTIONS:", + "", + "Clang-format options:", + "", + " --Werror - If set, changes formatting warnings to errors", + " --Wno-error= - If set don't error out on the specified warning type.", + " =unknown - If set, unknown format options are only warned about.", + " This can be used to enable formatting, even if the", + " configuration contains unknown (newer) options.", + " Use with caution, as this might lead to dramatically", + " differing format depending on an option being", + " supported or not.", + " --assume-filename= - Set filename used to determine the language and to find", + " .clang-format file.", + " Only used when reading from stdin.", + " If this is not passed, the .clang-format file is searched", + " relative to the current working directory when reading stdin.", + " Unrecognized filenames are treated as C++.", + " supported:", + " CSharp: .cs", + " Java: .java", + " JavaScript: .mjs .js .ts", + " Json: .json", + " Objective-C: .m .mm", + " Proto: .proto .protodevel", + " TableGen: .td", + " TextProto: .textpb .pb.txt .textproto .asciipb", + " Verilog: .sv .svh .v .vh", + " --cursor= - The position of the cursor when invoking", + " clang-format from an editor integration", + " --dry-run - If set, do not actually make the formatting changes", + " --dump-config - Dump configuration options to stdout and exit.", + " Can be used with -style option.", + " --fallback-style= - The name of the predefined style used as a", + " fallback in case clang-format is invoked with", + " -style=file, but can not find the .clang-format", + " file to use. Defaults to 'LLVM'.", + " Use -fallback-style=none to skip formatting.", + " --ferror-limit= - Set the maximum number of clang-format errors to emit", + " before stopping (0 = no limit).", + " Used only with --dry-run or -n", + " --files= - A file containing a list of files to process, one per line.", + " -i - Inplace edit s, if specified.", + " --length= - Format a range of this length (in bytes).", + " Multiple ranges can be formatted by specifying", + " several -offset and -length pairs.", + " When only a single -offset is specified without", + " -length, clang-format will format up to the end", + " of the file.", + " Can only be used with one input file.", + " --lines= - : - format a range of", + " lines (both 1-based).", + " Multiple ranges can be formatted by specifying", + " several -lines arguments.", + " Can't be used with -offset and -length.", + " Can only be used with one input file.", + " -n - Alias for --dry-run", + " --offset= - Format a range starting at this byte offset.", + " Multiple ranges can be formatted by specifying", + " several -offset and -length pairs.", + " Can only be used with one input file.", + " --output-replacements-xml - Output replacements as XML.", + " --qualifier-alignment= - If set, overrides the qualifier alignment style", + " determined by the QualifierAlignment style flag", + " --sort-includes - If set, overrides the include sorting behavior", + " determined by the SortIncludes style flag", + " --style= - Set coding style. can be:", + " 1. A preset: LLVM, GNU, Google, Chromium, Microsoft,", + " Mozilla, WebKit.", + " 2. 'file' to load style configuration from a", + " .clang-format file in one of the parent directories", + " of the source file (for stdin, see --assume-filename).", + " If no .clang-format file is found, falls back to", + " --fallback-style.", + " --style=file is the default.", + " 3. 'file:' to explicitly specify", + " the configuration file.", + " 4. \"{key: value, ...}\" to set specific parameters, e.g.:", + " --style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"", + " --verbose - If set, shows the list of processed files", + "", + "Generic Options:", + "", + " --help - Display available options (--help-hidden for more)", + " --help-list - Display list of available options (--help-list-hidden for more)", + " --version - Display the version of this program" + ], "clippy": [ "Checks a package to catch common mistakes and improve your Rust code.", "", diff --git a/.automation/generated/linter-links-previews.json b/.automation/generated/linter-links-previews.json index b10deae791b..568a3e0b10f 100644 --- a/.automation/generated/linter-links-previews.json +++ b/.automation/generated/linter-links-previews.json @@ -64,6 +64,11 @@ "image": null, "title": "ChkTeX - LaTeX semantic checker" }, + "clang-format": { + "description": "A\u0302\u00ab ClangCheck :: Contents :: Clang-Format Style Options A\u0302\u00bb.", + "image": null, + "title": "ClangFormat \u2014 Clang 18.0.0git documentation" + }, "clippy": { "description": "A bunch of lints to catch common mistakes and improve your Rust code - rust-lang/rust-clippy", "image": "https://avatars1.githubusercontent.com/u/5430905?s=400&v=4", diff --git a/.automation/generated/linter-versions.json b/.automation/generated/linter-versions.json index 550f2a854e6..c6b88853ebd 100644 --- a/.automation/generated/linter-versions.json +++ b/.automation/generated/linter-versions.json @@ -11,6 +11,7 @@ "checkov": "3.0.24", "checkstyle": "10.12.4", "chktex": "1.7.8", + "clang-format": "16.0.6", "clippy": "0.1.73", "clj-kondo": "2023.10.20", "cljstyle": "0.15.0", diff --git a/.github/workflows/deploy-BETA-linters.yml b/.github/workflows/deploy-BETA-linters.yml index 35f352a49d4..745de04bc19 100644 --- a/.github/workflows/deploy-BETA-linters.yml +++ b/.github/workflows/deploy-BETA-linters.yml @@ -82,12 +82,14 @@ jobs: "bash_shfmt", "bicep_bicep_linter", "c_cpplint", + "c_clang_format", "clojure_clj_kondo", "clojure_cljstyle", "cloudformation_cfn_lint", "coffee_coffeelint", "copypaste_jscpd", "cpp_cpplint", + "cpp_clang_format", "csharp_dotnet_format", "csharp_csharpier", "css_stylelint", diff --git a/.github/workflows/deploy-DEV-linters.yml b/.github/workflows/deploy-DEV-linters.yml index dae80269afe..91e2a2ec109 100644 --- a/.github/workflows/deploy-DEV-linters.yml +++ b/.github/workflows/deploy-DEV-linters.yml @@ -70,12 +70,14 @@ jobs: "bash_shfmt", "bicep_bicep_linter", "c_cpplint", + "c_clang_format", "clojure_clj_kondo", "clojure_cljstyle", "cloudformation_cfn_lint", "coffee_coffeelint", "copypaste_jscpd", "cpp_cpplint", + "cpp_clang_format", "csharp_dotnet_format", "csharp_csharpier", "css_stylelint", diff --git a/.github/workflows/deploy-RELEASE-linters.yml b/.github/workflows/deploy-RELEASE-linters.yml index 535fca2907e..cdca3e404f3 100644 --- a/.github/workflows/deploy-RELEASE-linters.yml +++ b/.github/workflows/deploy-RELEASE-linters.yml @@ -57,12 +57,14 @@ jobs: "bash_shfmt", "bicep_bicep_linter", "c_cpplint", + "c_clang_format", "clojure_clj_kondo", "clojure_cljstyle", "cloudformation_cfn_lint", "coffee_coffeelint", "copypaste_jscpd", "cpp_cpplint", + "cpp_clang_format", "csharp_dotnet_format", "csharp_csharpier", "css_stylelint", diff --git a/Dockerfile b/Dockerfile index 21ea00283ac..fcf77d9abe0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -115,6 +115,7 @@ RUN apk add --no-cache \ php81-simplexml \ dpkg \ py3-pyflakes \ + clang16-extra-tools \ nodejs \ npm \ yarn \ diff --git a/docs/standalone-linters.md b/docs/standalone-linters.md index 432c138b910..51742d208c7 100644 --- a/docs/standalone-linters.md +++ b/docs/standalone-linters.md @@ -10,12 +10,14 @@ | BASH_SHFMT | oxsecurity/megalinter-only-bash_shfmt:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-bash_shfmt/beta) | | BICEP_BICEP_LINTER | oxsecurity/megalinter-only-bicep_bicep_linter:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-bicep_bicep_linter/beta) | | C_CPPLINT | oxsecurity/megalinter-only-c_cpplint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-c_cpplint/beta) | +| C_CLANG_FORMAT | oxsecurity/megalinter-only-c_clang_format:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-c_clang_format/beta) | | CLOJURE_CLJ_KONDO | oxsecurity/megalinter-only-clojure_clj_kondo:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-clojure_clj_kondo/beta) | | CLOJURE_CLJSTYLE | oxsecurity/megalinter-only-clojure_cljstyle:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-clojure_cljstyle/beta) | | CLOUDFORMATION_CFN_LINT | oxsecurity/megalinter-only-cloudformation_cfn_lint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-cloudformation_cfn_lint/beta) | | COFFEE_COFFEELINT | oxsecurity/megalinter-only-coffee_coffeelint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-coffee_coffeelint/beta) | | COPYPASTE_JSCPD | oxsecurity/megalinter-only-copypaste_jscpd:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-copypaste_jscpd/beta) | | CPP_CPPLINT | oxsecurity/megalinter-only-cpp_cpplint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-cpp_cpplint/beta) | +| CPP_CLANG_FORMAT | oxsecurity/megalinter-only-cpp_clang_format:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-cpp_clang_format/beta) | | CSHARP_DOTNET_FORMAT | oxsecurity/megalinter-only-csharp_dotnet_format:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-csharp_dotnet_format/beta) | | CSHARP_CSHARPIER | oxsecurity/megalinter-only-csharp_csharpier:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-csharp_csharpier/beta) | | CSS_STYLELINT | oxsecurity/megalinter-only-css_stylelint:beta | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter-only-css_stylelint/beta) | diff --git a/flavors/c_cpp/Dockerfile b/flavors/c_cpp/Dockerfile index 8f381c07940..4d71c5dba41 100644 --- a/flavors/c_cpp/Dockerfile +++ b/flavors/c_cpp/Dockerfile @@ -66,6 +66,7 @@ RUN apk add --no-cache \ openssh \ openjdk11 \ py3-pyflakes \ + clang16-extra-tools \ nodejs \ npm \ yarn \ diff --git a/flavors/c_cpp/flavor.json b/flavors/c_cpp/flavor.json index b87a978ea0f..76ff2a463e2 100644 --- a/flavors/c_cpp/flavor.json +++ b/flavors/c_cpp/flavor.json @@ -11,8 +11,10 @@ "BASH_SHELLCHECK", "BASH_SHFMT", "C_CPPLINT", + "C_CLANG_FORMAT", "COPYPASTE_JSCPD", "CPP_CPPLINT", + "CPP_CLANG_FORMAT", "CSS_STYLELINT", "CSS_SCSS_LINT", "DOCKERFILE_HADOLINT", diff --git a/linters/c_clang_format/Dockerfile b/linters/c_clang_format/Dockerfile new file mode 100644 index 00000000000..23e2cde1440 --- /dev/null +++ b/linters/c_clang_format/Dockerfile @@ -0,0 +1,211 @@ +# syntax=docker/dockerfile:1 +########################################### +########################################### +## Dockerfile to run MegaLinter ## +########################################### +########################################### + +# @not-generated + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#FROM__START + +#FROM__END + +################## +# Get base image # +################## +FROM python:3.11.5-alpine3.18 +ARG GITHUB_TOKEN + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#ARG__START + +#ARG__END + +#################### +# Run APK installs # +#################### + +WORKDIR / + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#APK__START +RUN apk add --no-cache \ + bash \ + ca-certificates \ + curl \ + gcc \ + git \ + git-lfs \ + libffi-dev \ + make \ + musl-dev \ + openssh \ + clang16-extra-tools \ + && git config --global core.autocrlf true +#APK__END + +# PATH for golang & python +ENV GOROOT=/usr/lib/go \ + GOPATH=/go + # PYTHONPYCACHEPREFIX="$HOME/.cache/cpython/" NV: not working for all packages :/ +# hadolint ignore=DL3044 +ENV PATH="$PATH":"$GOROOT"/bin:"$GOPATH"/bin +RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin || true && \ + # Ignore npm package issues + yarn config set ignore-engines true || true + +############################## +# Installs rust dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#CARGO__START + +#CARGO__END + +################################ +# Installs python dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#PIPVENV__START + +#PIPVENV__END + +############################ +# Install NPM dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +ENV NODE_OPTIONS="--max-old-space-size=8192" \ + NODE_ENV=production +#NPM__START + +#NPM__END + +# Add node packages to path # +ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ + NODE_PATH="/node-deps/node_modules" + +############################## +# Installs ruby dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#GEM__START + +#GEM__END + +############################## +# COPY instructions # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#COPY__START + +#COPY__END + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#OTHER__START + +#OTHER__END + +################################ +# Installs python dependencies # +################################ +COPY megalinter /megalinter +RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ + && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ + && rm -rf /var/cache/apk/* \ + && find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf + +####################################### +# Copy scripts and rules to container # +####################################### +COPY megalinter/descriptors /megalinter-descriptors +COPY TEMPLATES /action/lib/.automation + +# Copy server scripts +COPY server /server + +########################### +# Get the build arguments # +########################### +ARG BUILD_DATE +ARG BUILD_REVISION +ARG BUILD_VERSION + +################################################# +# Set ENV values used for debugging the version # +################################################# +ENV BUILD_DATE=$BUILD_DATE \ + BUILD_REVISION=$BUILD_REVISION \ + BUILD_VERSION=$BUILD_VERSION + +#FLAVOR__START +ENV MEGALINTER_FLAVOR=none +#FLAVOR__END + +######################################### +# Label the instance and set maintainer # +######################################### +LABEL com.github.actions.name="MegaLinter" \ + com.github.actions.description="The ultimate linters aggregator to make sure your projects are clean" \ + com.github.actions.icon="code" \ + com.github.actions.color="red" \ + maintainer="Nicolas Vuillamy " \ + org.opencontainers.image.created=$BUILD_DATE \ + org.opencontainers.image.revision=$BUILD_REVISION \ + org.opencontainers.image.version=$BUILD_VERSION \ + org.opencontainers.image.authors="Nicolas Vuillamy " \ + org.opencontainers.image.url="https://megalinter.io" \ + org.opencontainers.image.source="https://github.com/oxsecurity/megalinter" \ + org.opencontainers.image.documentation="https://megalinter.io" \ + org.opencontainers.image.vendor="Nicolas Vuillamy" \ + org.opencontainers.image.description="Lint your code base with GitHub Actions" + +#EXTRA_DOCKERFILE_LINES__START +ENV ENABLE_LINTERS=C_CLANG_FORMAT \ + FLAVOR_SUGGESTIONS=false \ + SINGLE_LINTER=C_CLANG_FORMAT \ + PRINT_ALPACA=false \ + LOG_FILE=none \ + SARIF_REPORTER=true \ + TEXT_REPORTER=false \ + UPDATED_SOURCES_REPORTER=false \ + GITHUB_STATUS_REPORTER=false \ + GITHUB_COMMENT_REPORTER=false \ + EMAIL_REPORTER=false \ + FILEIO_REPORTER=false \ + CONFIG_REPORTER=false \ + SARIF_TO_HUMAN=false +RUN mkdir /root/docker_ssh && mkdir /usr/bin/megalinter-sh +EXPOSE 22 +COPY entrypoint.sh /entrypoint.sh +COPY sh /usr/bin/megalinter-sh +COPY sh/megalinter_exec /usr/bin/megalinter_exec +COPY sh/motd /etc/motd +RUN find /usr/bin/megalinter-sh/ -type f -iname "*.sh" -exec chmod +x {} \; && \ + chmod +x entrypoint.sh && \ + chmod +x /usr/bin/megalinter_exec && \ + echo "alias megalinter='python -m megalinter.run'" >> ~/.bashrc && source ~/.bashrc && \ + echo "alias megalinter_exec='/usr/bin/megalinter_exec'" >> ~/.bashrc && source ~/.bashrc +RUN export STANDALONE_LINTER_VERSION="$(python -m megalinter.run --input /tmp --linterversion)" && \ + echo $STANDALONE_LINTER_VERSION +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] +#EXTRA_DOCKERFILE_LINES__END diff --git a/linters/cpp_clang_format/Dockerfile b/linters/cpp_clang_format/Dockerfile new file mode 100644 index 00000000000..7c9a07d8c06 --- /dev/null +++ b/linters/cpp_clang_format/Dockerfile @@ -0,0 +1,211 @@ +# syntax=docker/dockerfile:1 +########################################### +########################################### +## Dockerfile to run MegaLinter ## +########################################### +########################################### + +# @not-generated + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#FROM__START + +#FROM__END + +################## +# Get base image # +################## +FROM python:3.11.5-alpine3.18 +ARG GITHUB_TOKEN + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#ARG__START + +#ARG__END + +#################### +# Run APK installs # +#################### + +WORKDIR / + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#APK__START +RUN apk add --no-cache \ + bash \ + ca-certificates \ + curl \ + gcc \ + git \ + git-lfs \ + libffi-dev \ + make \ + musl-dev \ + openssh \ + clang16-extra-tools \ + && git config --global core.autocrlf true +#APK__END + +# PATH for golang & python +ENV GOROOT=/usr/lib/go \ + GOPATH=/go + # PYTHONPYCACHEPREFIX="$HOME/.cache/cpython/" NV: not working for all packages :/ +# hadolint ignore=DL3044 +ENV PATH="$PATH":"$GOROOT"/bin:"$GOPATH"/bin +RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin || true && \ + # Ignore npm package issues + yarn config set ignore-engines true || true + +############################## +# Installs rust dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#CARGO__START + +#CARGO__END + +################################ +# Installs python dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#PIPVENV__START + +#PIPVENV__END + +############################ +# Install NPM dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +ENV NODE_OPTIONS="--max-old-space-size=8192" \ + NODE_ENV=production +#NPM__START + +#NPM__END + +# Add node packages to path # +ENV PATH="/node-deps/node_modules/.bin:${PATH}" \ + NODE_PATH="/node-deps/node_modules" + +############################## +# Installs ruby dependencies # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#GEM__START + +#GEM__END + +############################## +# COPY instructions # +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# + +#COPY__START + +#COPY__END + +############################################################################################# +## @generated by .automation/build.py using descriptor files, please do not update manually ## +############################################################################################# +#OTHER__START + +#OTHER__END + +################################ +# Installs python dependencies # +################################ +COPY megalinter /megalinter +RUN PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py install \ + && PYTHONDONTWRITEBYTECODE=1 python /megalinter/setup.py clean --all \ + && rm -rf /var/cache/apk/* \ + && find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf + +####################################### +# Copy scripts and rules to container # +####################################### +COPY megalinter/descriptors /megalinter-descriptors +COPY TEMPLATES /action/lib/.automation + +# Copy server scripts +COPY server /server + +########################### +# Get the build arguments # +########################### +ARG BUILD_DATE +ARG BUILD_REVISION +ARG BUILD_VERSION + +################################################# +# Set ENV values used for debugging the version # +################################################# +ENV BUILD_DATE=$BUILD_DATE \ + BUILD_REVISION=$BUILD_REVISION \ + BUILD_VERSION=$BUILD_VERSION + +#FLAVOR__START +ENV MEGALINTER_FLAVOR=none +#FLAVOR__END + +######################################### +# Label the instance and set maintainer # +######################################### +LABEL com.github.actions.name="MegaLinter" \ + com.github.actions.description="The ultimate linters aggregator to make sure your projects are clean" \ + com.github.actions.icon="code" \ + com.github.actions.color="red" \ + maintainer="Nicolas Vuillamy " \ + org.opencontainers.image.created=$BUILD_DATE \ + org.opencontainers.image.revision=$BUILD_REVISION \ + org.opencontainers.image.version=$BUILD_VERSION \ + org.opencontainers.image.authors="Nicolas Vuillamy " \ + org.opencontainers.image.url="https://megalinter.io" \ + org.opencontainers.image.source="https://github.com/oxsecurity/megalinter" \ + org.opencontainers.image.documentation="https://megalinter.io" \ + org.opencontainers.image.vendor="Nicolas Vuillamy" \ + org.opencontainers.image.description="Lint your code base with GitHub Actions" + +#EXTRA_DOCKERFILE_LINES__START +ENV ENABLE_LINTERS=CPP_CLANG_FORMAT \ + FLAVOR_SUGGESTIONS=false \ + SINGLE_LINTER=CPP_CLANG_FORMAT \ + PRINT_ALPACA=false \ + LOG_FILE=none \ + SARIF_REPORTER=true \ + TEXT_REPORTER=false \ + UPDATED_SOURCES_REPORTER=false \ + GITHUB_STATUS_REPORTER=false \ + GITHUB_COMMENT_REPORTER=false \ + EMAIL_REPORTER=false \ + FILEIO_REPORTER=false \ + CONFIG_REPORTER=false \ + SARIF_TO_HUMAN=false +RUN mkdir /root/docker_ssh && mkdir /usr/bin/megalinter-sh +EXPOSE 22 +COPY entrypoint.sh /entrypoint.sh +COPY sh /usr/bin/megalinter-sh +COPY sh/megalinter_exec /usr/bin/megalinter_exec +COPY sh/motd /etc/motd +RUN find /usr/bin/megalinter-sh/ -type f -iname "*.sh" -exec chmod +x {} \; && \ + chmod +x entrypoint.sh && \ + chmod +x /usr/bin/megalinter_exec && \ + echo "alias megalinter='python -m megalinter.run'" >> ~/.bashrc && source ~/.bashrc && \ + echo "alias megalinter_exec='/usr/bin/megalinter_exec'" >> ~/.bashrc && source ~/.bashrc +RUN export STANDALONE_LINTER_VERSION="$(python -m megalinter.run --input /tmp --linterversion)" && \ + echo $STANDALONE_LINTER_VERSION +ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] +#EXTRA_DOCKERFILE_LINES__END diff --git a/megalinter/descriptors/all_flavors.json b/megalinter/descriptors/all_flavors.json index 7641d1bbc3d..e68568a130d 100644 --- a/megalinter/descriptors/all_flavors.json +++ b/megalinter/descriptors/all_flavors.json @@ -12,8 +12,10 @@ "BASH_SHELLCHECK", "BASH_SHFMT", "C_CPPLINT", + "C_CLANG_FORMAT", "COPYPASTE_JSCPD", "CPP_CPPLINT", + "CPP_CLANG_FORMAT", "CSS_STYLELINT", "CSS_SCSS_LINT", "DOCKERFILE_HADOLINT", diff --git a/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json b/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json index 87f85c545f7..0de01ea7a4b 100644 --- a/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json +++ b/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json @@ -118,12 +118,14 @@ "BASH_SHFMT", "BICEP_BICEP_LINTER", "C_CPPLINT", + "C_CLANG_FORMAT", "CLOJURE_CLJ_KONDO", "CLOJURE_CLJSTYLE", "CLOUDFORMATION_CFN_LINT", "COFFEE_COFFEELINT", "COPYPASTE_JSCPD", "CPP_CPPLINT", + "CPP_CLANG_FORMAT", "CSHARP_DOTNET_FORMAT", "CSHARP_CSHARPIER", "CSS_STYLELINT", diff --git a/megalinter/tests/test_megalinter/linters/c_clang_format_test.py b/megalinter/tests/test_megalinter/linters/c_clang_format_test.py new file mode 100644 index 00000000000..d33592aa674 --- /dev/null +++ b/megalinter/tests/test_megalinter/linters/c_clang_format_test.py @@ -0,0 +1,14 @@ +# !/usr/bin/env python3 +""" +Unit tests for C linter clang-format +This class has been automatically @generated by .automation/build.py, please don't update it manually +""" + +from unittest import TestCase + +from megalinter.tests.test_megalinter.LinterTestRoot import LinterTestRoot + + +class c_clang_format_test(TestCase, LinterTestRoot): + descriptor_id = "C" + linter_name = "clang-format" diff --git a/megalinter/tests/test_megalinter/linters/cpp_clang_format_test.py b/megalinter/tests/test_megalinter/linters/cpp_clang_format_test.py new file mode 100644 index 00000000000..19139381e19 --- /dev/null +++ b/megalinter/tests/test_megalinter/linters/cpp_clang_format_test.py @@ -0,0 +1,14 @@ +# !/usr/bin/env python3 +""" +Unit tests for CPP linter clang-format +This class has been automatically @generated by .automation/build.py, please don't update it manually +""" + +from unittest import TestCase + +from megalinter.tests.test_megalinter.LinterTestRoot import LinterTestRoot + + +class cpp_clang_format_test(TestCase, LinterTestRoot): + descriptor_id = "CPP" + linter_name = "clang-format"