Skip to content

Commit 784f7a8

Browse files
committed
updated for 2025, tests, uv, woah
1 parent 0ed6755 commit 784f7a8

27 files changed

+864
-152
lines changed

.ansible-lint

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
profile: production
3+
4+
exclude_paths:
5+
- .cache/
6+
- .github/
7+
- molecule/*/tests/
8+
9+
skip_list:
10+
- yaml[line-length]
11+
- fqcn[action-core] # todo this one is probably worth fixing
12+
- package-latest
13+
14+
offline: false
15+
16+
supported_ansible_also:
17+
- ">=2.12"
18+
19+
mock_modules:
20+
- community.general.ini_file
21+
- community.general.alternatives
22+
23+
mock_roles:
24+
- external.role.dependency
25+
26+
verbosity: 1
27+
28+
warn_list:
29+
- experimental
30+
- yaml[truthy]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
---
2+
name: Molecule CI
3+
4+
# Run tests on pull requests and main branch pushes
5+
on:
6+
pull_request:
7+
branches: [main]
8+
push:
9+
branches: [main]
10+
workflow_dispatch: # Allow manual triggering
11+
12+
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.x'
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -r requirements-dev.txt
29+
30+
- name: Run yamllint
31+
run: yamllint .
32+
33+
- name: Run ansible-lint
34+
run: ansible-lint
35+
36+
test:
37+
name: Molecule Test
38+
runs-on: ubuntu-latest
39+
needs: lint
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
config:
44+
- 2204-no-uv
45+
- 2404-no-uv
46+
- 2404-uv
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Python
53+
uses: actions/setup-python@v4
54+
with:
55+
python-version: '3.x'
56+
57+
- name: Install dependencies
58+
run: |
59+
python -m pip install --upgrade pip
60+
pip install -r requirements-dev.txt
61+
62+
- name: Set up Docker Buildx
63+
uses: docker/setup-buildx-action@v3
64+
65+
- name: Run molecule test
66+
run: make molecule-${{ matrix.config }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ Icon
66
.Spotlight-V100
77
.Trashes
88
.ci-env
9+
.ansible
10+
__pycache__
11+
molecule*.log

.travis.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.yamllint

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--- # -*-YAML-*-
2+
extends: default
3+
4+
ignore: |
5+
.cache/
6+
.git/
7+
.github/
8+
molecule/*/tests/
9+
vagrant-inventory
10+
tasks/.#*
11+
12+
rules:
13+
line-length:
14+
max: 120
15+
level: warning
16+
17+
indentation:
18+
spaces: 2
19+
indent-sequences: true
20+
check-multi-line-strings: false
21+
22+
comments:
23+
min-spaces-from-content: 1
24+
25+
document-start:
26+
present: true
27+
28+
trailing-spaces: enable
29+
30+
empty-lines:
31+
max: 2
32+
max-start: 0
33+
max-end: 1
34+
35+
brackets:
36+
min-spaces-inside: 0
37+
max-spaces-inside: 1
38+
39+
braces:
40+
min-spaces-inside: 0
41+
max-spaces-inside: 1
42+
43+
key-duplicates: enable
44+
45+
octal-values:
46+
forbid-implicit-octal: true
47+
forbid-explicit-octal: false
48+
49+
truthy:
50+
allowed-values: ['true', 'false', 'yes', 'no']
51+
check-keys: true

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
The MIT License
22

33
Copyright (c) 2014 Pieterjan Vandaele
4+
Copyright (c) 2015-2025 Jonathan E Freedman
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,59 @@
1-
.PHONY: clean dist_clean molecule testenv
1+
.PHONY: help clean lint test molecule molecule-test format \
2+
molecule-test molecule-2204-no-uv molecule-2404-no-uv molecule-2404-uv
23

3-
BUILD_IMAGE="anxsscaffolding/build"
4+
molecule ?= molecule
5+
6+
help: ## Display this help message
7+
@echo "Available targets:"
8+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
9+
10+
lint: yamllint ansible-lint
11+
@echo "All linting completed!"
12+
13+
yamllint: ## Run YAML linting
14+
@echo "Running yamllint..."
15+
yamllint .
16+
17+
ansible-lint: ## Run Ansible linting
18+
@echo "Running ansible-lint..."
19+
ansible-lint
20+
21+
format: ## Format code with black and other formatters
22+
@echo "Formatting Python code..."
23+
black tests/ --line-length 88 --target-version py39
24+
@echo "Code formatting completed!"
25+
26+
test: lint molecule ## Run default test suite (lint + default molecule scenario)
27+
@echo "Default testing completed!"
28+
29+
molecule-2204-no-uv:
30+
@echo "==> molecule: ubuntu-22.04 (no uv)"; \
31+
LOG=molecule-2204-no-uv.log; \
32+
( MOLECULE_UBUNTU_VERSION=2204 PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
33+
34+
molecule-2404-no-uv:
35+
@echo "==> molecule: ubuntu-24.04 (no uv)"; \
36+
LOG=molecule-2404-no-uv.log; \
37+
( MOLECULE_UBUNTU_VERSION=2404 PYTHON_UV_INSTALL=false $(molecule) test -s default 2>&1 | tee $$LOG ) || ( echo "FAILED: see $$LOG"; cat $$LOG; false )
38+
39+
molecule-2404-uv:
40+
@echo "==> molecule: ubuntu-24.04 (with uv)"; \
41+
LOG=molecule-2404-uv.log; \
42+
( MOLECULE_UBUNTU_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 )
443

544
molecule:
6-
docker run \
7-
-v $(shell pwd):/mnt \
8-
-v /var/run/docker.sock:/var/run/docker.sock \
9-
$(BUILD_IMAGE)
45+
@echo "Running all molecule scenarios..."
46+
make -j molecule-test
47+
48+
molecule-test: molecule-2404-uv molecule-2404-no-uv molecule-2204-no-uv
49+
50+
molecule-destroy:
51+
@echo "Removing molecule instances"
52+
molecule destroy
53+
54+
clean: molecule-destroy ## Clean up molecule instances and temporary files
55+
@echo "Cleaning up..."
56+
find . -name "*.pyc" -delete
57+
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
58+
find . -name ".pytest_cache" -type d -exec rm -rf {} + 2>/dev/null || true
59+
@echo "Cleanup completed!"

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
## ANXS - python [![Build Status](https://travis-ci.com/ANXS/python.png)](https://travis-ci.com/ANXS/python)
1+
## ANXS - python
22

3-
Ansible role which installs python, pip, setuptools and virtualenv
3+
[![test workflow status](https://github.com/ANXS/python/actions/workflows/test.yml/badge.svg)](https://github.com/ANXS/python/actions/workflows/test.yml) ![Maintenance](https://img.shields.io/maintenance/yes/2025.svg)
44

5+
Ansible role which installs python, pip, and virtualenv
56

67
#### Requirements & Dependencies
7-
- Tested on Ansible 2.3 or higher.
8-
8+
- Tested on Ansible 2.12 or higher.
99

1010
#### Variables
1111

@@ -14,18 +14,14 @@ python_setuptools_version: # default to latest
1414
python_virtualenv_version: # default to latestlenv
1515
```
1616
17+
## Testing
1718
18-
#### Testing
19-
This project comes with a VagrantFile, this is a fast and easy way to test changes to the role, fire it up with `vagrant up`
20-
21-
See [vagrant docs](https://docs.vagrantup.com/v2/) for getting setup with vagrant
22-
23-
24-
#### License
19+
This project uses molecule to test a few scenarios. You can kick off the tests (and linting) with `make test`.
2520

26-
Licensed under the MIT License. See the LICENSE file for details.
21+
## License
2722

23+
Licensed under the MIT License. See the [LICENSE](https://github.com/ANXS/python/blob/master/LICENSE) file for details.
2824

29-
#### Feedback, bug-reports, requests, ...
25+
## Feedback, bug-reports, requests, ...
3026

3127
Are [welcome](https://github.com/ANXS/python/issues)!

Vagrantfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

defaults/main.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
22
python_prefix_dir: "/usr/local"
3-
python_pip_location: "{{python_prefix_dir}}/bin/pip"
4-
python_virtualenv_location: "{{python_prefix_dir}}/bin/virtualenv"
5-
# python_setuptools_version: # default to latest
6-
7-
get_pip_url: "https://bootstrap.pypa.io/get-pip.py"
83

4+
# List of optional deadsnakes versions to install
95
python_versions: []
6+
7+
# UV installation settings
8+
python_uv_install: false
9+
python_uv_version: "0.9.3"
10+
python_uv_install_path: "{{ python_prefix_dir }}/bin"
11+
python_uv_temp_dir: "/tmp"

0 commit comments

Comments
 (0)