Skip to content

Commit b661b3d

Browse files
committed
Improve system dependency installation in CI workflows with enhanced checks and alternative installation methods
1 parent e9311bb commit b661b3d

File tree

2 files changed

+112
-8
lines changed

2 files changed

+112
-8
lines changed

.github/workflows/ci.yml

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,62 @@ jobs:
5656
- name: Install system dependencies
5757
run: |
5858
echo "🔧 Installing system dependencies for BPG..."
59-
# Install missing libraries
60-
sudo apt-get update -qq
61-
sudo apt-get install -y libtiff5-dev pkg-config wget build-essential
62-
echo "✅ System dependencies installed"
59+
60+
# Check if we can use sudo without password
61+
if sudo -n true 2>/dev/null; then
62+
echo "📦 Installing system packages with sudo..."
63+
sudo apt-get update -qq
64+
sudo apt-get install -y libtiff5-dev pkg-config wget build-essential
65+
echo "✅ System dependencies installed via apt"
66+
else
67+
echo "⚠️ Cannot use sudo - checking for existing dependencies..."
68+
69+
# Check if required tools/libraries are already available
70+
MISSING_DEPS=()
71+
72+
# Check for essential build tools
73+
if ! command -v gcc &> /dev/null; then
74+
MISSING_DEPS+=("gcc")
75+
fi
76+
if ! command -v make &> /dev/null; then
77+
MISSING_DEPS+=("make")
78+
fi
79+
if ! command -v wget &> /dev/null && ! command -v curl &> /dev/null; then
80+
MISSING_DEPS+=("wget or curl")
81+
fi
82+
83+
# Check for pkg-config and libraries
84+
if ! command -v pkg-config &> /dev/null; then
85+
MISSING_DEPS+=("pkg-config")
86+
fi
87+
if ! pkg-config --exists libtiff-4 2>/dev/null; then
88+
MISSING_DEPS+=("libtiff-dev")
89+
fi
90+
91+
if [ ${#MISSING_DEPS[@]} -eq 0 ]; then
92+
echo "✅ All required dependencies are already available"
93+
else
94+
echo "❌ Missing dependencies: ${MISSING_DEPS[*]}"
95+
echo "📝 BPG compilation may fail due to missing system dependencies"
96+
echo "💡 Consider configuring passwordless sudo for the runner user"
97+
echo " or pre-installing: libtiff5-dev pkg-config wget build-essential"
98+
99+
# Try alternative installation methods
100+
echo "🔄 Attempting alternative installation methods..."
101+
102+
# Try using conda if available
103+
if command -v conda &> /dev/null; then
104+
echo "📦 Trying conda installation..."
105+
conda install -c conda-forge libtiff pkg-config -y || echo "⚠️ Conda install failed"
106+
fi
107+
108+
# Try using homebrew if available (for macOS runners)
109+
if command -v brew &> /dev/null; then
110+
echo "📦 Trying homebrew installation..."
111+
brew install libtiff pkg-config || echo "⚠️ Homebrew install failed"
112+
fi
113+
fi
114+
fi
63115
64116
- name: Install BPG tools
65117
run: |

.github/workflows/tests.yml

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,62 @@ jobs:
5454
- name: Install system dependencies
5555
run: |
5656
echo "🔧 Installing system dependencies for BPG..."
57-
# Install missing libraries
58-
sudo apt-get update -qq
59-
sudo apt-get install -y libtiff5-dev pkg-config wget build-essential
60-
echo "✅ System dependencies installed"
57+
58+
# Check if we can use sudo without password
59+
if sudo -n true 2>/dev/null; then
60+
echo "📦 Installing system packages with sudo..."
61+
sudo apt-get update -qq
62+
sudo apt-get install -y libtiff5-dev pkg-config wget build-essential
63+
echo "✅ System dependencies installed via apt"
64+
else
65+
echo "⚠️ Cannot use sudo - checking for existing dependencies..."
66+
67+
# Check if required tools/libraries are already available
68+
MISSING_DEPS=()
69+
70+
# Check for essential build tools
71+
if ! command -v gcc &> /dev/null; then
72+
MISSING_DEPS+=("gcc")
73+
fi
74+
if ! command -v make &> /dev/null; then
75+
MISSING_DEPS+=("make")
76+
fi
77+
if ! command -v wget &> /dev/null && ! command -v curl &> /dev/null; then
78+
MISSING_DEPS+=("wget or curl")
79+
fi
80+
81+
# Check for pkg-config and libraries
82+
if ! command -v pkg-config &> /dev/null; then
83+
MISSING_DEPS+=("pkg-config")
84+
fi
85+
if ! pkg-config --exists libtiff-4 2>/dev/null; then
86+
MISSING_DEPS+=("libtiff-dev")
87+
fi
88+
89+
if [ ${#MISSING_DEPS[@]} -eq 0 ]; then
90+
echo "✅ All required dependencies are already available"
91+
else
92+
echo "❌ Missing dependencies: ${MISSING_DEPS[*]}"
93+
echo "📝 BPG compilation may fail due to missing system dependencies"
94+
echo "💡 Consider configuring passwordless sudo for the runner user"
95+
echo " or pre-installing: libtiff5-dev pkg-config wget build-essential"
96+
97+
# Try alternative installation methods
98+
echo "🔄 Attempting alternative installation methods..."
99+
100+
# Try using conda if available
101+
if command -v conda &> /dev/null; then
102+
echo "📦 Trying conda installation..."
103+
conda install -c conda-forge libtiff pkg-config -y || echo "⚠️ Conda install failed"
104+
fi
105+
106+
# Try using homebrew if available (for macOS runners)
107+
if command -v brew &> /dev/null; then
108+
echo "📦 Trying homebrew installation..."
109+
brew install libtiff pkg-config || echo "⚠️ Homebrew install failed"
110+
fi
111+
fi
112+
fi
61113
62114
- name: Install BPG tools
63115
run: |

0 commit comments

Comments
 (0)