Skip to content

Commit

Permalink
Use our own clang-format image
Browse files Browse the repository at this point in the history
  • Loading branch information
Manu343726 committed Jan 20, 2019
1 parent 0cbca41 commit f218ea8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ clang-format-check:
tags:
- linux
- docker
image: manu343726/tinyrefl:clang40-x86
image: manu343726/tinyrefl:clang-format-ci
script:
- ./ci/ci_clang_format_check.sh
- CLANG_FORMAT=clang-format ./ci/ci_clang_format_check.sh
- echo clang-format was applied ok
test-clang40-x86-llvm4.0.0:
stage: test
Expand Down
2 changes: 2 additions & 0 deletions ci/ci_clang_format_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ CLANG_FORMAT_SCRIPT=$(pwd)/run-clang-format.sh
if [ ! -e $CLANG_FORMAT_SCRIPT ]; then
echo clang-format script not found
exit 3
else
echo using clang-format script $CLANG_FORMAT_SCRIPT
fi

if bash $CLANG_FORMAT_SCRIPT; then
Expand Down
3 changes: 3 additions & 0 deletions ci/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ build lasote/conangcc7-armv7 gcc7-armv7 gcc g++ CROSS_BUILDING
build lasote/conangcc7 gcc7-x86 gcc g++
build lasote/conangcc8-armv7 gcc8-armv7 gcc g++ CROSS_BUILDING
build lasote/conangcc8 gcc8-x86 gcc g++

docker build clang-format -t manu343726/tinyrefl:clang-format && docker push manu343726/tinyrefl:clang-format
docker build clang-format-ci -t manu343726/tinyrefl:clang-format-ci && docker push manu343726/tinyrefl:clang-format-ci
4 changes: 4 additions & 0 deletions ci/docker/clang-format-ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM manu343726/tinyrefl:clang-format
MAINTAINER Manu Sanchez <Manu343726@gmail.com>

ENTRYPOINT /bin/bash
22 changes: 22 additions & 0 deletions ci/docker/clang-format/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Image based on https://hub.docker.com/r/unibeautify/clang-format
# but adds git so we can diff the clang-format result on CI

FROM debian:sid-slim
MAINTAINER Manu Sanchez <Manu343726@gmail.com>

ARG CLANG_FORMAT_VERSION_ARG=6.0
ENV CLANG_FORMAT_VERSION=$CLANG_FORMAT_VERSION_ARG

RUN apt-get update && \
apt-get install -y clang-format-${CLANG_FORMAT_VERSION} git && \
apt-get clean

RUN update-alternatives \
--install /usr/bin/clang-format clang-format /usr/bin/clang-format-${CLANG_FORMAT_VERSION} 50

# switch to uid/gid identical to host uid/gid (forks/users), if not doing this, files that
# clang-format written will change user and group all to root.
USER 1000:100

ENTRYPOINT ["clang-format"]
CMD ["--help"]
7 changes: 5 additions & 2 deletions run-clang-format.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#!/bin/bash

CLANG_FORMAT=$1
if [[ -z "$CLANG_FORMAT" ]]; then
CLANG_FORMAT=$1
fi

DIRECTORIES=(include src tests examples)

root_dir=$(pwd)

if [[ -z "$CLANG_FORMAT" ]]; then
CLANG_FORMAT="docker run --rm -v ${root_dir}:${root_dir} unibeautify/clang-format"
CLANG_FORMAT="docker run --rm -v ${root_dir}:${root_dir} manu343726/tinyrefl:clang-format"
fi

echo CLANG_FORMAT=$CLANG_FORMAT
Expand Down

0 comments on commit f218ea8

Please sign in to comment.