From f647d80b0856f3caed4856c37fe75ff4d12e2c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 19 Oct 2024 22:17:10 +0200 Subject: [PATCH] workflows/lint: add clang-format on changed files The entire codebase is not ready to be clang-formatted and probably never will be, but we can at least check if the changes in new pull requests follow our coding style. --- .clang-format | 20 ++++++++++++++++++++ .github/workflows/lint.yml | 13 +++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000000..d49333055eeaf --- /dev/null +++ b/.clang-format @@ -0,0 +1,20 @@ +BasedOnStyle: Google +BreakBeforeBraces: Linux +IndentWidth: 4 +PPIndentWidth: 1 +IndentPPDirectives: AfterHash +IndentCaseLabels: false +IncludeBlocks: Preserve +SortIncludes: true +SpaceAfterCStyleCast: false +AllowShortIfStatementsOnASingleLine : Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AlignArrayOfStructures: Right +AlignConsecutiveAssignments: true +AllowAllParametersOfDeclarationOnNextLine: false +Cpp11BracedListStyle: true +InsertNewlineAtEOF: true +SpacesInContainerLiterals: false +BinPackArguments: true +BinPackParameters: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3aece2f4d71b1..8fdd3c54dd64e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,3 +39,16 @@ jobs: steps: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 + + clang-format-lint: + runs-on: ubuntu-24.04 + container: + image: "registry.opensuse.org/home/mia/images/images/mpv-ci:stable-deps" + if: github.event_name == 'pull_request' + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 50 + - name: Check Formatting + run: | + git clang-format ${{ github.event.pull_request.base.sha }} --diff