|
| 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 Files and Dirs" |
| 25 | + name: ${{ env.stepName }} |
| 26 | + id: exclude-dirs-with-errors |
| 27 | + uses: ./formatting |
| 28 | + with: |
| 29 | + path: formatting/goodFiles |
| 30 | + exclude-dirs: "fileWithErrorInclude, fileWithErrorSource" |
| 31 | + exclude-files: "formatErrorTest.h, formatErrorTest.c" |
| 32 | + |
| 33 | + - env: |
| 34 | + stepName: "Functional | Success | Exclude Just Files" |
| 35 | + name: ${{ env.stepName }} |
| 36 | + id: exclude-files-with-errors |
| 37 | + uses: ./formatting |
| 38 | + with: |
| 39 | + path: formatting/goodFiles |
| 40 | + exclude-dirs: ",,," |
| 41 | + exclude-files: "errorFileInDirectory.h, formatErrorTest.h, errorFileInDirectory.c, formatErrorTest.c" |
| 42 | + |
| 43 | + - name: Remove Error Files at Top Directory |
| 44 | + working-directory: formatting/goodFiles |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + # Remove Error Files at Top Directory |
| 48 | + # Do a git remove since we use a git diff to check if formatting fails |
| 49 | + git rm $(find . -name "formatErrorTest.c") |
| 50 | + git rm $(find . -name "formatErrorTest.h") |
| 51 | +
|
| 52 | + - env: |
| 53 | + stepName: "Functional | Success | Exclude Just Error Dirs" |
| 54 | + name: ${{ env.stepName }} |
| 55 | + id: exclude-two-files-two-dirs |
| 56 | + uses: ./formatting |
| 57 | + with: |
| 58 | + path: formatting/goodFiles |
| 59 | + exclude-dirs: "fileWithErrorInclude, fileWithErrorSource" |
| 60 | + |
| 61 | + formatting-error-cases: |
| 62 | + runs-on: ubuntu-20.04 |
| 63 | + steps: |
| 64 | + - uses: actions/checkout@v3 |
| 65 | + - env: |
| 66 | + stepName: "Functional | Failure | Whitespace, CRLF, and Format Failure" |
| 67 | + name: ${{ env.stepName }} |
| 68 | + id: all-format-errors |
| 69 | + continue-on-error: true |
| 70 | + uses: ./formatting |
| 71 | + with: |
| 72 | + path: formatting |
| 73 | + |
| 74 | + - name: Reset Files |
| 75 | + shell: bash |
| 76 | + run: git reset --hard |
| 77 | + |
| 78 | + - env: |
| 79 | + stepName: "Functional | Failure | CRLF and Formatting Error" |
| 80 | + name: ${{ env.stepName }} |
| 81 | + id: crlf-and-format-error |
| 82 | + continue-on-error: true |
| 83 | + uses: ./formatting |
| 84 | + with: |
| 85 | + path: formatting |
| 86 | + exclude-dirs: "filesWithTrailingWhitespace" |
| 87 | + |
| 88 | + - name: Reset Files |
| 89 | + shell: bash |
| 90 | + run: git reset --hard |
| 91 | + |
| 92 | + - env: |
| 93 | + stepName: "Functional | Failure | CRLF and Whitespace Error" |
| 94 | + name: ${{ env.stepName }} |
| 95 | + id: crlf-and-whitespace-error |
| 96 | + continue-on-error: true |
| 97 | + uses: ./formatting |
| 98 | + with: |
| 99 | + path: formatting |
| 100 | + exclude-dirs: "filesWithFormattingErrors" |
| 101 | + |
| 102 | + - name: Reset Files |
| 103 | + shell: bash |
| 104 | + run: git reset --hard |
| 105 | + |
| 106 | + - env: |
| 107 | + stepName: "Functional | Failure | CRLF and Whitespace Error Not C Files" |
| 108 | + name: ${{ env.stepName }} |
| 109 | + id: crlf-and-whitespace-non-c-error |
| 110 | + continue-on-error: true |
| 111 | + uses: ./formatting |
| 112 | + with: |
| 113 | + path: formatting |
| 114 | + exclude-dirs: "filesWithFormattingErrors, fileWithErrorInclude, fileWithErrorSource" |
| 115 | + |
| 116 | + - name: Reset Files |
| 117 | + shell: bash |
| 118 | + run: git reset --hard |
| 119 | + |
| 120 | + - env: |
| 121 | + stepName: "Functional | Failure | CRLF Error" |
| 122 | + name: ${{ env.stepName }} |
| 123 | + id: crlf-error |
| 124 | + continue-on-error: true |
| 125 | + uses: ./formatting |
| 126 | + with: |
| 127 | + path: formatting |
| 128 | + exclude-dirs: "filesWithFormattingErrors,filesWithTrailingWhitespace" |
| 129 | + exclude-files: "badFile.c" |
| 130 | + |
| 131 | + - name: Reset Files |
| 132 | + shell: bash |
| 133 | + run: git reset --hard |
| 134 | + |
| 135 | + - env: |
| 136 | + stepName: "Functional | Failure | Formatting and Whitespace Error" |
| 137 | + name: ${{ env.stepName }} |
| 138 | + id: formatting-and-whitespace-error |
| 139 | + continue-on-error: true |
| 140 | + uses: ./formatting |
| 141 | + with: |
| 142 | + path: formatting |
| 143 | + exclude-dirs: "filesWithCRLFEndings" |
| 144 | + |
| 145 | + - name: Reset Files |
| 146 | + shell: bash |
| 147 | + run: git reset --hard |
| 148 | + |
| 149 | + - env: |
| 150 | + stepName: "Functional | Failure | Formatting Error" |
| 151 | + name: ${{ env.stepName }} |
| 152 | + id: formatting-error |
| 153 | + continue-on-error: true |
| 154 | + uses: ./formatting |
| 155 | + with: |
| 156 | + path: formatting |
| 157 | + exclude-dirs: "filesWithTrailingWhitespace,filesWithCRLFEndings" |
| 158 | + |
| 159 | + - name: Reset Files |
| 160 | + shell: bash |
| 161 | + run: git reset --hard |
| 162 | + |
| 163 | + - env: |
| 164 | + stepName: "Functional | Failure | Whitespace Error" |
| 165 | + name: ${{ env.stepName }} |
| 166 | + id: whitespace-error |
| 167 | + continue-on-error: true |
| 168 | + uses: ./formatting |
| 169 | + with: |
| 170 | + path: formatting |
| 171 | + exclude-dirs: "filesWithFormattingErrors,filesWithCRLFEndings" |
| 172 | + |
| 173 | + - name: Reset Files |
| 174 | + shell: bash |
| 175 | + run: git reset --hard |
| 176 | + |
| 177 | + - env: |
| 178 | + stepName: "API | Failure | Exclude Dirs Error" |
| 179 | + name: ${{ env.stepName }} |
| 180 | + id: error-in-exclude-dirs |
| 181 | + continue-on-error: true |
| 182 | + uses: ./formatting |
| 183 | + with: |
| 184 | + path: formatting |
| 185 | + exclude-dirs: "filesWithFormattingErrors, filesWithCRLFEndings" |
| 186 | + |
| 187 | + - name: Reset Files |
| 188 | + shell: bash |
| 189 | + run: git reset --hard |
| 190 | + |
| 191 | + - env: |
| 192 | + stepName: "API | Failure | Exclude Files Error" |
| 193 | + name: ${{ env.stepName }} |
| 194 | + id: error-in-exclude-files |
| 195 | + continue-on-error: true |
| 196 | + uses: ./formatting |
| 197 | + with: |
| 198 | + path: formatting |
| 199 | + exclude-files: "filesWithFormattingErrors, filesWithCRLFEndings" |
| 200 | + |
| 201 | + - name: Reset Files |
| 202 | + shell: bash |
| 203 | + run: git reset --hard |
| 204 | + |
| 205 | + - env: |
| 206 | + stepName: "API | Failure | Exclude Option Errors" |
| 207 | + name: ${{ env.stepName }} |
| 208 | + id: error-in-both |
| 209 | + continue-on-error: true |
| 210 | + uses: ./formatting |
| 211 | + with: |
| 212 | + path: formatting |
| 213 | + exclude-files: "filesWithFormattingErrors, filesWithCRLFEndings" |
| 214 | + exclude-dirs: "filesWithFormattingErrors, |
| 215 | + filesWithCRLFEndings" |
| 216 | + |
| 217 | + - name: Reset Files |
| 218 | + shell: bash |
| 219 | + run: git reset --hard |
| 220 | + |
| 221 | + - env: |
| 222 | + stepName: Check Failure Test Cases |
| 223 | + name: ${{ env.stepName }} |
| 224 | + id: check-failure-test-cases |
| 225 | + shell: bash |
| 226 | + run: | |
| 227 | + # ${{ env.stepName }} |
| 228 | + exitStatus=0 |
| 229 | + if [ "${{ steps.all-format-errors.outcome}}" = "failure" ]; then |
| 230 | + echo -e "${{ env.bashPass }} Functional | Failure | Whitespace, CRLF, and Format Failure | Had Expected "failure" ${{ env.bashEnd }}" |
| 231 | + else |
| 232 | + echo -e "${{ env.bashFail }} Functional | Failure | Whitespace, CRLF, and Format Failure | Had Unexpected "success" ${{ env.bashEnd }}" |
| 233 | + exitStatus=1 |
| 234 | + fi |
| 235 | + if [ "${{ steps.crlf-and-format-error.outcome}}" = "failure" ]; then |
| 236 | + echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Formatting Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 237 | + else |
| 238 | + echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Formatting Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 239 | + exitStatus=1 |
| 240 | + fi |
| 241 | + if [ "${{ steps.crlf-and-whitespace-error.outcome}}" = "failure" ]; then |
| 242 | + echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 243 | + else |
| 244 | + echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 245 | + exitStatus=1 |
| 246 | + fi |
| 247 | + if [ "${{ steps.crlf-and-whitespace-non-c-error.outcome}}" = "failure" ]; then |
| 248 | + echo -e "${{ env.bashPass }} Functional | Failure | CRLF and Whitespace Error Not C Files | Had Expected "failure" ${{ env.bashEnd }}" |
| 249 | + else |
| 250 | + echo -e "${{ env.bashFail }} Functional | Failure | CRLF and Whitespace Error Not C Files | Had Unexpected "success" ${{ env.bashEnd }}" |
| 251 | + exitStatus=1 |
| 252 | + fi |
| 253 | + if [ "${{ steps.crlf-error.outcome}}" = "failure" ]; then |
| 254 | + echo -e "${{ env.bashPass }} Functional | Failure | CRLF Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 255 | + else |
| 256 | + echo -e "${{ env.bashFail }} Functional | Failure | CRLF Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 257 | + exitStatus=1 |
| 258 | + fi |
| 259 | + if [ "${{ steps.formatting-and-whitespace-error.outcome}}" = "failure" ]; then |
| 260 | + echo -e "${{ env.bashPass }} Functional | Failure | Formatting and Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 261 | + else |
| 262 | + echo -e "${{ env.bashFail }} Functional | Failure | Formatting and Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 263 | + exitStatus=1 |
| 264 | + fi |
| 265 | + if [ "${{ steps.formatting-error.outcome}}" = "failure" ]; then |
| 266 | + echo -e "${{ env.bashPass }} Functional | Failure | Formatting Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 267 | + else |
| 268 | + echo -e "${{ env.bashFail }} Functional | Failure | Formatting Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 269 | + exitStatus=1 |
| 270 | + fi |
| 271 | + if [ "${{ steps.whitespace-error.outcome}}" = "failure" ]; then |
| 272 | + echo -e "${{ env.bashPass }} Functional | Failure | Whitespace Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 273 | + else |
| 274 | + echo -e "${{ env.bashFail }} Functional | Failure | Whitespace Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 275 | + exitStatus=1 |
| 276 | + fi |
| 277 | + if [ "${{ steps.error-in-exclude-dirs.outcome}}" = "failure" ]; then |
| 278 | + echo -e "${{ env.bashPass }} API | Failure | Exclude Dirs Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 279 | + else |
| 280 | + echo -e "${{ env.bashFail }} API | Failure | Exclude Dirs Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 281 | + exitStatus=1 |
| 282 | + fi |
| 283 | + if [ "${{ steps.error-in-exclude-files.outcome}}" = "failure" ]; then |
| 284 | + echo -e "${{ env.bashPass }} API | Failure | Exclude Files Error | Had Expected "failure" ${{ env.bashEnd }}" |
| 285 | + else |
| 286 | + echo -e "${{ env.bashFail }} API | Failure | Exclude Files Error | Had Unexpected "success" ${{ env.bashEnd }}" |
| 287 | + exitStatus=1 |
| 288 | + fi |
| 289 | + if [ "${{ steps.error-in-both.outcome}}" = "failure" ]; then |
| 290 | + echo -e "${{ env.bashPass }} API | Failure | Exclude Option Errors | Had Expected "failure" ${{ env.bashEnd }}" |
| 291 | + else |
| 292 | + echo -e "${{ env.bashFail }} API | Failure | Exclude Option Errors | Had Unexpected "success" ${{ env.bashEnd }}" |
| 293 | + exitStatus=1 |
| 294 | + fi |
| 295 | + exit $exitStatus |
0 commit comments