Skip to content

Commit

Permalink
Merge pull request #2379 from DARMA-tasking/2378-update-clang-format
Browse files Browse the repository at this point in the history
#2378: update `.clang-format` to match style guidelines
  • Loading branch information
lifflander authored Feb 27, 2025
2 parents 6b13039 + ca3aa8f commit 328cda2
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ColumnLimit: 80
UseTab: Never

AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
AlignAfterOpenBracket: BlockIndent
AlignConsecutiveAssignments: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
Expand Down Expand Up @@ -89,4 +89,4 @@ SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++14
Standard: c++17
59 changes: 59 additions & 0 deletions .github/workflows/run-clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: PR checks (clang-format)

on: pull_request

jobs:
check:
name: Run clang-format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Run clang-format
run: |
{
echo 'CLANG_FORMAT_DIFF<<EOF'
git clang-format-16 --diff origin/${{ github.base_ref }} || true
echo EOF
} >> "$GITHUB_ENV"
- uses: actions/github-script@v7
with:
script: |
let commentId = -1
for await (const { data: comments } of github.paginate.iterator(
github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
}
)) {
const foundComment = comments.find((comment) =>
comment.body.startsWith(
'`clang-format` output for this changeset:'
)
)
if (foundComment) {
commentId = foundComment.id
break
}
}
const { CLANG_FORMAT_DIFF } = process.env
const commentBody = '`clang-format` output for this changeset:\n```diff\n' + CLANG_FORMAT_DIFF + '\n```'
if (commentId === -1) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
})
} else {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: commentId,
body: commentBody
})
}

0 comments on commit 328cda2

Please sign in to comment.