-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: add basic skopeo and E2E tests
Signed-off-by: tarilabs <[email protected]>
- Loading branch information
Showing
7 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: E2E | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
e2e-skopeo: | ||
name: E2E using CNCF Distribution Registry | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Install Skopeo | ||
run: | | ||
sudo apt-get update && sudo apt-get install skopeo | ||
skopeo version | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.9' | ||
- name: Install Poetry | ||
run: | | ||
pipx install poetry | ||
- name: Install dependencies | ||
run: | | ||
make install | ||
- name: Run E2E tests | ||
run: | | ||
make test-e2e-skopeo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import os | ||
import shutil | ||
import subprocess | ||
import typing | ||
|
||
def is_skopeo() -> bool : | ||
return shutil.which("skopeo") | ||
|
||
def skopeo_pull(base_image: str, dest: typing.Union[str, os.PathLike]): | ||
if isinstance(dest, os.PathLike): | ||
dest = str(dest) | ||
return subprocess.run(["skopeo", "copy", "--multi-arch", "all", "docker://"+base_image, "oci:"+dest+":latest"], check=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
import pytest | ||
from olot.backend.skopeo import is_skopeo, skopeo_pull | ||
from olot.basics import check_ocilayout, read_ocilayout_root_index | ||
|
||
@pytest.mark.e2e_skopeo | ||
def test_is_skopeo(): | ||
assert is_skopeo() | ||
|
||
|
||
@pytest.mark.e2e_skopeo | ||
def test_skopeo_pull(tmp_path): | ||
"""Test skopeo to pull/dl a known base-image to an oci-layout | ||
""" | ||
skopeo_pull("quay.io/mmortari/hello-world-wait", tmp_path) | ||
|
||
assert check_ocilayout(tmp_path) | ||
|
||
mut = read_ocilayout_root_index(tmp_path) | ||
assert mut.schemaVersion == 2 | ||
assert len(mut.manifests) == 1 | ||
manifest0 = mut.manifests[0] | ||
assert manifest0.mediaType == "application/vnd.oci.image.index.v1+json" | ||
assert manifest0.digest == "sha256:d437889e826ecce2116ac711469bd09b1bb3c64d45055cbf23a6f8f3db223b8b" | ||
assert manifest0.size == 491 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import pytest | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
for item in items: | ||
skip_e2e_skopeo = pytest.mark.skip( | ||
reason="this is an end-to-end test, requires explicit opt-in --e2e-skopeo option to run." | ||
) | ||
skip_not_e2e = pytest.mark.skip( | ||
reason="skipping non-e2e tests; opt-out of --e2e -like options to run." | ||
) | ||
if "e2e_skopeo" in item.keywords: | ||
if not config.getoption("--e2e-skopeo"): | ||
item.add_marker(skip_e2e_skopeo) | ||
continue | ||
# elif "e2e_model_registry" in item.keywords: | ||
# if not config.getoption("--e2e-model-registry"): | ||
# item.add_marker(skip_e2e_model_registry) | ||
# continue | ||
|
||
if config.getoption("--e2e-skopeo"): # or config.getoption("--e2e-model-registry"): | ||
item.add_marker(skip_not_e2e) | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--e2e-skopeo", | ||
action="store_true", | ||
default=False, | ||
help="opt-in to run tests marked with e2e_skopeo", | ||
) |