Skip to content

Commit e9311bb

Browse files
committed
Enhance CI workflows by adding caching for BPG tools, improving system dependency installation, and implementing multiple download sources for BPG. Include better error handling and logging during the installation process.
1 parent b2afaf9 commit e9311bb

File tree

2 files changed

+96
-8
lines changed

2 files changed

+96
-8
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ jobs:
4444
${{ runner.os }}-ci-pip-${{ matrix.python-version }}-
4545
${{ runner.os }}-ci-pip-
4646
47+
- name: Cache BPG tools
48+
uses: actions/cache@v4
49+
id: bpg-cache
50+
with:
51+
path: ~/.local/bin/bpg*
52+
key: ${{ runner.os }}-bpg-tools-v1
53+
restore-keys: |
54+
${{ runner.os }}-bpg-tools-
55+
56+
- name: Install system dependencies
57+
run: |
58+
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"
63+
4764
- name: Install BPG tools
4865
run: |
4966
echo "🔧 Installing BPG (Better Portable Graphics) tools..."
@@ -56,10 +73,13 @@ jobs:
5673
echo "$BPG_BIN_DIR" >> $GITHUB_PATH
5774
export PATH="$BPG_BIN_DIR:$PATH"
5875
59-
# Check if BPG tools are already installed
76+
# Check if BPG tools are already installed or cached
6077
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
6178
echo "✅ BPG tools already installed"
6279
bpgenc 2>&1 | head -n 3 || true
80+
elif [ "${{ steps.bpg-cache.outputs.cache-hit }}" == "true" ]; then
81+
echo "✅ BPG tools restored from cache"
82+
chmod +x "$BPG_BIN_DIR"/bpg* 2>/dev/null || true
6383
else
6484
echo "📦 Installing BPG tools from source..."
6585
@@ -81,15 +101,38 @@ jobs:
81101
# Download and try to compile BPG (non-blocking)
82102
echo "📥 Downloading BPG source..."
83103
cd /tmp
84-
if wget -q https://bellard.org/bpg/bpg-0.9.8.tar.gz; then
104+
105+
# Try multiple sources for BPG
106+
BPG_DOWNLOADED=false
107+
108+
# Primary source
109+
if wget -q --timeout=10 https://bellard.org/bpg/bpg-0.9.8.tar.gz 2>/dev/null; then
110+
echo "✅ Downloaded BPG source from primary location"
111+
BPG_DOWNLOADED=true
112+
# Fallback: try curl
113+
elif curl -sL --max-time 10 https://bellard.org/bpg/bpg-0.9.8.tar.gz -o bpg-0.9.8.tar.gz 2>/dev/null; then
114+
echo "✅ Downloaded BPG source using curl"
115+
BPG_DOWNLOADED=true
116+
# Alternative source (if available)
117+
elif wget -q --timeout=10 https://github.com/mirrorer/libbpg/archive/refs/heads/master.tar.gz -O bpg-master.tar.gz 2>/dev/null; then
118+
echo "✅ Downloaded BPG source from alternative location"
119+
tar xzf bpg-master.tar.gz
120+
mv libbpg-master bpg-0.9.8
121+
BPG_DOWNLOADED=true
122+
fi
123+
124+
if [ "$BPG_DOWNLOADED" = true ]; then
85125
echo "✅ Downloaded BPG source"
86126
tar xzf bpg-0.9.8.tar.gz
87127
cd bpg-0.9.8
88128
89129
# Try to compile BPG tools
90130
echo "🔨 Attempting to compile BPG tools..."
91-
if make 2>&1; then
131+
132+
# Redirect make output to avoid stdout issues
133+
if make > make_output.log 2>&1; then
92134
echo "✅ BPG compilation successful"
135+
cat make_output.log | tail -n 10 # Show last 10 lines of build log
93136
94137
# Install to user bin directory
95138
if cp bpgenc bpgdec "$BPG_BIN_DIR/" 2>/dev/null; then
@@ -107,7 +150,8 @@ jobs:
107150
fi
108151
else
109152
echo "⚠️ BPG compilation failed - this is non-critical"
110-
echo "🔍 Make output was shown above for debugging"
153+
echo "🔍 Build log (last 20 lines):"
154+
cat make_output.log | tail -n 20 || echo "No build log available"
111155
echo "📝 BPG-dependent tests will be skipped"
112156
fi
113157
else

.github/workflows/tests.yml

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ jobs:
4242
${{ runner.os }}-pip-${{ matrix.python-version }}-
4343
${{ runner.os }}-pip-
4444
45+
- name: Cache BPG tools
46+
uses: actions/cache@v4
47+
id: bpg-cache
48+
with:
49+
path: ~/.local/bin/bpg*
50+
key: ${{ runner.os }}-bpg-tools-v1
51+
restore-keys: |
52+
${{ runner.os }}-bpg-tools-
53+
54+
- name: Install system dependencies
55+
run: |
56+
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"
61+
4562
- name: Install BPG tools
4663
run: |
4764
echo "🔧 Installing BPG (Better Portable Graphics) tools..."
@@ -54,10 +71,13 @@ jobs:
5471
echo "$BPG_BIN_DIR" >> $GITHUB_PATH
5572
export PATH="$BPG_BIN_DIR:$PATH"
5673
57-
# Check if BPG tools are already installed
74+
# Check if BPG tools are already installed or cached
5875
if command -v bpgenc &> /dev/null && command -v bpgdec &> /dev/null; then
5976
echo "✅ BPG tools already installed"
6077
bpgenc 2>&1 | head -n 3 || true
78+
elif [ "${{ steps.bpg-cache.outputs.cache-hit }}" == "true" ]; then
79+
echo "✅ BPG tools restored from cache"
80+
chmod +x "$BPG_BIN_DIR"/bpg* 2>/dev/null || true
6181
else
6282
echo "📦 Installing BPG tools from source..."
6383
@@ -79,15 +99,38 @@ jobs:
7999
# Download and try to compile BPG (non-blocking)
80100
echo "📥 Downloading BPG source..."
81101
cd /tmp
82-
if wget -q https://bellard.org/bpg/bpg-0.9.8.tar.gz; then
102+
103+
# Try multiple sources for BPG
104+
BPG_DOWNLOADED=false
105+
106+
# Primary source
107+
if wget -q --timeout=10 https://bellard.org/bpg/bpg-0.9.8.tar.gz 2>/dev/null; then
108+
echo "✅ Downloaded BPG source from primary location"
109+
BPG_DOWNLOADED=true
110+
# Fallback: try curl
111+
elif curl -sL --max-time 10 https://bellard.org/bpg/bpg-0.9.8.tar.gz -o bpg-0.9.8.tar.gz 2>/dev/null; then
112+
echo "✅ Downloaded BPG source using curl"
113+
BPG_DOWNLOADED=true
114+
# Alternative source (if available)
115+
elif wget -q --timeout=10 https://github.com/mirrorer/libbpg/archive/refs/heads/master.tar.gz -O bpg-master.tar.gz 2>/dev/null; then
116+
echo "✅ Downloaded BPG source from alternative location"
117+
tar xzf bpg-master.tar.gz
118+
mv libbpg-master bpg-0.9.8
119+
BPG_DOWNLOADED=true
120+
fi
121+
122+
if [ "$BPG_DOWNLOADED" = true ]; then
83123
echo "✅ Downloaded BPG source"
84124
tar xzf bpg-0.9.8.tar.gz
85125
cd bpg-0.9.8
86126
87127
# Try to compile BPG tools
88128
echo "🔨 Attempting to compile BPG tools..."
89-
if make 2>&1; then
129+
130+
# Redirect make output to avoid stdout issues
131+
if make > make_output.log 2>&1; then
90132
echo "✅ BPG compilation successful"
133+
cat make_output.log | tail -n 10 # Show last 10 lines of build log
91134
92135
# Install to user bin directory
93136
if cp bpgenc bpgdec "$BPG_BIN_DIR/" 2>/dev/null; then
@@ -105,7 +148,8 @@ jobs:
105148
fi
106149
else
107150
echo "⚠️ BPG compilation failed - this is non-critical"
108-
echo "🔍 Make output was shown above for debugging"
151+
echo "🔍 Build log (last 20 lines):"
152+
cat make_output.log | tail -n 20 || echo "No build log available"
109153
echo "📝 BPG-dependent tests will be skipped"
110154
fi
111155
else

0 commit comments

Comments
 (0)