From bb0c6727dfb217a22d1277b2b95636e2d3838a6c Mon Sep 17 00:00:00 2001 From: Simon Li Date: Sat, 2 Mar 2024 22:25:42 +0000 Subject: [PATCH] Test docker and nerdctl --- .github/workflows/build.yml | 26 +++++++++++++++++++++++++- tests/conftest.py | 8 ++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d65dd41..1963b0a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,8 @@ jobs: fail-fast: false matrix: python_version: ["3.9"] + container_engine: + - podman repo_type: # Only test a subset of the repo2docker tests since we're testing podman, # not the full repo2docker functionality @@ -33,6 +35,19 @@ jobs: # - r - unit - venv/default + include: + - python_version: "3.11" + container_engine: docker + repo_type: base + - python_version: "3.11" + container_engine: docker + repo_type: venv/default + - python_version: "3.11" + container_engine: nerdctl + repo_type: base + - python_version: "3.11" + container_engine: nerdctl + repo_type: venv/default steps: - name: Checkout repo @@ -45,6 +60,12 @@ jobs: cache: pip cache-dependency-path: dev-requirements.txt + - name: Install nerdctl + if: matrix.container_engine == 'nerdctl' + run: | + NERDCTL_VERSION=1.7.4 + curl -sfL https://github.com/containerd/nerdctl/releases/download/v$NERDCTL_VERSION/nerdctl-full-$NERDCTL_VERSION-linux-amd64.tar.gz | tar -zxvf - -C /usr/local + - name: Install run: | pip install -r dev-requirements.txt @@ -67,7 +88,10 @@ jobs: done - name: Run tests - run: pytest -v tests/${{ matrix.repo_type }} + run: | + export CONTAINER_ENGINE=${{ matrix.container_engine }} + which $CONTAINER_ENGINE + pytest -v tests/${{ matrix.repo_type }} # https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ publish-pypi: diff --git a/tests/conftest.py b/tests/conftest.py index bc128bb..0bd665d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,6 +19,9 @@ from repo2docker.__main__ import make_r2d +CONTAINER_ENGINE = os.getenv("CONTAINER_ENGINE") + + def pytest_collect_file(parent, path): if path.basename == "verify": return LocalRepo.from_parent(parent, fspath=path) @@ -99,9 +102,10 @@ def collect(self): args = [ "--appendix", 'RUN echo "appendix" > /tmp/appendix', - "--engine", - "podman", + "--engine=podman", ] + if CONTAINER_ENGINE: + args.append(f"--PodmanEngine.podman_executable={CONTAINER_ENGINE}") # If there's an extra-args.yaml file in a test dir, assume it contains # a yaml list with extra arguments to be passed to repo2docker extra_args_path = os.path.join(self.fspath.dirname, "extra-args.yaml")