From 78b788044cbedbec375c0ee0d8d970c8cdbed676 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 | 38 ++++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 12 ++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000000..b79600ba099de --- /dev/null +++ b/.clang-format @@ -0,0 +1,38 @@ +--- +Language: Cpp +BasedOnStyle: Google +IndentWidth: 4 +PPIndentWidth: 1 +IndentPPDirectives: AfterHash +IndentCaseLabels: false +IncludeBlocks: Preserve +SortIncludes: true +SpaceAfterCStyleCast: false +AllowShortIfStatementsOnASingleLine : Never +AllowShortLoopsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AlignConsecutiveMacros: true +AllowAllArgumentsOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +Cpp11BracedListStyle: false +InsertNewlineAtEOF: true +SpacesInContainerLiterals: false +BinPackArguments: true +BinPackParameters: true +AlignAfterOpenBracket: Align +BracedInitializerIndentWidth: 4 +SeparateDefinitionBlocks: Always +BreakBeforeBraces: Custom +AllowShortCaseLabelsOnASingleLine: true +BraceWrapping: + AfterControlStatement: MultiLine + AfterCaseLabel: false + AfterEnum: true + AfterFunction: true +AlignConsecutiveAssignments: + Enabled: true + AcrossEmptyLines: false + AcrossComments: false +PackConstructorInitializers: Never +BreakConstructorInitializers: BeforeComma +--- diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cc3e17a6863e9..b0ce8fd3cad3a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -46,3 +46,15 @@ jobs: - uses: actions/checkout@v4 - uses: editorconfig-checker/action-editorconfig-checker@main - run: editorconfig-checker -config .editorconfig-checker.json + + clang-format-lint: + runs-on: ubuntu-latest + 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