|
78 | 78 | echo "❌ Failed to post check-kernel-commits comment to PR" |
79 | 79 | exit 1 |
80 | 80 | fi |
| 81 | +
|
| 82 | + - name: Install build dependencies for patchutils |
| 83 | + run: | |
| 84 | + sudo apt-get update |
| 85 | + sudo apt-get install -y build-essential autoconf automake libtool gnulib |
| 86 | +
|
| 87 | + - name: Clone and build custom patchutils |
| 88 | + run: | |
| 89 | + git clone https://github.com/kerneltoast/patchutils.git --depth=1 --revision=32e5f1df96920f1d24beb910346f01acab8b0bd8 |
| 90 | + cd patchutils |
| 91 | + ./bootstrap |
| 92 | + ./configure |
| 93 | + make -j$(nproc) |
| 94 | +
|
| 95 | + - name: Download run_interdiff.py |
| 96 | + run: | |
| 97 | + curl -sL \ |
| 98 | + https://raw.githubusercontent.com/ctrliq/kernel-src-tree-tools/mainline/run_interdiff.py \ |
| 99 | + -o run_interdiff.py |
| 100 | + chmod +x run_interdiff.py |
| 101 | +
|
| 102 | + - name: Run interdiff check |
| 103 | + id: interdiff |
| 104 | + run: | |
| 105 | + set +e # Don't exit on error, we want to capture the output |
| 106 | + python3 run_interdiff.py --repo . --pr_branch "${{ github.head_ref }}" --base_branch "${{ github.base_ref }}" --markdown --interdiff ../patchutils/src/interdiff | tee interdiff_result.txt |
| 107 | + EXIT_CODE=$? |
| 108 | +
|
| 109 | + # Check if the script failed |
| 110 | + if [ $EXIT_CODE -ne 0 ]; then |
| 111 | + echo "❌ Interdiff check failed with exit code $EXIT_CODE" |
| 112 | + exit $EXIT_CODE |
| 113 | + fi |
| 114 | +
|
| 115 | + # Check for differences: |
| 116 | + # 1. Verify the success message exists |
| 117 | + # 2. If it exists, check if there are any OTHER lines (which would indicate differences) |
| 118 | + # 3. If success message doesn't exist, that's also a difference |
| 119 | + if grep -q "All backported commits match their upstream counterparts." interdiff_result.txt; then |
| 120 | + # Success message found, check if there are any other lines |
| 121 | + LINE_COUNT=$(wc -l < ../interdiff_result.txt) |
| 122 | + if [ "$LINE_COUNT" -gt 1 ]; then |
| 123 | + echo "has_differences=true" >> $GITHUB_OUTPUT |
| 124 | + else |
| 125 | + echo "has_differences=false" >> $GITHUB_OUTPUT |
| 126 | + fi |
| 127 | + else |
| 128 | + # Success message not found, there must be differences |
| 129 | + echo "has_differences=true" >> $GITHUB_OUTPUT |
| 130 | + fi |
| 131 | +
|
| 132 | + set -e # Re-enable exit on error |
| 133 | +
|
| 134 | + - name: Comment on PR if interdiff differences found |
| 135 | + if: steps.interdiff.outputs.has_differences == 'true' |
| 136 | + env: |
| 137 | + GH_TOKEN: ${{ github.token }} |
| 138 | + run: | |
| 139 | + if ! gh pr comment ${{ github.event.pull_request.number }} \ |
| 140 | + --body-file interdiff_result.txt \ |
| 141 | + --repo ${{ github.repository }}; then |
| 142 | + echo "❌ Failed to post interdiff comment to PR" |
| 143 | + exit 1 |
| 144 | + fi |
| 145 | +
|
0 commit comments