Skip to content

Commit 5ef9854

Browse files
committed
tests should fail when they fail tho
1 parent 2889e5a commit 5ef9854

File tree

4 files changed

+42
-40
lines changed

4 files changed

+42
-40
lines changed

Makefile

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,36 +27,34 @@ format: ## Format code with black and other formatters
2727
# Convenience molecule targets (Ubuntu)
2828
molecule-2204-no-uv:
2929
@echo "molecule: ubuntu-22.04 (no uv)"
30-
LOG=molecule-2204-no-uv.log; \
31-
( MOLECULE_OS=ubuntu MOLECULE_VERSION=2204 PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
30+
@LOG=molecule-2204-no-uv.log; \
31+
bash -o pipefail -c "MOLECULE_OS=ubuntu MOLECULE_VERSION=2204 PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG" || \
32+
( echo "FAILED: see $$LOG"; cat $$LOG; exit 1 )
3233

3334
molecule-2404-no-uv:
3435
@echo "molecule: ubuntu-24.04 (no uv)"
35-
LOG=molecule-2404-no-uv.log; \
36-
( MOLECULE_OS=ubuntu MOLECULE_VERSION=2404 PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
36+
@LOG=molecule-2404-no-uv.log; \
37+
bash -o pipefail -c "MOLECULE_OS=ubuntu MOLECULE_VERSION=2404 PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG" || \
38+
( echo "FAILED: see $$LOG"; cat $$LOG; exit 1 )
3739

3840
molecule-2404-uv:
3941
@echo "molecule: ubuntu-24.04 (with uv)"
40-
LOG=molecule-2404-uv.log; \
41-
( MOLECULE_OS=ubuntu MOLECULE_VERSION=2404 PYTHON_UV_INSTALL=true PYTHON_UV_SUFFIX="-alt" $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
42+
@LOG=molecule-2404-uv.log; \
43+
bash -o pipefail -c "MOLECULE_OS=ubuntu MOLECULE_VERSION=2404 PYTHON_UV_INSTALL=true PYTHON_UV_SUFFIX="-alt" $(molecule) test -s default 2>&1 | tee $$LOG" || \
44+
( echo "FAILED: see $$LOG"; cat $$LOG; exit 1 )
4245

4346
# Convenience molecule targets (Debian 13)
4447
molecule-debian-13-no-uv:
4548
@echo "molecule: debian-13 (no uv)"
46-
LOG=molecule-debian-13-no-uv.log; \
47-
( MOLECULE_OS=debian MOLECULE_VERSION=13 MOLECULE_IMAGE=${MOLECULE_IMAGE:-geerlingguy/docker-debian13-ansible:latest} PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
49+
@LOG=molecule-debian-13-no-uv.log; \
50+
bash -o pipefail -c "MOLECULE_OS=debian MOLECULE_VERSION=13 PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG" || \
51+
( echo "FAILED: see $$LOG"; cat $$LOG; exit 1 )
4852

4953
molecule-debian-13-uv:
5054
@echo "molecule: debian-13 (with uv)"
51-
LOG=molecule-debian-13-uv.log; \
52-
( MOLECULE_OS=debian MOLECULE_VERSION=13 MOLECULE_IMAGE=${MOLECULE_IMAGE:-geerlingguy/docker-debian13-ansible:latest} PYTHON_UV_INSTALL=true PYTHON_UV_SUFFIX="-alt" $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
53-
54-
# Generic runner: allows invocation like:
55-
# make molecule-run MOLECULE_OS=debian MOLECULE_VERSION=13 MOLECULE_IMAGE=... PYTHON_UV_INSTALL=false
56-
molecule-run:
57-
@echo "molecule: ${MOLECULE_OS:-ubuntu}-${MOLECULE_VERSION:-2404} (uv=${PYTHON_UV_INSTALL:-true})"
58-
LOG=molecule-${MOLECULE_OS:-ubuntu}-${MOLECULE_VERSION:-2404}-$$( [ "${PYTHON_UV_INSTALL:-true}" = "true" ] && echo uv || echo no-uv ).log; \
59-
( MOLECULE_OS="${MOLECULE_OS:-ubuntu}" MOLECULE_VERSION="${MOLECULE_VERSION:-2404}" MOLECULE_IMAGE="${MOLECULE_IMAGE:-geerlingguy/docker-${MOLECULE_OS:-ubuntu}${MOLECULE_VERSION:-2404}-ansible:latest}" PYTHON_UV_INSTALL="${PYTHON_UV_INSTALL:-true}" PYTHON_UV_SUFFIX="${PYTHON_UV_SUFFIX}" $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
55+
@LOG=molecule-debian-13-uv.log; \
56+
bash -o pipefail -c "MOLECULE_OS=debian MOLECULE_VERSION=13 PYTHON_UV_INSTALL=true PYTHON_UV_SUFFIX="-alt" $(molecule) test -s default 2>&1 | tee $$LOG" || \
57+
( echo "FAILED: see $$LOG"; cat $$LOG; exit 1 )
6058

6159
act-download: ## download act
6260
@if [ ! -f "$(ACT_BINARY)" ]; then \
@@ -71,7 +69,7 @@ test_workflow: act-download ## Run GitHub workflows, but locally
7169
@echo "Running Tests!"
7270
$(ACT_BINARY)
7371

74-
test: molecule
72+
test: lint molecule
7573

7674
molecule-destroy:
7775
$(molecule) destroy

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
## ANXS - python
1+
## [ANXS](http://anxs.io/) - python
22

33
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/anxs/python/github-workflow-molecule.yml)
44
![Maintenance](https://img.shields.io/maintenance/yes/2025.svg)
55
![Ansible Role](https://img.shields.io/ansible/role/d/anxs/python)
6+
![GitHub License](https://img.shields.io/github/license/anxs/python)
67

78
Ansible role which installs python, pip, virtualenv, and uv
89

9-
#### Requirements & Dependencies
10-
- Tested on Ansible 2.12 or higher.
10+
## Requirements & Dependencies
1111

12-
#### Variables
12+
* Tested on Ansible 2.12 or higher.
1313

14-
```yaml
15-
python_setuptools_version: # default to latest
16-
python_virtualenv_version: # default to latestlenv
17-
```
14+
## Variables
1815

19-
## Testing
16+
This is a partial listing of configurable variables
2017

21-
This project uses molecule to test a few scenarios. You can kick off the tests (and linting) with `make test`.
18+
* `python_versions` is a list of python versions to install from the [deadsnakes](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa) PPA.
19+
* `python_uv_version` can be set to `true` to install [uv](https://github.com/astral-sh/uv).
2220

23-
## License
21+
## Testing
2422

25-
Licensed under the MIT License. See the [LICENSE](https://github.com/ANXS/python/blob/master/LICENSE) file for details.
23+
This project uses molecule to test a few scenarios. You can kick off the tests (and linting) with `make test`.
2624

2725
## Feedback, bug-reports, requests, ...
2826

molecule/default/molecule.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ driver:
77

88
platforms:
99
- name: "anxs-python-${MOLECULE_OS:-ubuntu}-${MOLECULE_VERSION:-2404}${PYTHON_UV_SUFFIX}"
10-
image: "${MOLECULE_IMAGE:-geerlingguy/docker-ubuntu2404-ansible:latest}"
10+
image: "geerlingguy/docker-${MOLECULE_OS:-ubuntu}${MOLECULE_VERSION:-2404}-ansible:latest"
1111
volumes:
1212
- /sys/fs/cgroup:/sys/fs/cgroup:rw
1313
privileged: true

molecule/default/tests/test_python_installation.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,29 @@ def _detect_os_release(self, host):
5050
def test_python_packages_can_be_installed(self, host):
5151
"""Test that pip can install packages system-wide on supported distros
5252
53-
This test runs only on distributions which support system-level pip
54-
installs (Ubuntu, or Debian older than 13). On Debian 13+ we skip this
55-
because some packaging changes make system-level pip installs unreliable
56-
in CI images.
53+
This test runs only on distributions which support
54+
system-level pip installs. On Debian 13+ and Ubuntu 24.04+ we
55+
skip this because some packaging changes make system-level pip
56+
installs unreliable in CI images.
57+
5758
"""
5859
osr = self._detect_os_release(host)
5960
distro = osr.get('ID', '').lower()
6061
version = osr.get('VERSION_ID', '')
6162

62-
# Skip system-level pip install test on Debian 13 and newer
63-
if distro == 'debian' and version:
63+
# Skip system-level pip install test on recent os
64+
major = None
65+
if version:
6466
try:
6567
major = int(version.split('.')[0])
6668
except Exception:
67-
major = None
68-
if major and major >= 13:
69-
pytest.skip("System-level pip installs are skipped on Debian 13+")
69+
pass
70+
71+
if distro == 'debian' and major and major >= 13:
72+
pytest.skip(f"System-level pip installs are skipped on Debian {version}")
73+
74+
elif distro == 'ubuntu' and major and major >= 24:
75+
pytest.skip(f"System-level pip installs are skipped on Ubuntu {version}")
7076

7177
# Attempt a system-level install (CI runs as root inside molecule by
7278
# default). We install a small package and assert success.

0 commit comments

Comments
 (0)