From ee203161aeebc90a0591febc6fde4f64c90d123c Mon Sep 17 00:00:00 2001 From: Simon Gerber Date: Fri, 15 Sep 2023 15:21:50 +0200 Subject: [PATCH] Add test environment for Python 3.11 + reclass_rs Add tox environment which patches Kapitan to use reclass-rs, add a make target `test_py3.11_reclass_rs`, and add a GitHub actions job which runs that make target. --- .github/workflows/build-virtualenv-caches.yml | 19 ++++++++++++++ .github/workflows/test.yml | 26 +++++++++++++++++++ tools/patch-kapitan.sh | 13 ++++++++++ tox.ini | 6 +++++ tox.mk | 11 ++++++-- 5 files changed, 73 insertions(+), 2 deletions(-) create mode 100755 tools/patch-kapitan.sh diff --git a/.github/workflows/build-virtualenv-caches.yml b/.github/workflows/build-virtualenv-caches.yml index f63d13224..13b30b19f 100644 --- a/.github/workflows/build-virtualenv-caches.yml +++ b/.github/workflows/build-virtualenv-caches.yml @@ -65,6 +65,25 @@ jobs: run: echo "PYVER=$(echo ${{ matrix.python-version}} |cut -d. -f1,2)" >> $GITHUB_ENV - run: | make testenv_py${PYVER} + build-test-reclass-rs-virtualenvs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - uses: Gr1N/setup-poetry@v8 + - name: Install tox + run: | + pip install tox + - uses: actions/cache@v3 + with: + path: | + .tox + ~/.cache/pypoetry/virtualenvs + key: ${{ runner.os }}-test-py3.11-reclass-rs-${{ hashFiles('poetry.lock', 'tox.ini') }} + - run: | + make testenv_py3.11_reclass_rs build-bench-virtualenvs: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6a232883..c151862d8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -74,6 +74,32 @@ jobs: run: echo "PYVER=$(echo ${{ matrix.python-version}} |cut -d. -f1,2)" >> $GITHUB_ENV - name: Run tests on Python ${{ matrix.python-version }} run: make test_py${PYVER} + tests_reclass_rs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - uses: Gr1N/setup-poetry@v8 + - name: Install tox + run: | + pip install tox + - uses: actions/cache@v3 + with: + path: | + .tox + ~/.cache/pypoetry/virtualenvs + key: ${{ runner.os }}-test-py3.11-reclass-rs-${{ hashFiles('poetry.lock', 'tox.ini') }} + - name: Install jsonnet-bundler + run: | + mkdir -p /opt/bin && curl -sLo /opt/bin/jb \ + https://github.com/jsonnet-bundler/jsonnet-bundler/releases/download/v0.4.0/jb-linux-amd64 \ + && chmod +x /opt/bin/jb + - name: Update PATH + run: echo "/opt/bin" >> $GITHUB_PATH + - name: Run tests on Python 3.11 with reclass-rs + run: make test_py3.11_reclass_rs benchs: runs-on: ubuntu-latest strategy: diff --git a/tools/patch-kapitan.sh b/tools/patch-kapitan.sh new file mode 100755 index 000000000..8f8c560f9 --- /dev/null +++ b/tools/patch-kapitan.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -eo pipefail + +KAPITAN_DIRECTORY=$1 +echo "Patching Kapitan in $KAPITAN_DIRECTORY" +if [ -f ${KAPITAN_DIRECTORY}/.patched ]; then + echo "Already patched" + exit 0 +fi + +curl -L https://raw.githubusercontent.com/projectsyn/reclass-rs/main/hack/kapitan_0.32_reclass_rs.patch | patch -p1 -d $KAPITAN_DIRECTORY +touch ${KAPITAN_DIRECTORY}/.patched diff --git a/tox.ini b/tox.ini index d0c58c106..970bd4899 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,7 @@ envlist = mypy black py3{8,9,10,11}{,-bench} + py311-reclass-rs [testenv] description = Unit tests and doctests @@ -20,6 +21,7 @@ deps = !bench: pytest-xdist bench: pytest-benchmark commands = \ + reclass-rs: {toxinidir}/tools/patch-kapitan.sh {envsitepackagesdir}/kapitan pytest {toxinidir}/tests \ bench: -m bench \ !bench: -m "not bench and not integration" -n auto --dist worksteal \ @@ -28,6 +30,10 @@ passenv = SSH_AUTH_SOCK HOME PATH +allowlist_externals = + curl + patch + {toxinidir}/tools/patch-kapitan.sh [testenv:bandit] description = PyCQA security linter diff --git a/tox.mk b/tox.mk index 5af7c05da..eb7c08b81 100644 --- a/tox.mk +++ b/tox.mk @@ -39,7 +39,7 @@ lintenv_mypy: lintenv_black: $(TOX_COMMAND) -e black --notest -.PHONY: test_py3.8 test_py3.9 test_py3.10 test_py3.11 +.PHONY: test_py3.8 test_py3.9 test_py3.10 test_py3.11 test_py3.11_reclass_rs test_py3.8: $(TOX_COMMAND) -e py38 @@ -53,7 +53,11 @@ test_py3.10: test_py3.11: $(TOX_COMMAND) -e py311 -.PHONY: testenv_py3.8 testenv_py3.9 testenv_py3.10 testenv_py3.11 +test_py3.11_reclass_rs: + $(TOX_COMMAND) -e py311-reclass-rs + +.PHONY: testenv_py3.8 testenv_py3.9 testenv_py3.10 testenv_py3.11 testenv_py3.11_reclass_rs + testenv_py3.8: $(TOX_COMMAND) -e py38 --notest @@ -67,6 +71,9 @@ testenv_py3.10: testenv_py3.11: $(TOX_COMMAND) -e py311 --notest +testenv_py3.11_reclass_rs: + $(TOX_COMMAND) -e py311 --notest + .PHONY: bench_py3.8 bench_py3.9 bench_py3.10 bench_py3.11 bench_py3.8: