diff --git a/.github/generate_cppcheck_report.py b/.github/generate_cppcheck_report.py new file mode 100755 index 000000000..6ce970a53 --- /dev/null +++ b/.github/generate_cppcheck_report.py @@ -0,0 +1,43 @@ +import sys + +UPDATED_FILES = sys.argv[1:] +TABLE_HEADER = """| Filename | Line | Type | Description | +| -------- | ---- | ---- | ----------- |""" + +with open("cppcheck.txt") as f: + content = f.readlines() + +updated = [] +anything_else = [] + +for line in content: + filename, row, kind, desc = line.split(":", 3) + formatted = f"| {filename} | {row} | {kind.strip()} | {desc.strip()} |" + + if filename == "nofile": + continue + + if filename in UPDATED_FILES: + updated.append(formatted) + else: + anything_else.append(formatted) + + +def make_output(data): + if data: + output = TABLE_HEADER + "\n" + output += "\n".join(data) + return output + return "" + + +print(f"""### CppCheck report + +{make_output(updated)} + +
+Report files about files you didn't modify in this PR + +{make_output(anything_else)} +
+""") diff --git a/.github/launch-lizard.py b/.github/launch-lizard.py index 39541eb68..2a07fd17b 100644 --- a/.github/launch-lizard.py +++ b/.github/launch-lizard.py @@ -32,22 +32,22 @@ def make_sorted_table_lines(lines_with_ccn): - output = "" - for line in sorted(lines_with_ccn, key=lambda e: e[1], reverse=True): - output += f"| {line[0]} | {line[1]} |\n" - return output + if lines_with_ccn: + output = TABLE_HEADERS + "\n" + for line in sorted(lines_with_ccn, key=lambda e: e[1], reverse=True): + output += f"| {line[0]} | {line[1]} |\n" + return output + return "" print(f"""### Lizard report Listing only functions with cyclomatic complexity >= {MAX_CCN} or NLOC >= {MAX_NLOC} or parameters >= {MAX_PARAM}. -{TABLE_HEADERS} {make_sorted_table_lines(updated)}
Report about files you didn't modify in this PR -{TABLE_HEADERS} {make_sorted_table_lines(anything_else)}
""") diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4758aeb8d..a5267b2cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -242,9 +242,31 @@ jobs: -- ${BUILD_FOLDER}/arkscript @@ -L ./lib - name: Summarize + id: summary + shell: bash run: | - afl-whatsup -s -d output - afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib + echo "FUZZ_SUMMARY<> $GITHUB_ENV + afl-whatsup -s -d output >> $GITHUB_ENV + afl-showmap -C -i output -o /dev/null -- ./${BUILD_FOLDER}/arkscript @@ -L ./lib | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g" | grep -v Reading | grep -v Scanning >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + - name: Find Comment + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: Fuzzing report + + - name: Create or update comment + uses: peter-evans/create-or-update-comment@v4 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ## Fuzzing report + ${{ env.FUZZ_SUMMARY }} + edit-mode: replace - name: Sort files for upload continue-on-error: true diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 451e45862..8982aae37 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -37,11 +37,9 @@ jobs: -I include src \ --enable=all --inline-suppr \ --suppressions-list=cppcheck-suppressions.txt - cat cppcheck.txt | sort > cppcheck_sorted.txt + content=$(python .github/generate_cppcheck_report.py $(echo $(git diff --name-only -r HEAD^1 HEAD))) echo "CPPCHECK_REPORT<> $GITHUB_ENV - echo "| Filename | Line | Type | Description |" >> $GITHUB_ENV - echo "| -------- | ---- | ---- | ----------- |" >> $GITHUB_ENV - cat cppcheck_sorted.txt | awk -F ":" '{type=$3;out=""; for (i = 4; i <= NF; i++) {out = out " " $i}; print $1 " | " $2 " |" type " |" out}' >> $GITHUB_ENV + echo "$content" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV - name: Find Comment @@ -63,6 +61,5 @@ jobs: --- - ### CppCheck report ${{ env.CPPCHECK_REPORT }} edit-mode: replace diff --git a/.gitignore b/.gitignore index 4098020cc..230fb530a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ # Personal utilities warnings.log +cppcheck.txt # ArkScript __arkscript__/