build: install clang-format from OS package repo (#5071)

Build and install clang-format instead of pulling it from a (potentially)
unmaintained repository
This commit is contained in:
Marco Ferrari 2024-01-01 11:39:59 +01:00 committed by GitHub
parent ededa44d36
commit 19e39e211e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 6 deletions

View file

@ -10,7 +10,6 @@
FROM tenable/terrascan:1.18.11 as terrascan FROM tenable/terrascan:1.18.11 as terrascan
FROM alpine/terragrunt:1.6.6 as terragrunt FROM alpine/terragrunt:1.6.6 as terragrunt
FROM dotenvlinter/dotenv-linter:3.3.0 as dotenv-linter 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/terraform-linters/tflint:v0.50.0 as tflint
FROM ghcr.io/yannh/kubeconform:v0.6.4 as kubeconfrm FROM ghcr.io/yannh/kubeconform:v0.6.4 as kubeconfrm
FROM golang:1.21.5-alpine as golang 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 ghcr.io/clj-kondo/clj-kondo:2023.12.15-alpine as clj-kondo
FROM dart:3.2.4-sdk as dart 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 FROM python:3.12.1-alpine3.19 as base_image
LABEL com.github.actions.name="Super-Linter" \ 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/ COPY --from=shfmt /bin/shfmt /usr/bin/
########################
# Install clang-format #
########################
COPY --from=clang-format /usr/bin/clang-format /usr/bin/
#################### ####################
# Install GitLeaks # # Install GitLeaks #
#################### ####################
@ -239,6 +260,11 @@ ENV DART_SDK /usr/lib/dart
COPY --from=dart "${DART_SDK}" "${DART_SDK}" COPY --from=dart "${DART_SDK}" "${DART_SDK}"
RUN chmod 755 "${DART_SDK}" && chmod 755 "${DART_SDK}/bin" 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 # # Install Lintr #
################# #################

View file

@ -73,6 +73,7 @@ control "super-linter-uninstalled-packages" do
packages = [ packages = [
"cmake", "cmake",
"clang17-extra-tools",
"g++", "g++",
"gnupg", "gnupg",
"libc-dev", "libc-dev",