diff --git a/.github/workflows/automated-tests.yml b/.github/workflows/automated-tests.yml index 61ceac66f9..396258f6bf 100644 --- a/.github/workflows/automated-tests.yml +++ b/.github/workflows/automated-tests.yml @@ -292,9 +292,25 @@ jobs: echo "Installation failed with exit code $COMMAND_EXIT_CODE" echo "Retrying installation within $RETRY_INTERVAL seconds..." sleep $RETRY_INTERVAL - # Remove lock in case the timeout was during an apt install - rm -f /var/lib/dpkg/lock fi + echo "Stop any ongoing processes related to apt-get or dpkg that might be stuck" + # Use -q to suppress "no process found" messages + killall -q apt-get || true + killall -q dpkg || true + + echo "Remove the lock files that may have been left behind" + # Group lock file removal for better readability + rm -f /var/lib/dpkg/lock-frontend + rm -f /var/lib/dpkg/lock + rm -f /var/cache/apt/archives/lock + + echo "Reconfigure the package manager" + dpkg --configure -a + + echo "Clean up any partially installed packages" + apt-get clean + apt-get autoremove + RETRY_COUNT=$((RETRY_COUNT + 1)) done