Skip to content

Commit b82e601

Browse files
authored
Merge pull request #7741 from hugovk/ci-stuff
CI: Cache libimagequant on Linux builds
2 parents b3a7ae0 + d96c196 commit b82e601

4 files changed

Lines changed: 59 additions & 11 deletions

File tree

.github/workflows/docs.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,26 @@ jobs:
3737
with:
3838
python-version: "3.x"
3939
cache: pip
40-
cache-dependency-path: ".ci/*.sh"
40+
cache-dependency-path: |
41+
".ci/*.sh"
42+
"pyproject.toml"
4143
4244
- name: Build system information
4345
run: python3 .github/workflows/system-info.py
4446

47+
- name: Cache libimagequant
48+
uses: actions/cache@v4
49+
id: cache-libimagequant
50+
with:
51+
path: ~/cache-libimagequant
52+
key: ${{ runner.os }}-libimagequant-${{ hashFiles('depends/install_imagequant.sh') }}
53+
4554
- name: Install Linux dependencies
4655
run: |
4756
.ci/install.sh
4857
env:
4958
GHA_PYTHON_VERSION: "3.x"
59+
GHA_LIBIMAGEQUANT_CACHE_HIT: ${{ steps.cache-libimagequant.outputs.cache-hit }}
5060

5161
- name: Build
5262
run: |

.github/workflows/test.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ concurrency:
2626
group: ${{ github.workflow }}-${{ github.ref }}
2727
cancel-in-progress: true
2828

29+
env:
30+
FORCE_COLOR: 1
31+
2932
jobs:
3033
build:
3134

@@ -65,17 +68,28 @@ jobs:
6568
python-version: ${{ matrix.python-version }}
6669
allow-prereleases: true
6770
cache: pip
68-
cache-dependency-path: ".ci/*.sh"
71+
cache-dependency-path: |
72+
".ci/*.sh"
73+
"pyproject.toml"
6974
7075
- name: Build system information
7176
run: python3 .github/workflows/system-info.py
7277

78+
- name: Cache libimagequant
79+
if: startsWith(matrix.os, 'ubuntu')
80+
uses: actions/cache@v4
81+
id: cache-libimagequant
82+
with:
83+
path: ~/cache-libimagequant
84+
key: ${{ runner.os }}-libimagequant-${{ hashFiles('depends/install_imagequant.sh') }}
85+
7386
- name: Install Linux dependencies
7487
if: startsWith(matrix.os, 'ubuntu')
7588
run: |
7689
.ci/install.sh
7790
env:
7891
GHA_PYTHON_VERSION: ${{ matrix.python-version }}
92+
GHA_LIBIMAGEQUANT_CACHE_HIT: ${{ steps.cache-libimagequant.outputs.cache-hit }}
7993

8094
- name: Install macOS dependencies
8195
if: startsWith(matrix.os, 'macOS')

depends/download-and-extract.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ archive=$1
55
url=$2
66

77
if [ ! -f $archive.tar.gz ]; then
8-
wget -O $archive.tar.gz $url
8+
wget --no-verbose -O $archive.tar.gz $url
99
fi
1010

1111
rmdir $archive

depends/install_imagequant.sh

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
11
#!/bin/bash
22
# install libimagequant
33

4-
archive=libimagequant-4.2.2
4+
archive_name=libimagequant
5+
archive_version=4.2.2
56

6-
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz
7+
archive=$archive_name-$archive_version
78

8-
pushd $archive/imagequant-sys
9+
if [[ "$GHA_LIBIMAGEQUANT_CACHE_HIT" == "true" ]]; then
910

10-
cargo install cargo-c
11-
cargo cinstall --prefix=/usr --destdir=.
12-
sudo cp usr/lib/libimagequant.so* /usr/lib/
13-
sudo cp usr/include/libimagequant.h /usr/include/
11+
# Copy cached files into place
12+
sudo cp ~/cache-$archive_name/libimagequant.so* /usr/lib/
13+
sudo cp ~/cache-$archive_name/libimagequant.h /usr/include/
1414

15-
popd
15+
else
16+
17+
# Build from source
18+
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz
19+
20+
pushd $archive/imagequant-sys
21+
22+
cargo install cargo-c
23+
cargo cinstall --prefix=/usr --destdir=.
24+
25+
# Copy into place
26+
sudo cp usr/lib/libimagequant.so* /usr/lib/
27+
sudo cp usr/include/libimagequant.h /usr/include/
28+
29+
if [ -n "$GITHUB_ACTIONS" ]; then
30+
# Copy to cache
31+
rm -rf ~/cache-$archive_name
32+
mkdir ~/cache-$archive_name
33+
cp usr/lib/libimagequant.so* ~/cache-$archive_name/
34+
cp usr/include/libimagequant.h ~/cache-$archive_name/
35+
fi
36+
37+
popd
38+
39+
fi

0 commit comments

Comments
 (0)