@@ -369,40 +369,42 @@ jobs:
369
369
# Define the path to cppcheck configuration file for linting benchmarks:
370
370
cppcheck_benchmarks_suppressions_list="${root}/etc/cppcheck/suppressions.benchmarks.txt"
371
371
372
- # Initialize a variable to capture errors:
373
- err_output=""
372
+ # Define output files for each category:
373
+ out_source="lint_c_errors_source.txt"
374
+ out_examples="lint_c_errors_examples.txt"
375
+ out_tests="lint_c_errors_tests.txt"
376
+ out_benchmarks="lint_c_errors_benchmarks.txt"
377
+ combined="lint_c_errors.txt"
374
378
375
379
# Lint C source files:
376
380
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep -E '\.c$' | grep -v -e '/examples' -e '/test' -e '/benchmark' | tr '\n' ' ')
377
381
if [[ -n "${files}" ]]; then
378
- err_output+=$( make lint-c-files FILES="${files}" 2>&1)
382
+ make lint-c-files FILES="${files}" CPPCHECK_FLAGS="--output-file=${out_source}"
379
383
fi
380
384
381
385
# Lint C example files...
382
386
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep '/examples/.*\.c$' | tr '\n' ' ')
383
387
if [[ -n "${files}" ]]; then
384
- err_output+=$( make lint-c-files FILES="${files}" CPPCHECK_SUPPRESSIONS_LIST="${cppcheck_examples_suppressions_list}" 2>&1)
388
+ make lint-c-files FILES="${files}" CPPCHECK_FLAGS="--output-file=${out_examples}" CPPCHECK_SUPPRESSIONS_LIST="${cppcheck_examples_suppressions_list}"
385
389
fi
386
390
387
391
# Lint C test fixtures files...
388
392
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep '/test/fixtures/.*\.c$' | tr '\n' ' ')
389
393
if [[ -n "${files}" ]]; then
390
- err_output+=$( make lint-c-files FILES="${files}" CPPCHECK_SUPPRESSIONS_LIST="${cppcheck_tests_fixtures_suppressions_list}" 2>&1)
394
+ make lint-c-files FILES="${files}" CPPCHECK_FLAGS="--output-file=${out_tests}" CPPCHECK_SUPPRESSIONS_LIST="${cppcheck_tests_fixtures_suppressions_list}"
391
395
fi
392
396
393
397
# Lint C benchmark files...
394
398
files=$(echo "${{ steps.random-files.outputs.files }}" | tr ',' '\n' | grep '/benchmark/.*\.c$' | tr '\n' ' ')
395
399
if [[ -n "${files}" ]]; then
396
- err_output+=$( make lint-c-files FILES="${files}" CPPCHECK_SUPPRESSIONS_LIST="${cppcheck_benchmarks_suppressions_list}" 2>&1)
400
+ make lint-c-files FILES="${files}" CPPCHECK_FLAGS="--output-file=${out_benchmarks}" CPPCHECK_SUPPRESSIONS_LIST="${cppcheck_benchmarks_suppressions_list}"
397
401
fi
398
402
399
- # Print the errors to the log :
400
- echo "$err_output "
403
+ # Combine all outputs into one file :
404
+ cat "$out_source" "$out_examples" "$out_tests" "$out_benchmarks" > "$combined "
401
405
402
- # Save the captured errors as an output variable...
403
- echo "stderr<<EOF" >> $GITHUB_OUTPUT
404
- echo "$err_output" >> $GITHUB_OUTPUT
405
- echo "EOF" >> $GITHUB_OUTPUT
406
+ # Print the combined errors to the log:
407
+ cat "$combined"
406
408
407
409
# Create sub-issue for C linting failures:
408
410
- name : ' Create sub-issue for C lint failures'
@@ -426,7 +428,7 @@ jobs:
426
428
### Error Details
427
429
428
430
\`\`\`
429
- $(grep -B 1 -A 2 "style:\|warning:\|error:" <<< "${{ steps.lint-c.outputs.stderr }} ")
431
+ $(grep -B 1 -A 2 "style:\|warning:\|error:" "lint_c_errors.txt ")
430
432
\`\`\`
431
433
EOF
432
434
0 commit comments