Skip to content

Commit 8c7887d

Browse files
committed
Speed up with pytest-split
1 parent 7474185 commit 8c7887d

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ concurrency:
1111

1212
jobs:
1313
build:
14-
name: ${{ matrix.image }}
14+
name: ${{ matrix.image }} (shard ${{ matrix.shard }})
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
fail-fast: false
1818
matrix:
1919
os: ["ubuntu-latest"]
20+
# This shards every image in the matrix below. Only the valgrind
21+
# image reads SHARD_INDEX/SHARD_COUNT; scope this to valgrind via
22+
# `include` before re-enabling the other (fast, unsharded) images.
23+
shard: [1, 2, 3, 4]
2024
image:
2125
# Run slower jobs first to give them a headstart and reduce waiting time
2226
- "ubuntu-26.04-resolute-ppc64le"
@@ -102,6 +106,8 @@ jobs:
102106
make test BRANCH=main
103107
env:
104108
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
109+
SHARD_INDEX: ${{ matrix.shard }}
110+
SHARD_COUNT: 4
105111

106112
- name: Log image size
107113
run: |

ubuntu-24.04-noble-amd64-valgrind/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ARG PIP_NO_CACHE_DIR=1
4343

4444
RUN virtualenv -p /usr/bin/python3.12-dbg --system-site-packages /vpy3 \
4545
&& /vpy3/bin/pip install --upgrade pip \
46-
&& /vpy3/bin/pip install olefile pytest pytest-cov pytest-timeout pytest-valgrind \
46+
&& /vpy3/bin/pip install olefile pytest pytest-cov pytest-split pytest-timeout pytest-valgrind \
4747
&& chown -R pillow:pillow /vpy3
4848

4949
COPY depends /depends

ubuntu-24.04-noble-amd64-valgrind/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ update:
1717

1818
.PHONY: test
1919
test:
20-
docker run --rm -e "PILLOW_VALGRIND_TEST=true" -v $(ROOT):/Pillow $(IMAGENAME):$(BRANCH)
20+
docker run --rm -e "PILLOW_VALGRIND_TEST=true" -e SHARD_INDEX -e SHARD_COUNT -v $(ROOT):/Pillow $(IMAGENAME):$(BRANCH)
2121

2222
.PHONY: push
2323
push:

ubuntu-24.04-noble-amd64-valgrind/test.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ cd /Pillow
44
make clean
55
make install-coverage
66

7+
SPLIT_ARGS=""
8+
if [ "${SHARD_COUNT:-1}" -gt 1 ]; then
9+
SPLIT_ARGS="--splits ${SHARD_COUNT} --group ${SHARD_INDEX}"
10+
fi
11+
712
PYTHONMALLOC=malloc valgrind --suppressions=/depends/python.supp --leak-check=no \
813
--log-file=/tmp/valgrind-output \
9-
python3 -m pytest --no-memcheck -vv --valgrind --valgrind-log=/tmp/valgrind-output
14+
python3 -m pytest --no-memcheck -vv --valgrind --valgrind-log=/tmp/valgrind-output $SPLIT_ARGS
1015

1116
# To run one test in the image:
1217
# make bash

0 commit comments

Comments
 (0)