From 02b36744360415035fbd3fa2a57828eea73486a9 Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 12 Jun 2022 21:44:49 +0100 Subject: [PATCH] Use pre-commit as a step in CI --- .ci.yml | 21 +++++++++++++++------ .pre-commit-config.yaml | 4 +--- resources/docker/llvm/Dockerfile | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.ci.yml b/.ci.yml index b444d74..d0c913c 100644 --- a/.ci.yml +++ b/.ci.yml @@ -5,12 +5,21 @@ platform: os: linux arch: arm64 -steps: -- name: Build - image: rg.fr-par.scw.cloud/serene/llvm:15-7 - commands: - - cmake --version - - ./builder build +trigger: when: branch: - master + +steps: +- name: Build + image: rg.fr-par.scw.cloud/serene/llvm:15-8 + commands: + - cmake --version + - ./builder build +- name: Lint + image: rg.fr-par.scw.cloud/serene/llvm:15-8 + commands: + - pre-commit clang-tidy -a + - pre-commit cppcheck -a + - pre-commit include-what-you-use -a + - pre-commit shell-lint -a diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 54cdc83..439e0c0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,8 +13,6 @@ repos: - id: check-case-conflict - id: check-docstring-first - id: check-executables-have-shebangs - - id: check-json - - id: check-yaml - id: forbid-new-submodules - id: end-of-file-fixer - id: trailing-whitespace @@ -24,7 +22,7 @@ repos: hooks: - id: clang-format #- id: clang-tidy - - id: oclint + #- id: oclint - id: cppcheck args: ['--project=compile_commands.json'] #- id: cpplint diff --git a/resources/docker/llvm/Dockerfile b/resources/docker/llvm/Dockerfile index 8ceaa7e..7aae3df 100644 --- a/resources/docker/llvm/Dockerfile +++ b/resources/docker/llvm/Dockerfile @@ -17,6 +17,8 @@ RUN apt-get update && apt-get install -y apt-utils && apt-get install -y wget \ software-properties-common \ zlib1g \ apt-utils \ + cppcheck \ + shellcheck \ zlib1g-dev RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh @@ -27,11 +29,15 @@ RUN apt-get update --fix-missing && \ libmlir-${VERSION} \ libmlir-${VERSION}-dbgsym \ liblld-${VERSION} \ - liblld-${VERSION}-dev + liblld-${VERSION}-dev \ + clang-format-${VERSION} \ + clang-tidy-${VERSION} RUN ln -s `which lld-${VERSION}` /usr/bin/lld && \ ln -s `which clang-${VERSION}` /usr/bin/clang && \ ln -s `which clang++-${VERSION}` /usr/bin/clang++ && \ + ln -s `which clang-format-${VERSION}` /usr/bin/clang-format && \ + ln -s `which clang-tidy-${VERSION}` /usr/bin/clang-tidy && \ ln -s `which mlir-tblgen-${VERSION}` /usr/bin/mlir-tblgen ENV MLIR_DIR /usr/lib/llvm-${VERSION} @@ -46,5 +52,9 @@ RUN git clone https://github.com/include-what-you-use/include-what-you-use.git - cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${VERSION} ../include-what-you-use && \ make && make install -WORKDIR / +WORKDIR /app RUN rm /iwuy -rf + +COPY .pre-commit-config.yaml . +RUN git init . +RUN apt-get install -y --no-install-recommends pre-commit && pre-commit autoupdate && rm /app/.pre-commit-config.yaml