diff --git a/.github/automation/.azure-pipeline.yml b/.github/automation/.azure-pipeline.yml index 91d3ac2de14..e19fb98e7db 100644 --- a/.github/automation/.azure-pipeline.yml +++ b/.github/automation/.azure-pipeline.yml @@ -21,17 +21,6 @@ trigger: - rls-* jobs: - - job: 'ClangFormat' - pool: - vmImage: 'ubuntu-20.04' - steps: - - script: | - .github/automation/env/clang.sh 11 - displayName: 'init' - - script: | - .github/automation/clang-format.sh - displayName: 'ClangFormat_Check' - failOnStderr: true - job: 'Ubuntu20' timeoutInMinutes: 120 pool: diff --git a/.github/automation/clang-format.sh b/.github/automation/clang-format.sh index b38c3877466..f7e1fe62def 100755 --- a/.github/automation/clang-format.sh +++ b/.github/automation/clang-format.sh @@ -16,10 +16,17 @@ # limitations under the License. #=============================================================================== -echo "Using clang-format version: $(clang-format --version)" +CLANG_FORMAT=clang-format-11 + +echo "Checking ${CLANG_FORMAT}" +if ! ${CLANG_FORMAT} --version; then + echo ${CLANG_FORMAT} is not available or not working correctly. + exit 1 +fi + echo "Starting format check..." -for filename in $(find "$(pwd)" -type f | grep -P ".*\.(c|cpp|h|hpp|cl)$"); do clang-format -style=file -i $filename; done +for filename in $(find "$(pwd)" -type f | grep -P ".*\.(c|cpp|h|hpp|cl)$"); do ${CLANG_FORMAT} -style=file -i $filename; done RETURN_CODE=0 echo $(git status) | grep "nothing to commit" > /dev/null @@ -32,4 +39,4 @@ else echo "Clang-format check PASSED! Not formatted files not found..." fi -exit ${RETURN_CODE} \ No newline at end of file +exit ${RETURN_CODE} diff --git a/.github/workflows/commit-msg-check.yml b/.github/workflows/pr-linter.yml similarity index 85% rename from .github/workflows/commit-msg-check.yml rename to .github/workflows/pr-linter.yml index 6d41bf56a45..972773b978f 100644 --- a/.github/workflows/commit-msg-check.yml +++ b/.github/workflows/pr-linter.yml @@ -16,7 +16,7 @@ # limitations under the License. # ******************************************************************************* -name: "PR Checks" +name: "PR Linters" on: pull_request: @@ -31,8 +31,8 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - commit-message-check: - name: Commit message checker + pr-formatting: + name: Formatting runs-on: ubuntu-latest steps: - name: Checkout @@ -41,3 +41,7 @@ jobs: fetch-depth: 0 - name: Check commit messages run: python3 ./.github/automation/commit-msg-check.py "${{ github.event.pull_request.head.sha }}" "${{ github.event.pull_request.base.sha }}" + - name: Install clang-format + run: sudo apt update && sudo apt install -y "clang-format-11" + - name: Check code formatting + run: .github/automation/clang-format.sh