Skip to content

Commit a280960

Browse files
committed
kernel-upgrade: Improve error handling
1 parent 98b30d7 commit a280960

File tree

2 files changed

+40
-12
lines changed

2 files changed

+40
-12
lines changed

.github/workflows/check-kernel-release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
- name: Fetch kernel.org and check for 6.12 release
2626
id: check
2727
run: |
28+
set -e -o pipefail
2829
# Fetch the kernel.org frontpage and extract 6.12 version
2930
CURRENT_VERSION=$(curl -s https://www.kernel.org/ | grep -oP '6\.12\.\d+' | head -n1)
3031
@@ -56,6 +57,7 @@ jobs:
5657
- name: Set up git credentials
5758
if: steps.check.outputs.new_release == 'true'
5859
run: |
60+
set -e -o pipefail
5961
git config --global user.email "ael-bot@users.noreply.github.com"
6062
git config --global user.name "ael-bot"
6163
@@ -68,6 +70,7 @@ jobs:
6870
env:
6971
GIT_TERMINAL_PROMPT: 0
7072
run: |
73+
set -e -o pipefail
7174
./utils/kernel-upgrade.sh linux
7275
7376
- name: Create pull request

utils/kernel-upgrade.sh

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Usage: ./utils/kernel-upgrade.sh <path-to-linux-dir>
77
#
88

9-
set -e
9+
set -e -o pipefail
1010

1111
# Parse arguments
1212
if [ $# -ne 1 ]; then
@@ -139,15 +139,6 @@ rebase_kernel() {
139139
log_info "Run 'git rebase --abort' to cancel or resolve conflicts manually"
140140
exit 1
141141
fi
142-
143-
# Push rebased branch to kkit remote
144-
log_info "Pushing rebased branch to $KKIT_REMOTE..."
145-
if git -C "$LINUX_DIR" push "$KKIT_REMOTE" "$LINUX_BRANCH" --force-with-lease; then
146-
log_info "Successfully pushed to $KKIT_REMOTE"
147-
else
148-
log_error "Push failed"
149-
exit 1
150-
fi
151142
}
152143

153144
# Update infix and run kernel refresh
@@ -195,8 +186,8 @@ update_infix() {
195186

196187
# Check if versions are the same
197188
if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
198-
log_info "Kernel version unchanged ($OLD_VERSION), skipping refresh"
199-
return 0
189+
log_info "Kernel version unchanged ($OLD_VERSION), nothing to do"
190+
exit 0
200191
fi
201192

202193
# Run kernel refresh script
@@ -231,6 +222,16 @@ update_infix() {
231222
else
232223
log_warn "doc/ChangeLog.md not found, skipping changelog update"
233224
fi
225+
226+
# Commit all changes
227+
log_info "Committing changes to infix..."
228+
git -C "$INFIX_DIR" add -A
229+
if git -C "$INFIX_DIR" diff-index --quiet HEAD --; then
230+
log_info "No changes to commit"
231+
else
232+
git -C "$INFIX_DIR" commit -m "Upgrade Linux kernel to $NEW_VERSION"
233+
log_info "Changes committed"
234+
fi
234235
}
235236

236237
# Check for uncommitted changes
@@ -254,6 +255,29 @@ check_clean_working_tree() {
254255
log_info "Working tree is clean"
255256
}
256257

258+
# Push changes to remotes
259+
push_changes() {
260+
log_info "Pushing changes to remotes..."
261+
262+
# Push rebased linux branch to kkit remote
263+
log_info "Pushing rebased linux branch to $KKIT_REMOTE..."
264+
if git -C "$LINUX_DIR" push "$KKIT_REMOTE" "$LINUX_BRANCH" --force-with-lease; then
265+
log_info "Successfully pushed linux branch to $KKIT_REMOTE"
266+
else
267+
log_error "Push to linux remote failed"
268+
exit 1
269+
fi
270+
271+
# Push infix branch to origin
272+
log_info "Pushing infix branch to origin..."
273+
if git -C "$INFIX_DIR" push origin "$INFIX_BRANCH"; then
274+
log_info "Successfully pushed infix branch to origin"
275+
else
276+
log_error "Push to infix remote failed"
277+
exit 1
278+
fi
279+
}
280+
257281
# Main execution
258282
main() {
259283
log_info "Starting automated kernel upgrade test..."
@@ -265,6 +289,7 @@ main() {
265289
update_linux_kernel
266290
rebase_kernel
267291
update_infix
292+
push_changes
268293

269294
log_info "Kernel upgrade completed successfully!"
270295
}

0 commit comments

Comments
 (0)