Skip to content

#2378: update .clang-format to match style guidelines #40

#2378: update .clang-format to match style guidelines

#2378: update .clang-format to match style guidelines #40

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 await 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
}
}
console.log(response)
console.log(commentId)
const { CLANG_FORMAT_DIFF } = process.env
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '```diff\n' + CLANG_FORMAT_DIFF + '\n```'
})