Skip to content

Commit 8275240

Browse files
committed
Update the uncrustify formatting action to use fd and smaller test cases
1 parent 1a16cea commit 8275240

File tree

20 files changed

+1402
-15815
lines changed

20 files changed

+1402
-15815
lines changed

.github/workflows/formattingTests.yml

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
name: Formatting Tests
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: [main,v2]
8+
workflow_dispatch:
9+
10+
env:
11+
# The bash escape character is \033
12+
bashPass: \033[32;1mPASSED -
13+
bashInfo: \033[33;1mINFO -
14+
bashFail: \033[31;1mFAILED -
15+
bashEnd: \033[0m
16+
17+
jobs:
18+
uncrustify-formatting-success-cases:
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- env:
24+
stepName: "Functional | Success | Exclude All Error Dirs"
25+
name: ${{ env.stepName }}
26+
id: exclude-dirs-with-errors
27+
uses: ./formatting
28+
with:
29+
path: formatting
30+
exclude-dirs: "filesWithFormattingErrors,filesWithCRLFEndings,filesWithTrailingWhitespace"
31+
exclude-files: "badFile.c"
32+
33+
- env:
34+
stepName: "Functional | Success | Exclude Files"
35+
name: ${{ env.stepName }}
36+
id: exclude-files-with-errors
37+
uses: ./formatting
38+
with:
39+
path: formatting
40+
exclude-dirs: ",,,"
41+
exclude-files: "badFile.c,cgc_error.h,crlf-file.c,test.c"
42+
43+
- env:
44+
stepName: "Functional | Success | Exclude File and Exclude Dirs"
45+
name: ${{ env.stepName }}
46+
id: exclude-single-dir-multiple-files
47+
uses: ./formatting
48+
with:
49+
path: formatting
50+
exclude-dirs: "goodFiles"
51+
exclude-files: "cgc_error.h,crlf-file.c,test.c"
52+
53+
- env:
54+
stepName: "Functional | Success | Exclude Files and Exclude Dirs"
55+
name: ${{ env.stepName }}
56+
id: exclude-two-files-two-dirs
57+
uses: ./formatting
58+
with:
59+
path: formatting
60+
exclude-dirs: "filesWithFormattingErrors,filesWithTrailingWhitespace"
61+
exclude-files: "test.c,cgc_error.h,crlf-file.c,badFile.c"
62+
63+
uncrustify-formatting-error-cases:
64+
runs-on: ubuntu-20.04
65+
steps:
66+
- uses: actions/checkout@v3
67+
- env:
68+
stepName: "Functional | Failure | Whitespace, CRLF, and Format Failure"
69+
name: ${{ env.stepName }}
70+
id: all-format-errors
71+
continue-on-error: true
72+
uses: ./formatting
73+
with:
74+
path: formatting
75+
76+
- env:
77+
stepName: "Functional | Failure | CRLF and Formatting Error"
78+
name: ${{ env.stepName }}
79+
id: crlf-and-format-error
80+
continue-on-error: true
81+
uses: ./formatting
82+
with:
83+
path: formatting
84+
exclude-dirs: "filesWithTrailingWhitespace"
85+
86+
- env:
87+
stepName: "Functional | Failure | CRLF and Whitespace Error"
88+
name: ${{ env.stepName }}
89+
id: crlf-and-whitespace-error
90+
continue-on-error: true
91+
uses: ./formatting
92+
with:
93+
path: formatting
94+
exclude-dirs: "filesWithFormattingErrors"
95+
96+
- env:
97+
stepName: "Functional | Failure | CRLF Error"
98+
name: ${{ env.stepName }}
99+
id: crlf-error
100+
continue-on-error: true
101+
uses: ./formatting
102+
with:
103+
path: formatting
104+
exclude-dirs: "filesWithFormattingErrors,filesWithTrailingWhitespace"
105+
exclude-files: "badFile.c"
106+
107+
- env:
108+
stepName: "Functional | Failure | Formatting and Whitespace Error"
109+
name: ${{ env.stepName }}
110+
id: formatting-and-whitespace-error
111+
continue-on-error: true
112+
uses: ./formatting
113+
with:
114+
path: formatting
115+
exclude-dirs: "filesWithCRLFEndings"
116+
117+
- env:
118+
stepName: "Functional | Failure | Formatting Error"
119+
name: ${{ env.stepName }}
120+
id: formatting-error
121+
continue-on-error: true
122+
uses: ./formatting
123+
with:
124+
path: formatting
125+
exclude-dirs: "filesWithTrailingWhitespace,filesWithCRLFEndings"
126+
127+
- env:
128+
stepName: "Functional | Failure | Whitespace Error"
129+
name: ${{ env.stepName }}
130+
id: whitespace-error
131+
continue-on-error: true
132+
uses: ./formatting
133+
with:
134+
path: formatting
135+
exclude-dirs: "filesWithFormattingErrors,filesWithCRLFEndings"
136+
137+
- env:
138+
stepName: "API | Failure | Exclude Dirs Error"
139+
name: ${{ env.stepName }}
140+
id: error-in-exclude-dirs
141+
continue-on-error: true
142+
uses: ./formatting
143+
with:
144+
path: formatting
145+
exclude-dirs: "filesWithFormattingErrors, filesWithCRLFEndings"
146+
147+
- env:
148+
stepName: "API | Failure | Exclude Files Error"
149+
name: ${{ env.stepName }}
150+
id: error-in-exclude-files
151+
continue-on-error: true
152+
uses: ./formatting
153+
with:
154+
path: formatting
155+
exclude-files: "filesWithFormattingErrors, filesWithCRLFEndings"
156+
157+
- env:
158+
stepName: "API | Failure | Exclude Option Errors"
159+
name: ${{ env.stepName }}
160+
id: error-in-both
161+
continue-on-error: true
162+
uses: ./formatting
163+
with:
164+
path: formatting
165+
exclude-files: "filesWithFormattingErrors, filesWithCRLFEndings"
166+
exclude-dirs: "filesWithFormattingErrors,
167+
filesWithCRLFEndings"
168+
169+
- env:
170+
stepName: Check Failure Test Cases
171+
name: ${{ env.stepName }}
172+
id: check-failure-test-cases
173+
shell: bash
174+
run: |
175+
# ${{ env.stepName }}
176+
exitStatus=0
177+
if [ "${{ steps.all-format-errors.outcome}}" = "failure" ]; then
178+
echo -e "${{ env.bashPass }} Functional | Failure | Whitespace, CRLF, and Format Failure | Had Expected "failure" ${{ env.bashEnd }}"
179+
else
180+
echo -e "${{ env.bashFail }} Functional | Failure | Whitespace, CRLF, and Format Failure | Had Unexpected "success" ${{ env.bashEnd }}"
181+
exitStatus=1
182+
fi
183+
if [ "${{ steps.crlf-and-format-error.outcome}}" = "failure" ]; then
184+
echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Formatting Error | Had Expected "failure" ${{ env.bashEnd }}"
185+
else
186+
echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Formatting Error | Had Unexpected "success" ${{ env.bashEnd }}"
187+
exitStatus=1
188+
fi
189+
if [ "${{ steps.crlf-and-whitespace-error.outcome}}" = "failure" ]; then
190+
echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}"
191+
else
192+
echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}"
193+
exitStatus=1
194+
fi
195+
if [ "${{ steps.crlf-error.outcome}}" = "failure" ]; then
196+
echo -e "${{ env.bashPass }} Functional | Failure | CRLF Error | Had Expected "failure" ${{ env.bashEnd }}"
197+
else
198+
echo -e "${{ env.bashFail }} Functional | Failure | CRLF Error | Had Unexpected "success" ${{ env.bashEnd }}"
199+
exitStatus=1
200+
fi
201+
if [ "${{ steps.formatting-and-whitespace-error.outcome}}" = "failure" ]; then
202+
echo -e "${{ env.bashPass }} Functional | Failure | Formatting and Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}"
203+
else
204+
echo -e "${{ env.bashFail }} Functional | Failure | Formatting and Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}"
205+
exitStatus=1
206+
fi
207+
if [ "${{ steps.formatting-error.outcome}}" = "failure" ]; then
208+
echo -e "${{ env.bashPass }} Functional | Failure | Formatting Error | Had Expected "failure" ${{ env.bashEnd }}"
209+
else
210+
echo -e "${{ env.bashFail }} Functional | Failure | Formatting Error | Had Unexpected "success" ${{ env.bashEnd }}"
211+
exitStatus=1
212+
fi
213+
if [ "${{ steps.whitespace-error.outcome}}" = "failure" ]; then
214+
echo -e "${{ env.bashPass }} Functional | Failure | Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}"
215+
else
216+
echo -e "${{ env.bashFail }} Functional | Failure | Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}"
217+
exitStatus=1
218+
fi
219+
if [ "${{ steps.error-in-exclude-dirs.outcome}}" = "failure" ]; then
220+
echo -e "${{ env.bashPass }} API | Failure | Exclude Dirs Error | Had Expected "failure" ${{ env.bashEnd }}"
221+
else
222+
echo -e "${{ env.bashFail }} API | Failure | Exclude Dirs Error | Had Unexpected "success" ${{ env.bashEnd }}"
223+
exitStatus=1
224+
fi
225+
if [ "${{ steps.error-in-exclude-files.outcome}}" = "failure" ]; then
226+
echo -e "${{ env.bashPass }} API | Failure | Exclude Files Error | Had Expected "failure" ${{ env.bashEnd }}"
227+
else
228+
echo -e "${{ env.bashFail }} API | Failure | Exclude Files Error | Had Unexpected "success" ${{ env.bashEnd }}"
229+
exitStatus=1
230+
fi
231+
if [ "${{ steps.error-in-both.outcome}}" = "failure" ]; then
232+
echo -e "${{ env.bashPass }} API | Failure | Exclude Option Errors | Had Expected "failure" ${{ env.bashEnd }}"
233+
else
234+
echo -e "${{ env.bashFail }} API | Failure | Exclude Option Errors | Had Unexpected "success" ${{ env.bashEnd }}"
235+
exitStatus=1
236+
fi
237+
exit $exitStatus

0 commit comments

Comments
 (0)