-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt smoke testing to test both molecule and ansible-lint
- Loading branch information
Showing
2 changed files
with
56 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from tempfile import TemporaryDirectory | ||
from pathlib import Path | ||
import hashlib | ||
import logging | ||
from subprocess import run | ||
import os | ||
|
||
logging.basicConfig(level=logging.DEBUG, | ||
format= '%(levelname)s: %(message)s', | ||
|
||
) | ||
parent_project_dir = Path(__file__).parent.parent.resolve().as_posix() | ||
with TemporaryDirectory(delete=False) as tmp_dir: | ||
checksum = hashlib.sha256(parent_project_dir.encode("utf-8")).hexdigest()[:4] | ||
tmp_path = Path(tmp_dir) / f"ansible-compat-smoke-{checksum}" | ||
|
||
logging.info(f"Using {tmp_path} temporary directory...") | ||
|
||
# set -eu | ||
# SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
for project in ("ansible-lint", "molecule"): | ||
|
||
logging.info(f"Running tests for {project}") | ||
project_dir = tmp_path / project | ||
if (project_dir / ".git").exists(): | ||
run(["git", "-C", project_dir, "pull"], check=True) | ||
else: | ||
project_dir.mkdir(parents=True, exist_ok=True) | ||
run(["git", "clone", "--recursive", f"https://github.com/ansible/{project}", project_dir], check=True) | ||
|
||
os.chdir(project_dir) | ||
venv_dir = (project_dir / ".venv").as_posix() | ||
os.environ["VIRTUAL_ENV"] = venv_dir | ||
run(["uv", "venv", "--seed", venv_dir], check=True) # creates .venv (implicit for next commands) | ||
run(["uv", "pip", "install", "-e", f"{parent_project_dir}[test]", "-e", ".[test]"], check=True) | ||
run(["uv", "pip", "freeze"], check=True) | ||
run(["uv", "run", "pytest", "-n", "auto"], check=True) | ||
|
||
# tox devenv | ||
# source venv/bin/activate | ||
# uv pip install -e "$SCRIPT_DIR/.." | ||
# uv pip freeze | grep "file:" | ||
# pytest -n auto | ||
# deactivate | ||
# popd | ||
# do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters