Skip to content

Commit e1c5baf

Browse files
committed
github actions: validate-kernel-commits: Add interdiff
Add steps to look for differences between upsteam commits referenced in PR commit and the upsteam change they are backporting. This is accomplished with a customized version of interdiff with fuzzy diffing and the run_interdiff.py helper script. Since the custom fuzzy diffing changes aren't available in upstream patchutils yet this workflow pulls down and builds the custom version.
1 parent 8adf1e3 commit e1c5baf

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/validate-kernel-commits.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,68 @@ jobs:
7878
echo "❌ Failed to post check-kernel-commits comment to PR"
7979
exit 1
8080
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

Comments
 (0)