Skip to content

Commit

Permalink
Merge pull request #11 from open-atmos/config_changes
Browse files Browse the repository at this point in the history
proposed changes to configuration format
  • Loading branch information
K20shores authored Jan 18, 2024
2 parents 500a7c0 + 6b714de commit 3d45292
Show file tree
Hide file tree
Showing 35 changed files with 1,732 additions and 390 deletions.
26 changes: 26 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
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: 150
IndentWidth: 2
IndentPPDirectives: AfterHash
NamespaceIndentation: All
PackConstructorInitializers: 'Never'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyBlock: true
Standard: 'Latest'
58 changes: 58 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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

- name: Check out code, run clang format, push changes
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Format code
run: |
find include -type f \( -name '*.hpp' -o -name '*.h' \) -exec clang-format -i --style=file {} +
find src -type f \( -name '*.cu' -o -name '*.hpp' -o -name '*.h' -o -name '*.cpp' \) -exec clang-format -i --style=file {} +
find test -type f \( -name '*.hpp' -o -name '*.h' -o -name '*.cpp' \) ! -path 'test/tutorial/*' -exec clang-format -i --style=file {} +
- 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
# a failue of this step means changes were detected
if: steps.check-changes.outcome != 'success'
run: |
git push origin HEAD:main-formatting
- name: Create Pull Request
# a failue of this step means changes were detected
if: steps.check-changes.outcome != 'success'
uses: peter-evans/create-pull-request@v3
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"
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ add_subdirectory(src)
if(PROJECT_IS_TOP_LEVEL AND ENABLE_TESTS)
enable_testing()
add_subdirectory(test)

# Copy example folder to use as test data

add_custom_target(copy_example_configs ALL ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/examples ${CMAKE_BINARY_DIR}/examples)
endif()

################################################################################
Expand Down
Loading

0 comments on commit 3d45292

Please sign in to comment.