-
Notifications
You must be signed in to change notification settings - Fork 35
Updates to Uncrustify Formatting #76
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ffcdf33
Updates to Uncrustify Formatting
Skptak c24a3c3
Merge branch 'main' into uncrustifyFormatting
Skptak 1a16cea
Merge branch 'main' into uncrustifyFormatting
Skptak 44112c3
Update the uncrustify formatting action to use fd and smaller test ca…
ab45ced
Merge branch 'main' into uncrustifyFormatting
Skptak dda3142
Merge branch 'main' into uncrustifyFormatting
Skptak 9fd21d0
Don't remove trailing whitespace for patches, lib, or archive files. …
Skptak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,2 @@ | ||
formatting/filesWithCRLFEndings/* eol=crlf | ||
clang-formatting/filesWithFormattingErrors/* eol=crlf |
This file contains hidden or 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,295 @@ | ||
name: Formatting Tests | ||
|
||
on: | ||
push: | ||
branches: ["**"] | ||
pull_request: | ||
branches: [main,v2] | ||
workflow_dispatch: | ||
|
||
env: | ||
# The bash escape character is \033 | ||
bashPass: \033[32;1mPASSED - | ||
bashInfo: \033[33;1mINFO - | ||
bashFail: \033[31;1mFAILED - | ||
bashEnd: \033[0m | ||
|
||
jobs: | ||
uncrustify-formatting-success-cases: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- env: | ||
stepName: "Functional | Success | Exclude Files and Dirs" | ||
name: ${{ env.stepName }} | ||
id: exclude-dirs-with-errors | ||
uses: ./formatting | ||
with: | ||
path: formatting/goodFiles | ||
exclude-dirs: "fileWithErrorInclude, fileWithErrorSource" | ||
exclude-files: "formatErrorTest.h, formatErrorTest.c" | ||
|
||
- env: | ||
stepName: "Functional | Success | Exclude Just Files" | ||
name: ${{ env.stepName }} | ||
id: exclude-files-with-errors | ||
uses: ./formatting | ||
with: | ||
path: formatting/goodFiles | ||
exclude-dirs: ",,," | ||
exclude-files: "errorFileInDirectory.h, formatErrorTest.h, errorFileInDirectory.c, formatErrorTest.c" | ||
|
||
- name: Remove Error Files at Top Directory | ||
working-directory: formatting/goodFiles | ||
shell: bash | ||
run: | | ||
# Remove Error Files at Top Directory | ||
# Do a git remove since we use a git diff to check if formatting fails | ||
git rm $(find . -name "formatErrorTest.c") | ||
git rm $(find . -name "formatErrorTest.h") | ||
|
||
- env: | ||
stepName: "Functional | Success | Exclude Just Error Dirs" | ||
name: ${{ env.stepName }} | ||
id: exclude-two-files-two-dirs | ||
uses: ./formatting | ||
with: | ||
path: formatting/goodFiles | ||
exclude-dirs: "fileWithErrorInclude, fileWithErrorSource" | ||
|
||
formatting-error-cases: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- env: | ||
stepName: "Functional | Failure | Whitespace, CRLF, and Format Failure" | ||
name: ${{ env.stepName }} | ||
id: all-format-errors | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "Functional | Failure | CRLF and Formatting Error" | ||
name: ${{ env.stepName }} | ||
id: crlf-and-format-error | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithTrailingWhitespace" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "Functional | Failure | CRLF and Whitespace Error" | ||
name: ${{ env.stepName }} | ||
id: crlf-and-whitespace-error | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithFormattingErrors" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "Functional | Failure | CRLF and Whitespace Error Not C Files" | ||
name: ${{ env.stepName }} | ||
id: crlf-and-whitespace-non-c-error | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithFormattingErrors, fileWithErrorInclude, fileWithErrorSource" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "Functional | Failure | CRLF Error" | ||
name: ${{ env.stepName }} | ||
id: crlf-error | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithFormattingErrors,filesWithTrailingWhitespace" | ||
exclude-files: "badFile.c" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "Functional | Failure | Formatting and Whitespace Error" | ||
name: ${{ env.stepName }} | ||
id: formatting-and-whitespace-error | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithCRLFEndings" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "Functional | Failure | Formatting Error" | ||
name: ${{ env.stepName }} | ||
id: formatting-error | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithTrailingWhitespace,filesWithCRLFEndings" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "Functional | Failure | Whitespace Error" | ||
name: ${{ env.stepName }} | ||
id: whitespace-error | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithFormattingErrors,filesWithCRLFEndings" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "API | Failure | Exclude Dirs Error" | ||
name: ${{ env.stepName }} | ||
id: error-in-exclude-dirs | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-dirs: "filesWithFormattingErrors, filesWithCRLFEndings" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "API | Failure | Exclude Files Error" | ||
name: ${{ env.stepName }} | ||
id: error-in-exclude-files | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-files: "filesWithFormattingErrors, filesWithCRLFEndings" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: "API | Failure | Exclude Option Errors" | ||
name: ${{ env.stepName }} | ||
id: error-in-both | ||
continue-on-error: true | ||
uses: ./formatting | ||
with: | ||
path: formatting | ||
exclude-files: "filesWithFormattingErrors, filesWithCRLFEndings" | ||
exclude-dirs: "filesWithFormattingErrors, | ||
filesWithCRLFEndings" | ||
|
||
- name: Reset Files | ||
shell: bash | ||
run: git reset --hard | ||
|
||
- env: | ||
stepName: Check Failure Test Cases | ||
name: ${{ env.stepName }} | ||
id: check-failure-test-cases | ||
shell: bash | ||
run: | | ||
# ${{ env.stepName }} | ||
exitStatus=0 | ||
if [ "${{ steps.all-format-errors.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | Whitespace, CRLF, and Format Failure | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | Whitespace, CRLF, and Format Failure | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.crlf-and-format-error.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Formatting Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Formatting Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.crlf-and-whitespace-error.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.crlf-and-whitespace-non-c-error.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Whitespace Error Not C Files | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Whitespace Error Not C Files | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.crlf-error.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | CRLF Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | CRLF Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.formatting-and-whitespace-error.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | Formatting and Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | Formatting and Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.formatting-error.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | Formatting Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | Formatting Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.whitespace-error.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} Functional | Failure | Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} Functional | Failure | Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.error-in-exclude-dirs.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} API | Failure | Exclude Dirs Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} API | Failure | Exclude Dirs Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.error-in-exclude-files.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} API | Failure | Exclude Files Error | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} API | Failure | Exclude Files Error | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
if [ "${{ steps.error-in-both.outcome}}" = "failure" ]; then | ||
echo -e "${{ env.bashPass }} API | Failure | Exclude Option Errors | Had Expected "failure" ${{ env.bashEnd }}" | ||
else | ||
echo -e "${{ env.bashFail }} API | Failure | Exclude Option Errors | Had Unexpected "success" ${{ env.bashEnd }}" | ||
exitStatus=1 | ||
fi | ||
exit $exitStatus |
This file contains hidden or 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 hidden or 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,29 @@ | ||
# Uncrustify Format GitHub Action | ||
## Purpose | ||
This directory contains an [action.yml](action.yml) file to uncrustify code | ||
files inside of [FreeRTOS](https://github.com/FreeRTOS/) repositories. It | ||
additionally will check for files with trailing whitespace, and CRLF line | ||
endings. | ||
|
||
If a file is found that contains incorrect formatting, trailing whitespace, or | ||
CRLF endings, this action will create a Git Patch that will be added to the | ||
summary of the workflow run that uses this action. This allows an end user to | ||
download the patch, apply it, and then pass the formatting checks. | ||
|
||
A patch is provided, instead of automatically applying the updates, as | ||
automatically formatting files could lead to merge conflicts. If an end-user | ||
didn't know they need to perform a `git pull` as their origin would have the | ||
formatting change applied. | ||
|
||
## Testing Files | ||
This directory contains many files that are used to test the action. | ||
These tests can be found inside of | ||
[formattingTests.yml](../.github/workflows/formattingTests.yml). | ||
The files have been named in such a way to explain what their purpose is. | ||
The general idea is that there are a mix of files, some with CRLF endings, | ||
some with uncrustify errors, and some with trailing whitespace. Where the | ||
inside of | ||
[formattingTests.yml](../.github/workflows/formattingTests.yml) | ||
these various files are checked to ensure this action properly fails when | ||
a formatting issue is discovered. Additional tests are here to ensure that | ||
the various input parameters to the action work as intended. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this branch always exist?