-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This merge forces contributors to use the same version of clang-format as our CI. This is done by installing pre-commit (which can be done easily through pip/pipx). pre-commit allows us to fix the used version of clang-format, so that contributors will use exactly the same version as our CI. If pre-commit can't be detected during cmake an error is thrown. Otherwise, the pre-commit hooks are installed. Since this replaces our git-cmake-format, that dependency was removed. Additional changes: - change not supported values in .clang-format - run pre-commit checks over all files Related PR: #1461
- Loading branch information
Showing
29 changed files
with
311 additions
and
335 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
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,24 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
source .github/bot-pr-base.sh | ||
cp .github/bot-pr-base.sh /tmp | ||
source /tmp/bot-pr-base.sh | ||
|
||
echo "Retrieving PR file list" | ||
PR_FILES=$(bot_get_all_changed_files ${PR_URL}) | ||
NUM=$(echo "${PR_FILES}" | wc -l) | ||
echo "PR has ${NUM} changed files" | ||
|
||
TO_FORMAT="$(echo "$PR_FILES" | grep -E $EXTENSION_REGEX || true)" | ||
echo "Set-up working tree" | ||
|
||
git remote add fork "$HEAD_URL" | ||
git fetch fork "$HEAD_BRANCH" | ||
git fetch origin "$BASE_BRANCH" | ||
|
||
# checkout current PR head | ||
LOCAL_BRANCH=format-tmp-$HEAD_BRANCH | ||
git checkout -b $LOCAL_BRANCH fork/$HEAD_BRANCH | ||
|
||
git config user.email "[email protected]" | ||
git config user.name "ginkgo-bot" | ||
|
||
# save scripts from develop | ||
pushd dev_tools/scripts | ||
pushd dev_tools/scripts || exit 1 | ||
cp add_license.sh format_header.sh update_ginkgo_header.sh /tmp | ||
popd | ||
popd || exit 1 | ||
|
||
# checkout current PR head | ||
LOCAL_BRANCH=format-tmp-$HEAD_BRANCH | ||
|
@@ -28,12 +29,3 @@ git checkout -b $LOCAL_BRANCH fork/$HEAD_BRANCH | |
cp /tmp/add_license.sh dev_tools/scripts/ | ||
cp /tmp/format_header.sh dev_tools/scripts/ | ||
cp /tmp/update_ginkgo_header.sh dev_tools/scripts/ | ||
|
||
# format files | ||
dev_tools/scripts/add_license.sh | ||
dev_tools/scripts/update_ginkgo_header.sh | ||
for f in $(echo "$TO_FORMAT" | grep -E $FORMAT_HEADER_REGEX); do dev_tools/scripts/format_header.sh "$f"; done | ||
for f in $(echo "$TO_FORMAT" | grep -E $FORMAT_REGEX); do "$CLANG_FORMAT" -i -style=file "$f"; done | ||
|
||
# restore formatting scripts so they don't appear in the diff | ||
git checkout -- dev_tools/scripts/*.sh |
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
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
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
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,21 @@ | ||
name: Check formatting | ||
on: workflow_call | ||
|
||
jobs: | ||
pre-commit: | ||
name: Run pre-commit hooks | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout the latest code (shallow clone) | ||
uses: actions/checkout@v4 | ||
- name: Run Pre-Commit checks | ||
run: cp .github/check-format.sh /tmp && /tmp/check-format.sh | ||
id: pre-commit | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Upload code formatting patch | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: patch | ||
path: format.patch |
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
Oops, something went wrong.