From 19e39e211efc0870b17f6d3742fad69a777eed06 Mon Sep 17 00:00:00 2001 From: Marco Ferrari Date: Mon, 1 Jan 2024 11:39:59 +0100 Subject: [PATCH] build: install clang-format from OS package repo (#5071) Build and install clang-format instead of pulling it from a (potentially) unmaintained repository --- Dockerfile | 38 ++++++++++++++++--- .../super-linter/controls/super_linter.rb | 1 + 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8e35633f..7f58f8a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,6 @@ FROM tenable/terrascan:1.18.11 as terrascan FROM alpine/terragrunt:1.6.6 as terragrunt FROM dotenvlinter/dotenv-linter:3.3.0 as dotenv-linter -FROM ghcr.io/awkbar-devops/clang-format:v1.0.2 as clang-format FROM ghcr.io/terraform-linters/tflint:v0.50.0 as tflint FROM ghcr.io/yannh/kubeconform:v0.6.4 as kubeconfrm FROM golang:1.21.5-alpine as golang @@ -27,6 +26,33 @@ FROM yoheimuta/protolint:0.47.4 as protolint FROM ghcr.io/clj-kondo/clj-kondo:2023.12.15-alpine as clj-kondo FROM dart:3.2.4-sdk as dart +FROM python:3.12.1-alpine3.19 as clang-format + +RUN apk add --no-cache \ + build-base \ + clang17 \ + cmake \ + git \ + llvm17-dev \ + ninja-is-really-ninja + +WORKDIR /tmp +RUN git clone \ + --branch "llvmorg-$(llvm-config --version)" \ + --depth 1 \ + https://github.com/llvm/llvm-project.git + +WORKDIR /tmp/llvm-project/llvm/build +RUN cmake \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + -DLLVM_BUILD_STATIC=ON \ + -DLLVM_ENABLE_PROJECTS=clang \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ .. \ + && ninja clang-format \ + && mv /tmp/llvm-project/llvm/build/bin/clang-format /usr/bin + FROM python:3.12.1-alpine3.19 as base_image LABEL com.github.actions.name="Super-Linter" \ @@ -191,11 +217,6 @@ COPY --from=dockerfile-lint /bin/hadolint /usr/bin/hadolint ################# COPY --from=shfmt /bin/shfmt /usr/bin/ -######################## -# Install clang-format # -######################## -COPY --from=clang-format /usr/bin/clang-format /usr/bin/ - #################### # Install GitLeaks # #################### @@ -239,6 +260,11 @@ ENV DART_SDK /usr/lib/dart COPY --from=dart "${DART_SDK}" "${DART_SDK}" RUN chmod 755 "${DART_SDK}" && chmod 755 "${DART_SDK}/bin" +######################## +# Install clang-format # +######################## +COPY --from=clang-format /usr/bin/clang-format /usr/bin/ + ################# # Install Lintr # ################# diff --git a/test/inspec/super-linter/controls/super_linter.rb b/test/inspec/super-linter/controls/super_linter.rb index 9f6af1f8..464174a0 100644 --- a/test/inspec/super-linter/controls/super_linter.rb +++ b/test/inspec/super-linter/controls/super_linter.rb @@ -73,6 +73,7 @@ control "super-linter-uninstalled-packages" do packages = [ "cmake", + "clang17-extra-tools", "g++", "gnupg", "libc-dev",