Skip to content

Commit 94035f6

Browse files
committed
Revert hybrid install, handle inexact version
1 parent 5e72917 commit 94035f6

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ branding:
77

88
inputs:
99
clang-format-version:
10-
description: 'The major version of clang-format that you want to use.'
10+
description: 'The version of clang-format that you want to use. Use either major version, or exact one.'
1111
required: false
1212
default: '21'
1313
check-path:

check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ format_diff() {
5656
}
5757

5858
CLANG_FORMAT_VERSION="$1"
59-
CLANG_FORMAT_MAJOR_VERSION=${CLANG_FORMAT_VERSION%%.*}
59+
CLANG_FORMAT_MAJOR_VERSION="${CLANG_FORMAT_VERSION%%.*}"
6060
CHECK_PATH="$2"
6161
FALLBACK_STYLE="$3"
6262
EXCLUDE_REGEX="$4"

clang-format-docker/Dockerfile

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@ ARG UBUNTU_VERSION
22
FROM ubuntu:${UBUNTU_VERSION}
33

44
ARG CLANG_FORMAT_VERSION
5-
ENV CLANG_FORMAT_MAJOR_VERSION=${CLANG_FORMAT_VERSION%%.*}
5+
ENV PIP_ROOT_USER_ACTION=ignore
6+
ENV PIP_BREAK_SYSTEM_PACKAGES=1
67

78
RUN apt-get update \
8-
&& apt-get install --no-install-recommends -y \
9-
clang-format-${CLANG_FORMAT_MAJOR_VERSION} \
10-
&& mv /usr/bin/clang-format-${CLANG_FORMAT_MAJOR_VERSION} /usr/bin/clang-format
11-
12-
RUN [ $CLANG_FORMAT_VERSION != $CLANG_FORMAT_MAJOR_VERSION ] \
13-
&& apt-get install --no-install-recommends -y python-pip \
14-
&& pip install "clang-format~=$CLANG_FORMAT_VERSION" \
15-
&& mv -f "$(which clang-format)" /usr/bin/clang-format
16-
17-
# Clean cache
18-
RUN apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
19-
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
9+
&& apt-get install --no-install-recommends -y python3-pip \
10+
&& pip install -v "$( \
11+
echo "$CLANG_FORMAT_VERSION" | grep -qF '.' \
12+
&& echo "clang-format==${CLANG_FORMAT_VERSION}" \
13+
|| echo "clang-format==${CLANG_FORMAT_VERSION}.*" \
14+
)" \
15+
# Clean cache
16+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
17+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* \
18+
&& mv /usr/local/bin/clang-format /usr/bin/clang-format
2019

2120
WORKDIR /
2221

0 commit comments

Comments
 (0)