From c9f5ab709dbf97ed1ae4360c814b260d0a74a951 Mon Sep 17 00:00:00 2001 From: ffrancis Date: Tue, 4 Nov 2025 11:23:36 +0530 Subject: [PATCH 1/3] Kernel_checker Test run for kernel checker Signed-off-by: ffrancis --- .github/workflows/checkpatch.yml | 108 +++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/checkpatch.yml diff --git a/.github/workflows/checkpatch.yml b/.github/workflows/checkpatch.yml new file mode 100644 index 0000000..68bc025 --- /dev/null +++ b/.github/workflows/checkpatch.yml @@ -0,0 +1,108 @@ +name: Kernel Checkpatch + +on: + pull_request: + types: [opened, synchronize, reopened] + workflow_dispatch: + +jobs: + checkpatch: + runs-on: ubuntu-latest + steps: + - name: Checkout (full history for format-patch) + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install Perl + run: sudo apt-get update && sudo apt-get install -y perl + + # If your repo has scripts/checkpatch.pl, we use it; else download a stable version from upstream. + - name: Resolve checkpatch.pl + id: resolve + shell: bash + run: | + set -e + if [[ -x scripts/checkpatch.pl ]]; then + echo "checkpatch=scripts/checkpatch.pl" >> "$GITHUB_OUTPUT" + else + curl -L --fail -o checkpatch.pl https://raw.githubusercontent.com/torvalds/linux/v6.6/scripts/checkpatch.pl + chmod +x checkpatch.pl + echo "checkpatch=./checkpatch.pl" >> "$GITHUB_OUTPUT" + fi + + - name: Generate patches for PR commits + id: gen + shell: bash + run: | + set -e + BASE_SHA="${{ github.event.pull_request.base.sha }}" + HEAD_SHA="${{ github.event.pull_request.head.sha }}" + mkdir -p patches + # Create one patch per commit in the PR range + git format-patch --no-signature --output-directory patches "${BASE_SHA}..${HEAD_SHA}" + COUNT=$(ls -1 patches/*.patch 2>/dev/null | wc -l | tr -d ' ') + echo "count=$COUNT" >> "$GITHUB_OUTPUT" + if [[ "$COUNT" -eq 0 ]]; then + echo "No new commits/patches to check." + fi + + - name: Run checkpatch (fail on ERROR, allow WARN) + if: steps.gen.outputs.count != '0' + shell: bash + run: | + set -e + shopt -s nullglob + CHECKPATCH="${{ steps.resolve.outputs.checkpatch }}" + ERROR_COUNT=0 + WARN_COUNT=0 + IGNORE_TYPES="FILE_PATH_CHANGES" + #IGNORE_TYPES="${{ vars.CHECKPATCH_IGNORE_TYPES }}" # optional: define repo-level variable, e.g.: 'LONG_LINE,LEADING_SPACE' + for p in patches/*.patch; do + echo "=== Checking $p ===" + #perl "$CHECKPATCH" --no-tree --strict --show-types ${IGNORE_TYPES:+--ignore "$IGNORE_TYPES"} "$p" | tee "checkpatch_${p##*/}.log" || true + perl "$CHECKPATCH" --no-tree --strict --show-types ${IGNORE_TYPES:+--ignore "$IGNORE_TYPES"} "$p" 2> >(grep -v "No typos will be found" | grep -v "No structs that should be const") | tee "checkpatch_${p##*/}.log" || true + done + + # Aggregate + #ERROR_COUNT=$(grep -h '^ERROR:' checkpatch_*.log | wc -l | tr -d ' ') + #WARN_COUNT=$(grep -h '^WARNING:' checkpatch_*.log | wc -l | tr -d ' ') || true + #ERROR_COUNT=$(grep -h '^ERROR:' checkpatch_*.log 2>/dev/null | wc -l | tr -d ' ') + #WARN_COUNT=$(grep -h '^WARNING:' checkpatch_*.log 2>/dev/null | wc -l | tr -d ' ') + # Aggregate using actual summary lines + ERROR_COUNT=$(grep -h '^total: ' checkpatch_*.log | grep -o '[0-9]\+ errors' | awk '{sum += $1} END {print sum+0}') + WARN_COUNT=$(grep -h '^total: ' checkpatch_*.log | grep -o '[0-9]\+ warnings' | awk '{sum += $1} END {print sum+0}') + + echo "Total ERRORs: $ERROR_COUNT" + echo "Total WARNINGs: $WARN_COUNT" + + # Save a combined report + # cat checkpatch_*.log > checkpatch_report.txt || true + + log_files=(checkpatch_*.log) + if (( ${#log_files[@]} > 0 )); then + cat "${log_files[@]}" > checkpatch_report.txt + else + echo "No checkpatch logs found." > checkpatch_report.txt + fi + + + # Upload as artifact for convenience + echo "ERROR_COUNT=$ERROR_COUNT" >> "$GITHUB_ENV" + echo "WARN_COUNT=$WARN_COUNT" >> "$GITHUB_ENV" + + # Fail only if ERRORs present (change condition to fail on warnings too) + if [[ "$ERROR_COUNT" -gt 0 ]]; then + echo "::error title=Checkpatch failed::Found $ERROR_COUNT errors" + exit 1 + fi + + - name: Upload checkpatch report + if: always() + uses: actions/upload-artifact@v4 + with: + name: checkpatch-report + path: | + patches/*.patch + checkpatch_*.log + checkpatch_report.txt From 2bfeb0c8c570e7b6d9fe9250c5c9d8bd90e1b04b Mon Sep 17 00:00:00 2001 From: ffrancis123 Date: Mon, 1 Dec 2025 20:34:50 +0530 Subject: [PATCH 2/3] Update checkpatch.yml Signed-off-by: ffrancis123 --- .github/workflows/checkpatch.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/checkpatch.yml b/.github/workflows/checkpatch.yml index 68bc025..6aa8e6a 100644 --- a/.github/workflows/checkpatch.yml +++ b/.github/workflows/checkpatch.yml @@ -23,13 +23,9 @@ jobs: shell: bash run: | set -e - if [[ -x scripts/checkpatch.pl ]]; then - echo "checkpatch=scripts/checkpatch.pl" >> "$GITHUB_OUTPUT" - else - curl -L --fail -o checkpatch.pl https://raw.githubusercontent.com/torvalds/linux/v6.6/scripts/checkpatch.pl - chmod +x checkpatch.pl - echo "checkpatch=./checkpatch.pl" >> "$GITHUB_OUTPUT" - fi + curl -L --fail -o checkpatch.pl https://raw.githubusercontent.com/torvalds/linux/master/scripts/checkpatch.pl + chmod +x checkpatch.pl + echo "checkpatch=./checkpatch.pl" >> "$GITHUB_OUTPUT" - name: Generate patches for PR commits id: gen From efc591e1606e0965f8480e43d99527301395cc43 Mon Sep 17 00:00:00 2001 From: ffrancis123 Date: Mon, 1 Dec 2025 20:36:06 +0530 Subject: [PATCH 3/3] Update checkpatch.yml Signed-off-by: ffrancis123 --- .github/workflows/checkpatch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checkpatch.yml b/.github/workflows/checkpatch.yml index 6aa8e6a..80633eb 100644 --- a/.github/workflows/checkpatch.yml +++ b/.github/workflows/checkpatch.yml @@ -17,7 +17,7 @@ jobs: - name: Install Perl run: sudo apt-get update && sudo apt-get install -y perl - # If your repo has scripts/checkpatch.pl, we use it; else download a stable version from upstream. + # download a stable version from upstream. - name: Resolve checkpatch.pl id: resolve shell: bash