Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,27 @@ RUN apk update && apk upgrade\
&& apk cache clean


RUN --mount=type=cache,target=/root/.cache/pip\
PYTHONDONTWRITEBYTECODE=1\
pip install --no-compile --no-cache\
-r /requirements.txt
# Don't write bytecode when Python runs, and don't buffer output.
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1

# Pip compiles each package to bytecode as it installs it, so every run
# starts pytest and its dependencies from compiled files instead of compiling
# them from source first.
RUN --mount=type=cache,target=/root/.cache/pip pip install -r /requirements.txt

COPY . /opt/test-runner

# Compile the runner to bytecode now, so runs don't compile it. The
# checked-hash files stay valid however the file times change.
RUN python3 -m compileall -q --invalidation-mode=checked-hash /opt/test-runner/runner /opt/test-runner/bin

# Run pytest once on a dummy test so it caches its assertion-rewritten copies
# of the installed plugins (such as pytest-subtests), which compileall can't make.
# This step unsets PYTHONDONTWRITEBYTECODE, because pytest needs it unset to
# write those files.
RUN mkdir /tmp/warm && echo "def test_x(): assert True" > /tmp/warm/test_warm.py \
&& PYTHONDONTWRITEBYTECODE= python3 -m pytest --collect-only -q -p no:cacheprovider /tmp/warm && rm -rf /tmp/warm

WORKDIR /opt/test-runner

ENTRYPOINT ["sh", "/opt/test-runner/bin/run.sh" ]
Loading