From 885a1946340dbb951eaeefba8da7f57f8ec057e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 28 Mar 2019 23:31:28 +0100 Subject: [PATCH] Perform clang-format on Azure --- build/pipelines/azure-pipelines.ci.yaml | 4 +++ build/pipelines/templates/clang-format.yaml | 37 +++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 build/pipelines/templates/clang-format.yaml diff --git a/build/pipelines/azure-pipelines.ci.yaml b/build/pipelines/azure-pipelines.ci.yaml index 31ce98fb..5a316045 100644 --- a/build/pipelines/azure-pipelines.ci.yaml +++ b/build/pipelines/azure-pipelines.ci.yaml @@ -18,6 +18,10 @@ jobs: parameters: platform: x64 +- template: ./templates/clang-format.yaml + parameters: + platform: x64 + - template: ./templates/build-app-public.yaml parameters: platform: x86 diff --git a/build/pipelines/templates/clang-format.yaml b/build/pipelines/templates/clang-format.yaml new file mode 100644 index 00000000..8d5acfc0 --- /dev/null +++ b/build/pipelines/templates/clang-format.yaml @@ -0,0 +1,37 @@ +# Job for running clang-format on sources. + +parameters: + platform: '' + condition: '' + +jobs: +- job: Format${{ parameters.platform }} + displayName: clang-format + pool: + vmImage: 'Ubuntu-16.04' + + steps: + - script: | + # Download a recent, static build of clang-format. Be quiet, but don't hide errors. + wget --no-verbose https://github.com/angular/clang-format/raw/master/bin/linux_x64/clang-format + chmod a+x clang-format + # Make sure it identifies itself + ./clang-format --version + # Parse full lines + export IFS=$'\n' + # For each file in repository with name ending with ".cpp" ... + for file in $(git ls-files | grep \\.cpp$); do + # ... print its name, in case clang-format throws some errors ... + echo Formatting "$file" + # ... and format it in place, so git can pick it up. + ./clang-format -style=file -i "$file" + done + # Just some visual separation + echo -e "\\n\\n\\n\\tChecking diff...\\n\\n\\n" + # Set error mode. Makes bash bail on first non-zero exit code + set -e + # Print diff, if any and report with exit code. + git diff --exit-code + # When no diff present, provide status. + echo -e "\\tStyle is fine" + displayName: 'clang-format'