Skip to content

Commit

Permalink
Run sanity with all supported python versions (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Aug 8, 2024
1 parent e94cca0 commit c4a12a1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ jobs:
default_python: "3.9"
other_names: |
lint
integration
sanity
py39-integration
py39-sanity
py312-sanity
platforms: linux,macos
build:
name: ${{ matrix.name }}
Expand Down Expand Up @@ -78,8 +79,10 @@ jobs:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update -y
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin python3.11-dev python3.11-venv python3.11-full
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin python3.9-dev python3.9-venv python3.10-dev python3.10-venv python3.10-dev python3.10-venv python3.11-dev python3.11-venv shellcheck
# installs pip for alternative python versions that do not ship it
python3.9 -m ensurepip
python3.10 -m ensurepip
python3.11 -m ensurepip
# Do not install docker-compose-plugin because it would v1 (broken due to not working with newer requests library)
sudo systemctl enable --now docker
Expand Down
8 changes: 7 additions & 1 deletion bindep.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ libsystemd0 [test platform:debian]
libsystemd-dev [test platform:debian]
pkg-config [test platform:debian]

# for sanity testing to pass we need all supported python versions installed:
# For sanity testing to pass we need all supported Python versions installed:
python3.9-dev [test platform:ubuntu-noble]
python3.9-venv [test platform:ubuntu-noble]
python3.10-dev [test platform:ubuntu-noble]
python3.10-venv [test platform:ubuntu-noble]
python3.11-dev [test platform:ubuntu-noble]
python3.11-venv [test platform:ubuntu-noble]
shellcheck [test platform:ubuntu-noble]
31 changes: 21 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# cspell: ignore TOXPYTHON setenv passenv REQPASS PYTHONPYCACHEPREFIX PYTHONIOENCODING PYTHONBREAKPOINT

[tox]
envlist = lint, darglint, py, integration
envlist = lint, darglint, py, sanity, integration
skipsdist = true # this repo is not a python package
isolated_build = true
requires =
Expand All @@ -13,17 +13,15 @@ requires =
setuptools >= 65.3.0 # editable installs

[testenv]
description = Run sanity and unit tests
basepython =
py39: {env:TOXPYTHON:python3.9}
py310: {env:TOXPYTHON:python3.10}
description =
Run unit tests
py{39,310,311,312,313}: with {basepython}
deps = -r test_requirements.txt
commands_pre =
bash -c 'test "$(basename $(cd ../.. && pwd))" == ansible_collections || { echo "Repository must be cloned inside a directory structure like ansible_collections/ansible/eda in order allow ansible-test to run."; exit 3;}'
commands =
# fail-fast if psycopg in not properly installed.
python3 -c "import psycopg"
ansible-test sanity
ansible-test units --venv -v --num-workers 1
allowlist_externals =
bash
Expand Down Expand Up @@ -52,25 +50,38 @@ passenv =
# https://tox.wiki/en/latest/upgrading.html#editable-mode
package = editable

[testenv:py{39,310,311,312,313}]
description =
Run unit tests
py{39,310,311,312,313}: with {basepython}



[testenv:lint]
deps = pre-commit
description = Run linters
commands = pre-commit run -a

[testenv:darglint]
deps = darglint
description = Run darglint
commands = darglint -s numpy -z full extensions/eda/plugins

[testenv:integration]
[testenv:integration,py{39,310,311,312,313}-integration]
deps = -r test_requirements.txt
description = Run integration tests
description =
Run integration tests
py{39,310,311,312,313}: with {basepython}
commands =
# risky: not safe for development it affects user setup
ansible-galaxy collection install .
pytest tests/integration -vvv -s

[testenv:sanity]
[testenv:sanity,py{39,310,311,312,313}-sanity]
deps = -r test_requirements.txt
description = Run ansible-test sanity on all python versions
description =
Run ansible-test sanity
py{39,310,311,312,313}: with {basepython}
commands =
ansible --version
ansible-test sanity

0 comments on commit c4a12a1

Please sign in to comment.