Skip to content

Handle repo2docker breaking changes #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2025
Merged
Show file tree
Hide file tree
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
34 changes: 29 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
python_version: ["3.9"]
container_engine:
- podman
repo2docker_version:
# Use version in dev-requirements.txt
- ""
repo_type:
# Only test a subset of the repo2docker tests since we're testing podman,
# not the full repo2docker functionality
Expand Down Expand Up @@ -48,6 +51,11 @@ jobs:
- python_version: "3.11"
container_engine: nerdctl
repo_type: venv/default
- python_version: "3.13"
container_engine: podman
repo_type: base
# 2025-05-12
repo2docker_version: e795060aec3555a6203ed79c3676765fb3f3b850

steps:
- name: Checkout repo
Expand All @@ -69,9 +77,16 @@ jobs:
containerd-rootless-setuptool.sh install
containerd-rootless-setuptool.sh install-buildkit

- name: Install
- name: Install dependencies
run: |
pip install -r dev-requirements.txt
if [ -n "${{ matrix.repo2docker_version }}" ]; then
pip install git+https://github.com/jupyterhub/repo2docker@${{ matrix.repo2docker_version }}
fi
pip freeze

- name: Install
run: |
# Make a wheel and install it to catch possible issues with releases
python -m build --wheel
pip install dist/*.whl
Expand All @@ -80,10 +95,19 @@ jobs:
- name: Fetch repo2docker tests
run: |
# Tests need to match the r2d version, need to convert YYYY.M.N to YYYY.MM.N
R2D_PY_VERSION=$(grep jupyter-repo2docker== dev-requirements.txt | cut -d= -f3)
GIT_TAG=$(echo $R2D_PY_VERSION | sed -re 's/\.([[:digit:]])\./.0\1./')
echo "Cloning repo2docker test from tag: $GIT_TAG"
git clone --depth 1 --branch=$GIT_TAG https://github.com/jupyter/repo2docker tests-repo2docker

if [ -n "${{ matrix.repo2docker_version }}" ]; then
echo "Cloning repo2docker test: ${{ matrix.repo2docker_version }}"
git clone https://github.com/jupyter/repo2docker tests-repo2docker
cd tests-repo2docker
git checkout ${{ matrix.repo2docker_version }}
cd ..
else
R2D_PY_VERSION=$(grep jupyter-repo2docker== dev-requirements.txt | cut -d= -f3)
GIT_TAG=$(echo $R2D_PY_VERSION | sed -re 's/\.([[:digit:]])\./.0\1./')
echo "Cloning repo2docker test from tag: $GIT_TAG"
git clone --depth 1 --branch=$GIT_TAG https://github.com/jupyter/repo2docker tests-repo2docker
fi
for d in ./tests-repo2docker/tests/*/; do
if [ "${d##*tests/}" != "unit/" ]; then
cp -a $d tests
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.0
rev: v0.12.0
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.5.3
hooks:
- id: prettier
22 changes: 22 additions & 0 deletions repo2podman/podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ def __init__(self, *, parent):
def build(
self,
*,
push=False,
load=False,
buildargs=None,
cache_from=None,
container_limits=None,
Expand Down Expand Up @@ -449,6 +451,11 @@ def build(
# except KeyError:
# pass

# load is ignored, only used by docker buildx
# https://github.com/jupyterhub/repo2docker/pull/1421/files
if push and not tag:
raise ValueError("tag required when push=True")

if kwargs:
raise ValueError("Additional kwargs not supported")

Expand All @@ -474,6 +481,10 @@ def build(
):
yield line

if push:
for line in self.push(tag):
yield line

def images(self):
def remove_local(tags):
if tags:
Expand Down Expand Up @@ -503,6 +514,17 @@ def remove_local(tags):
]

def inspect_image(self, image):
# https://github.com/jupyterhub/repo2docker/pull/1421
# Return None if image doesn't exist
try:
exec_podman(
["image", "exists", image], capture="both", exe=self.podman_executable
)
except PodmanCommandError as e:
if isinstance(e.e, CalledProcessError) and e.e.returncode == 1:
return None
raise

lines = exec_podman(
["inspect", "--type", "image", "--format", self.format_arg, image],
capture="stdout",
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

import os
import pipes
import shlex
import requests
import time

Expand Down Expand Up @@ -87,7 +87,7 @@ def reportinfo(self):
def repr_failure(self, excinfo):
err = excinfo.value
if isinstance(err, SystemExit):
cmd = "jupyter-repo2docker %s" % " ".join(map(pipes.quote, self.args))
cmd = "jupyter-repo2docker %s" % " ".join(map(shlex.quote, self.args))
return "%s | exited with status=%s" % (cmd, err.code)
else:
return super().repr_failure(excinfo)
Expand Down
Loading