-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI/CD: Script that creates a pull request to run clang-format on our …
…codebase
- Loading branch information
1 parent
7088bf7
commit e62968a
Showing
4 changed files
with
40 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
name: clang-format | ||
|
||
on: [pull_request] | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
cpp-formatting-check: | ||
clang-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- name: Run clang-format | ||
run: | | ||
clang-format --Werror --dry-run $(find . -name '*.cpp' -or -name '*.h') | ||
clang-format --Werror --dry-run *.cpp *.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: clang-format pull request | ||
|
||
on: | ||
[workflow_dispatch] | ||
|
||
jobs: | ||
clang-format: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Create pull request | ||
run: | | ||
rand_char=$(openssl rand -hex 3) | ||
git checkout -b clang-format-$rand_char | ||
clang-format -i *.cpp *.h | ||
git add --all | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
git commit -m "Format: Run clang-format on main branch" | ||
git push -u origin clang-format-$rand_char | ||
gh pr create -B main -H clang-format-$rand_char --title 'Format: Run clang-format on main branch' --body "This pull request fixes formatting issues in the codebase using .clang-format configuration file. Created by Github Actions" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters