diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e51922e1..ab22cbb2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -130,7 +130,7 @@ jobs: uses: actions/cache@v3 with: path: container-test-template-cache - key: ${{ runner.os }}-go-build-cache-${{ hashFiles('containers/test-template/**') }} + key: ${{ runner.os }}-test-template-cache-${{ hashFiles('containers/test-template/**') }} - name: Inject container-test-template-cache into docker uses: reproducible-containers/buildkit-cache-dance@v2.1.2 diff --git a/containers/test-template/Dockerfile b/containers/test-template/Dockerfile index 5fd54422..c3280b01 100644 --- a/containers/test-template/Dockerfile +++ b/containers/test-template/Dockerfile @@ -1,4 +1,5 @@ -FROM python:3.11.5 +ARG PYTHON_VERSION=3.11 +FROM python:${PYTHON_VERSION}-slim # Install and uninstall snakebids to cache it and it's dependences RUN python -m pip install pipx && \ diff --git a/pyproject.toml b/pyproject.toml index d7128594..e24d8cc5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,11 +104,17 @@ pytest --doctest-modules --ignore=docs \ mkinit = "mkinit --recursive --nomods --black -i snakebids" benchmark = "pytest --benchmark-only --benchmark-autosave" +[tool.poe.tasks._get_version] +imports = ["platform"] +expr = "platform.python_version()" + [tool.poe.tasks.build-container] args = [{ name = "container_id", positional = true, required = true }] +uses = { VERSION = "_get_version"} cmd = """ docker build 'containers/${container_id}' \ - --tag 'snakebids/${container_id}:dev' + --tag 'snakebids/${container_id}:${VERSION}' \ + --build-arg="PYTHON_VERSION=${VERSION}" """ [tool.isort] diff --git a/snakebids/tests/test_template.py b/snakebids/tests/test_template.py index 3f0d138a..b8f20975 100644 --- a/snakebids/tests/test_template.py +++ b/snakebids/tests/test_template.py @@ -1,5 +1,6 @@ from __future__ import annotations +import platform import subprocess as sp from pathlib import Path @@ -11,7 +12,7 @@ from snakebids.tests.helpers import needs_docker -@needs_docker("snakebids/test-template:dev") +@needs_docker(f"snakebids/test-template:{platform.python_version()}") @pytest.mark.parametrize( ["build", "venv"], [