|
26 | 26 | run: | |
27 | 27 | echo "Checking formatting in dynadjust" |
28 | 28 | ERRORS="" |
29 | | - # Determine clang-format style: use .clang-format if available, |
30 | | - # otherwise default to LLVM style. |
| 29 | + # Use .clang-format if present, otherwise default to LLVM style. |
31 | 30 | if [ -f .clang-format ]; then |
32 | 31 | STYLE=file |
33 | 32 | else |
|
38 | 37 | for f in $files; do |
39 | 38 | diff=$(clang-format -style=$STYLE "$f" | diff "$f" -) |
40 | 39 | if [ -n "$diff" ]; then |
41 | | - echo "Formatting issues found in $f" |
| 40 | + echo "::warning file=$f::Formatting issues found" |
42 | 41 | ERRORS="${ERRORS}\n- $f" |
43 | 42 | ret=1 |
44 | 43 | fi |
|
61 | 60 | repo: context.repo.repo, |
62 | 61 | body: msg |
63 | 62 | }); |
| 63 | +
|
| 64 | + - name: Create Annotations for Formatting Issues |
| 65 | + if: ${{ github.event_name == 'workflow_dispatch' && steps.fmt.outputs.errors != '' }} |
| 66 | + uses: actions/github-script@v6 |
| 67 | + with: |
| 68 | + script: | |
| 69 | + const errors = `${{ steps.fmt.outputs.errors }}`.trim().split('\n').filter(e => e); |
| 70 | + if (errors.length === 0) return; |
| 71 | + github.rest.checks.create({ |
| 72 | + owner: context.repo.owner, |
| 73 | + repo: context.repo.repo, |
| 74 | + name: 'Check code formatting', |
| 75 | + head_sha: context.sha, |
| 76 | + status: 'completed', |
| 77 | + conclusion: 'failure', |
| 78 | + output: { |
| 79 | + title: 'Formatting Issues', |
| 80 | + summary: `Formatting issues detected in the following files:\n${errors.join('\n')}`, |
| 81 | + annotations: errors.map(file => ({ |
| 82 | + path: file.replace(/^- /, ''), |
| 83 | + start_line: 1, |
| 84 | + end_line: 1, |
| 85 | + annotation_level: 'failure', |
| 86 | + message: 'Formatting issues found' |
| 87 | + })) |
| 88 | + } |
| 89 | + }); |
0 commit comments