enroll/tests.sh

54 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2025-12-15 11:04:54 +11:00
#!/bin/bash
2025-12-15 11:29:19 +11:00
set -eo pipefail
# Pytests
2025-12-15 11:04:54 +11:00
poetry run pytest -vvvv --cov=enroll --cov-report=term-missing --disable-warnings
2025-12-15 11:29:19 +11:00
BUNDLE_DIR="/tmp/bundle"
ANSIBLE_DIR="/tmp/ansible"
rm -rf "${BUNDLE_DIR}" "${ANSIBLE_DIR}"
# Install something that has symlinks like apache2,
# to extend the manifests that will be linted later
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apache2
2025-12-15 11:29:19 +11:00
# Generate data
poetry run \
2025-12-16 20:48:08 +11:00
enroll single-shot \
2025-12-15 11:29:19 +11:00
--harvest "${BUNDLE_DIR}" \
--out "${ANSIBLE_DIR}"
# Analyse
poetry run \
enroll explain "${BUNDLE_DIR}"
poetry run \
enroll explain "${BUNDLE_DIR}" --format json | jq
2025-12-15 11:29:19 +11:00
2026-01-05 21:30:14 +11:00
# Validate
poetry run \
enroll validate --fail-on-warnings "${BUNDLE_DIR}"
# Install/remove something, harvest again and diff the harvests
2026-01-05 10:23:15 +11:00
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cowsay
poetry run \
enroll harvest --out "${BUNDLE_DIR}2"
2026-01-05 21:30:14 +11:00
# Validate
poetry run \
enroll validate --fail-on-warnings "${BUNDLE_DIR}2"
# Diff
poetry run \
enroll diff \
2026-01-05 14:27:56 +11:00
--old "${BUNDLE_DIR}" \
--new "${BUNDLE_DIR}2" \
--format json | jq
2026-01-05 15:06:20 +11:00
DEBIAN_FRONTEND=noninteractive apt-get remove -y --purge cowsay
# Ansible test
builtin cd "${ANSIBLE_DIR}"
2025-12-15 11:29:19 +11:00
# Lint
ansible-lint "${ANSIBLE_DIR}"
2025-12-15 11:04:54 +11:00
2025-12-15 11:29:19 +11:00
# Run
2025-12-15 11:57:33 +11:00
ansible-playbook playbook.yml -i "localhost," -c local --check --diff