mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-02 22:40:10 +00:00
c71d08fc22
before this change, user need to click into the details for more details on the formatting issue identified by the lint workflow. after this change, the workflow pastes the details with a comment, to provide more specific details on the formatting issue if any. Signed-off-by: Kefu Chai <tchaikov@gmail.com>
56 lines
1.4 KiB
YAML
56 lines
1.4 KiB
YAML
name: lint
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- '**.h'
|
|
- '**.cc'
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
format_code:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
|
|
|
|
- name: Install clang-format
|
|
uses: aminya/setup-cpp@290824452986e378826155f3379d31bce8753d76 # v0.37.0
|
|
with:
|
|
clangformat: 17.0.5
|
|
|
|
- name: Run clang-format
|
|
id: clang_format
|
|
run: |
|
|
find include src -name '*.h' -o -name '*.cc' | xargs clang-format -i -style=file -fallback-style=none
|
|
git diff | tee fmt.patch
|
|
if [ -s fmt.patch ]; then
|
|
exit 1
|
|
fi
|
|
- uses: actions/github-script@v7
|
|
if: failure() && steps.clang_format.outcome == 'failure'
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
const patch = fs.readFileSync('fmt.patch', { encoding: 'utf8' });
|
|
const comment = `clang-format 17.0.5 found issues in the formatting in your code:
|
|
<details>
|
|
<summary>
|
|
View the diff from clang-format:
|
|
</summary>
|
|
|
|
\`\`\`diff
|
|
${patch}
|
|
\`\`\`
|
|
|
|
</details>
|
|
`;
|
|
await github.rest.issues.createComment({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
body: comment
|
|
});
|