From 586cc194d1d9c85f2ecf715cc44c075f1d161bf6 Mon Sep 17 00:00:00 2001 From: tylertitsworth Date: Tue, 28 May 2024 13:57:08 -0700 Subject: [PATCH] add cache registry --- .github/workflows/container-ci.yaml | 1 + .github/workflows/test-runner-ci.yaml | 1 + README.md | 1 + test-runner/action.yml | 5 +++++ test-runner/tests.yaml | 6 +++--- test-runner/tests/utest.py | 9 +++++---- tox.ini | 1 + 7 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/container-ci.yaml b/.github/workflows/container-ci.yaml index c9713b0f1..c69530043 100644 --- a/.github/workflows/container-ci.yaml +++ b/.github/workflows/container-ci.yaml @@ -189,6 +189,7 @@ jobs: - name: Test Container Group uses: intel/ai-containers/test-runner@main with: + cache_registry: ${{ secrets.CACHE_REGISTRY }} mlops_repo: ${{ secrets.MLOPS_REPO || github.repository }} mlops_ref: ${{ secrets.MLOPS_REF || github.ref }} recipe_dir: ${{ inputs.group_dir }} diff --git a/.github/workflows/test-runner-ci.yaml b/.github/workflows/test-runner-ci.yaml index 83007e998..6ce2a65f9 100644 --- a/.github/workflows/test-runner-ci.yaml +++ b/.github/workflows/test-runner-ci.yaml @@ -104,6 +104,7 @@ jobs: - name: Test Container Group uses: intel/ai-containers/test-runner@main with: + cache_registry: ${{ secrets.CACHE_REGISTRY }} mlops_repo: ${{ github.repository }} mlops_ref: ${{ github.ref }} recipe_dir: test-runner diff --git a/README.md b/README.md index fd074ecf6..4da72f5c6 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Define your project's registry and repository each time you use the project: ```bash # REGISTRY/REPO:TAG +export CACHE_REGISTRY= export REGISTRY= export REPO= ``` diff --git a/test-runner/action.yml b/test-runner/action.yml index 9279b8fbc..8ac3eb8f2 100644 --- a/test-runner/action.yml +++ b/test-runner/action.yml @@ -16,6 +16,10 @@ name: Integration Test description: 'https://github.com/intel/ai-containers/blob/main/test-runner/README.md' author: tyler.titsworth@intel.com inputs: + cache_registry: + description: 'Container Cache Registry URL' + required: true + type: string mlops_repo: description: 'Test Runner org/repo' required: true @@ -63,6 +67,7 @@ runs: shell: bash run: venv/bin/python mlops/test-runner/test_runner.py -f ${{ inputs.test_dir }}/tests.yaml -l ${{ inputs.test_dir }}/logs -a ${{ inputs.recipe_dir }}/.actions.json -v env: + CACHE_REGISTRY: ${{ inputs.cache_registry }} PYTHONPATH: mlops/test-runner REGISTRY: ${{ inputs.registry }} REPO: ${{ inputs.repo }} diff --git a/test-runner/tests.yaml b/test-runner/tests.yaml index 9a79144a5..26e18be2d 100644 --- a/test-runner/tests.yaml +++ b/test-runner/tests.yaml @@ -31,14 +31,14 @@ test2: env: TEST: Hello test3: - img: python:3.10-slim-bullseye # python 3.10 + img: ${CACHE_REGISTRY}/cache/library/python:3.10-slim-bullseye # python 3.10 cmd: python --version # will return python 3.11 serving: True test${TEST:-4}: - img: python:3.11-slim-bullseye + img: ${CACHE_REGISTRY}/cache/library/python:3.11-slim-bullseye cmd: echo "${TEST:-4}" test6: - img: python:3.11-slim-bullseye + img: ${CACHE_REGISTRY}/cache/library/python:3.11-slim-bullseye cmd: "echo 'hello: world'" mask: - hello diff --git a/test-runner/tests/utest.py b/test-runner/tests/utest.py index 1604f96e8..cf1a6e916 100644 --- a/test-runner/tests/utest.py +++ b/test-runner/tests/utest.py @@ -17,6 +17,7 @@ import pytest import yaml +from expandvars import expandvars from hypothesis import given from hypothesis.strategies import dictionaries, text from test_runner import get_test_list, parse_args, set_log_filename @@ -124,20 +125,20 @@ def test_get_test_list(test_args_input, test_json_input): "env": {"TEST": "Hello"}, }, "test3": { - "img": "python:3.10-slim-bullseye", + "img": "${CACHE_REGISTRY}/cache/library/python:3.10-slim-bullseye", "cmd": "python --version", "serving": True, }, "test4": { - "img": "python:3.11-slim-bullseye", + "img": f"{expandvars('${CACHE_REGISTRY}')}/cache/library/python:3.11-slim-bullseye", "cmd": 'echo "4"', }, "test5": { - "img": "python:3.11-slim-bullseye", + "img": f"{expandvars('${CACHE_REGISTRY}')}/cache/library/python:3.11-slim-bullseye", "cmd": 'echo "5"', }, "test6": { - "img": "python:3.11-slim-bullseye", + "img": "${CACHE_REGISTRY}/cache/library/python:3.11-slim-bullseye", "cmd": "echo 'hello: world'", "mask": ["hello"], }, diff --git a/tox.ini b/tox.ini index c9691bbe1..27ce87a9b 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ commands = pythonpath = tests passenv = DOCKER_* setenv = + CACHE_REGISTRY = {env:CACHE_REGISTRY} PATH = {env:PATH}:/usr/local/bin/docker PWD = {env:PWD} REGISTRY = {env:REGISTRY}