Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI(clang-format): Run clang-format faster using a different action that runs in parallel #1035

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 63 additions & 11 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,81 @@
---
name: ClangFormat Check

on:
push:
branches:
- grass[0-9]+
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress:
# Do not cancel on protected branches, like grass8
${{ github.ref_protected != true }}

cancel-in-progress: ${{ github.ref_protected != true }}
permissions: {}

jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
permissions:
contents: read
checks: write
issues: write
pull-requests: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.11.0
- uses: DoozyX/clang-format-lint-action@11b773b1598aa4ae3b32f023701bca5201c3817d # v0.17
with:
clang-format-version: "15"
check-path: .
source: "."
clangFormatVersion: 15
inplace: True
- name: Verify Changed files
uses: tj-actions/verify-changed-files@d774a4c7ebe335445d79c7b44138f56a76058ba0 # v19.0.0
id: verify-changed-files
- id: git-changed-files
run: |
{
echo 'CHANGED_FILES<<EOF'
git ls-files --other --modified --exclude-standard
echo EOF
} >> "$GITHUB_OUTPUT"
- name: List all changed files tracked and untracked files
run: |
echo "Changed files: ${{ steps.git-changed-files.outputs.CHANGED_FILES }}"
- name: Add job summary without changed files
if: ${{ steps.verify-changed-files.outputs.files_changed == 'false' }}
run: |
{
echo "### Changed files:"
echo "No files were changed by clang-format"
} >> "$GITHUB_STEP_SUMMARY"
- name: Add job summary with changed files
if: ${{ steps.verify-changed-files.outputs.files_changed == 'true' }}
run: |
{
echo '### Changed files:'
echo '```'
echo "${CHANGED_FILES}"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
env:
CHANGED_FILES: ${{ steps.git-changed-files.outputs.CHANGED_FILES }}
- name: Add code suggestions
uses: reviewdog/action-suggester@3d7fde6859623ad6174df5fd662677a0eb63310a # v1.11.0
with:
tool_name: clang-format
fail_on_error: true
cleanup: false
- name: Explain that more files need to be fixed
if: ${{ steps.verify-changed-files.outputs.files_changed == 'true' }}
run: |
{
echo ''
echo 'Suggestions can only be added near to lines changed in this PR.'
echo 'All these fixed files are included in the artifact. The artifact can be downloaded and copied to the the repository to replace unformatted files with the formatted files.'
} >> "$GITHUB_STEP_SUMMARY"
exit 1
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: always()
with:
name: formatted-clang-format
path: |
.clang-format
${{ steps.git-changed-files.outputs.CHANGED_FILES }}
Loading