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 ee20316
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/build-virtualenv-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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
6 changes: 6 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,10 @@ passenv =
SSH_AUTH_SOCK
HOME
PATH
allowlist_externals =
curl
patch
{toxinidir}/tools/patch-kapitan.sh

[testenv:bandit]
description = PyCQA security linter
Expand Down
11 changes: 9 additions & 2 deletions 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,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
Expand All @@ -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:
Expand Down

0 comments on commit ee20316

Please sign in to comment.