Skip to content

Commit

Permalink
Add test environment for Python 3.11 + reclass_rs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
simu committed Sep 15, 2023
1 parent 289e508 commit b4d9163
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,33 @@ 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-${{ 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: Extract Python minor version from matrix python-version
- name: Run tests on Python 3.11 with reclass-rs
run: make test_py3.11_reclass_rs
benchs:
runs-on: ubuntu-latest
strategy:
Expand Down
13 changes: 13 additions & 0 deletions tools/patch-kapitan.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ envlist =
mypy
black
py3{8,9,10,11}{,-bench}
py311-reclass-rs

[testenv]
description = Unit tests and doctests
Expand All @@ -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 \
Expand All @@ -28,6 +30,9 @@ passenv =
SSH_AUTH_SOCK
HOME
PATH
allowlist_externals =
curl
patch

[testenv:bandit]
description = PyCQA security linter
Expand Down
5 changes: 4 additions & 1 deletion tox.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -53,6 +53,9 @@ test_py3.10:
test_py3.11:
$(TOX_COMMAND) -e py311

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.8:
Expand Down

0 comments on commit b4d9163

Please sign in to comment.