Skip to content
Snippets Groups Projects
Commit 4da3f209 authored by Lars Bilke's avatar Lars Bilke
Browse files

Merge branch 'git-clang-format' into 'master'

[ci] Use git clang-format and merged result pipelines.

See merge request ogs/ogs!3761
parents 0692194b 70aa34fa
No related branches found
No related tags found
No related merge requests found
......@@ -46,7 +46,11 @@ repos:
- id: cmake-lint
additional_dependencies: ["cmakelang[YAML]"]
exclude: "scripts/cmake/jedbrown/.*|PackagingMacros.cmake|conan.cmake|CPM.cmake|FindFilesystem.cmake|ConanSetup.cmake|BuildExternalProject.cmake"
- repo: git://github.com/doublify/pre-commit-clang-format
rev: 62302476d0da01515660132d76902359bed0f782
- repo: local
hooks:
- id: clang-format
- id: git-clang-format
name: git-clang-format
entry: bash -c 'if command -v git-clang-format &> /dev/null; then git clang-format; else exit 0; fi'
language: system
pass_filenames: false
files: \.(h|cpp)$
......@@ -2,27 +2,25 @@ pre commit:
stage: preparation
image: $PRECOMMIT_IMAGE
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result"
needs: [ci_images]
variables:
SKIP: clang-format
script:
- pre-commit install
- TARGET_SHA1=$(git show-ref -s ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} | tail -1)
- pre-commit run --from-ref `git merge-base ${TARGET_SHA1} HEAD` --to-ref HEAD
- echo "Target branch is ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}, target sha is ${TARGET_SHA1}."
- git diff --check `git merge-base ${TARGET_SHA1} HEAD` HEAD -- . ':!*.md' ':!*.pandoc' ':!*.asc' ':!*.dat' ':!*.ts'
- echo "Target target sha is ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA}."
- pre-commit run --from-ref ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA} --to-ref HEAD
- git diff --check ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA} HEAD -- . ':!*.md' ':!*.pandoc' ':!*.asc' ':!*.dat' ':!*.ts'
clang-format:
stage: check
image: $PRECOMMIT_IMAGE
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_MERGE_REQUEST_EVENT_TYPE == "merged_result"
needs: [ci_images]
allow_failure: true
script:
- pre-commit install
- TARGET_SHA1=$(git show-ref -s ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME})
- pre-commit run clang-format --from-ref `git merge-base ${TARGET_SHA1} HEAD` --to-ref HEAD
- git clang-format ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA}
- if [[ $(git diff) ]]; then exit 1; fi
after_script:
- git diff
......@@ -13,3 +13,5 @@ RUN wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${clang_
&& tar xf clang+llvm-${clang_version}-x86_64-linux-gnu-ubuntu-16.04.tar.xz \
&& rm clang+llvm-${clang_version}-x86_64-linux-gnu-ubuntu-16.04.tar.xz
ENV PATH="/clang+llvm-${clang_version}-x86_64-linux-gnu-ubuntu-/bin:${PATH}"
RUN ln -s /usr/bin/python3 /usr/bin/python
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment