-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from NCAR/111-clang-format
Add clang-format to autoformate C/C++ code
- Loading branch information
Showing
23 changed files
with
991 additions
and
753 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
BasedOnStyle: Google | ||
AlignAfterOpenBracket: 'AlwaysBreak' | ||
AllowAllConstructorInitializersOnNextLine: 'false' | ||
AllowAllParametersOfDeclarationOnNextLine: 'false' | ||
AlignConsecutiveMacros: 'true' | ||
AllowShortCaseLabelsOnASingleLine: 'true' | ||
AllowShortFunctionsOnASingleLine: 'None' | ||
AllowShortIfStatementsOnASingleLine: 'Never' | ||
AllowShortLoopsOnASingleLine: 'false' | ||
BreakBeforeBraces: Allman | ||
BinPackArguments: 'false' | ||
BinPackParameters: 'false' | ||
Cpp11BracedListStyle: 'false' | ||
ColumnLimit: 125 | ||
IndentWidth: 2 | ||
IndentPPDirectives: BeforeHash | ||
NamespaceIndentation: All | ||
PackConstructorInitializers: 'Never' | ||
SpaceAfterTemplateKeyword: 'false' | ||
SpaceBeforeCtorInitializerColon: 'true' | ||
SpaceBeforeInheritanceColon: 'true' | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: 'true' | ||
SpaceInEmptyBlock: true | ||
Standard: 'Latest' | ||
IncludeBlocks: Regroup | ||
IncludeCategories: | ||
# MUSICA project headers | ||
- Regex: '<(musica)\/' | ||
Priority: 2 | ||
# MICM, TUV-X headers | ||
- Regex: '<(micm|tuvx)[[:alnum:].\Q/-_\E]+>' | ||
Priority: 3 | ||
# External libraries headers | ||
- Regex: '<([[:alnum:].\Q/-_\E]+)\/' | ||
Priority: 4 | ||
# System headers | ||
- Regex: '<[[:alnum:].\Q/-_\E]+>' | ||
Priority: 5 | ||
# Main, local, private headers | ||
- Regex: '".*' | ||
Priority: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Clang-Format | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
format: | ||
name: Run Clang-Format | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Install Clang-Format | ||
run: sudo apt-get update && sudo apt-get install clang-format && clang-format --version | ||
|
||
- name: Check out code, run clang format, push changes | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Format code | ||
run: | | ||
find include -type f \( -name '*.hpp' -or -name '*.h' \) -exec clang-format -i --style=file --verbose {} + | ||
find src -type f \( -name '*.cpp' -or -name '*.c' \) -exec clang-format -i --style=file --verbose {} + | ||
- name: Check for changes | ||
id: check-changes | ||
run: git diff --exit-code | ||
continue-on-error: true | ||
|
||
- name: Commit and push changes | ||
# a failue of this step means changes were detected | ||
if: steps.check-changes.outcome != 'success' | ||
run: | | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "actions@github.com" | ||
git commit -am "Auto-format code using Clang-Format" || echo "No changes to commit" | ||
- name: Push changes to main-formatting branch | ||
if: steps.check-changes.outcome != 'success' | ||
run: git push origin HEAD:main-formatting | ||
|
||
- name: Create Pull Request | ||
if: steps.check-changes.outcome != 'success' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: "Auto-format code using Clang-Format" | ||
title: "Auto-format code changes" | ||
body: "This is an automated pull request to apply code formatting using Clang-Format." | ||
branch: "main-formatting" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
/** | ||
* This file contains the version information for the different project modules | ||
* Copyright (C) 2023-2024 National Center for Atmospheric Research, | ||
* | ||
* SPDX-License-Identifier: Apache-2.0* creating solvers, and solving the model. | ||
/* Copyright (C) 2023-2024 National Center for Atmospheric Research | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
namespace musica { | ||
extern "C" { | ||
namespace musica | ||
{ | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
char* getAllComponentVersions(); | ||
char* getAllComponentVersions(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
} | ||
} | ||
#endif |
Oops, something went wrong.