Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ansible lint collection #125

Merged
merged 1 commit into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/tox_lsr/config_files/collection_yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,8 @@
extends: default
ignore: |
/.tox/
/tests/storage/
rules:
line-length: disable
truthy: disable
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
document-start: disable
comments:
min-spaces-from-content: 1
comments-indentation: disable
21 changes: 20 additions & 1 deletion src/tox_lsr/config_files/tox-default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ setenv =
LSR_ROLE2COLL_NAMESPACE = fedora
LSR_ROLE2COLL_NAME = linux_system_roles
LSR_TOX_ENV_TMP_DIR = {envtmpdir}
LSR_ANSIBLE_LINT_CONTAINER = {env:LSR_ANSIBLE_LINT_CONTAINER:quay.io/ansible/creator-ee:v0.16.0}
deps =
py{26,27,36,37,38,39,310,311}: pytest-cov
py{27,36,37,38,39,310,311}: pytest>=3.5.1
Expand Down Expand Up @@ -245,12 +246,30 @@ commands =
{env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \
-v {toxinidir}:/workdir --workdir /workdir \
--entrypoint /usr/local/bin/ansible-lint \
quay.io/ansible/creator-ee:v0.16.0 \
{env:LSR_ANSIBLE_LINT_CONTAINER} \
{env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs}
{[lsr_config]commands_post}
commands_post =
bash {lsr_scriptdir}/ansible-lint-helper.sh post

[testenv:ansible-lint-collection]
changedir = {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}
allowlist_externals =
podman
bash
cp
commands =
bash {lsr_scriptdir}/setup_module_utils.sh
{[lsr_config]commands_pre}
cp {toxinidir}/.ansible-lint {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}
{env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \
-v {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}:/workdir \
--workdir /workdir \
--entrypoint /usr/local/bin/ansible-lint \
{env:LSR_ANSIBLE_LINT_CONTAINER} \
{env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs}
{[lsr_config]commands_post}

[testenv:ansible-test]
# NOTE: ansible-test in ansible 2.9 seems to become confused
# when running in a venv that uses basepython 3.9 or later
Expand Down
5 changes: 5 additions & 0 deletions src/tox_lsr/test_scripts/runcollection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ cp "$LSR_TOX_ENV_DIR/tmp/galaxy.yml" "$TOX_WORK_DIR/ansible_collections/$LSR_ROL
# create the collection in this dir to share with other testenvs
cd "$TOX_WORK_DIR/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"

# these are for ansible-lint
cp "$LSR_CONFIGDIR/collection_yamllint.yml" \
"$TOX_WORK_DIR/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME/.yamllint.yml"
touch "$TOX_WORK_DIR/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME/CHANGELOG.md"

# unit testing not working yet - will need these and more
#export RUN_PYTEST_UNIT_DIR="$role/unit"
#export PYTHONPATH="$MY_LSR_TOX_ENV_DIR/ansible_collections/"${LSR_ROLE2COLL_NAME}"/"${LSR_ROLE2COLL_NAME}"/plugins/modules:$MY_LSR_TOX_ENV_DIR/ansible_collections/"${LSR_ROLE2COLL_NAME}"/"${LSR_ROLE2COLL_NAME}"/plugins/module_utils"
Expand Down
19 changes: 18 additions & 1 deletion tests/fixtures/test_tox_merge_ini/result.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ setenv = PYTHONPATH = {env:LSR_PYTHONPATH:}{toxinidir}/library:{toxinidir}/modul
LSR_ROLE2COLL_NAMESPACE = fedora
LSR_ROLE2COLL_NAME = linux_system_roles
LSR_TOX_ENV_TMP_DIR = {envtmpdir}
LSR_ANSIBLE_LINT_CONTAINER = {env:LSR_ANSIBLE_LINT_CONTAINER:quay.io/ansible/creator-ee:v0.16.0}
LOCAL1 = local1
LOCAL2 = local2
deps = py{26,27,36,37,38,39,310,311}: pytest-cov
Expand Down Expand Up @@ -204,11 +205,27 @@ commands = bash {lsr_scriptdir}/setup_module_utils.sh
{env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \
-v {toxinidir}:/workdir --workdir /workdir \
--entrypoint /usr/local/bin/ansible-lint \
quay.io/ansible/creator-ee:v0.16.0 \
{env:LSR_ANSIBLE_LINT_CONTAINER} \
{env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs}
{[lsr_config]commands_post}
commands_post = bash {lsr_scriptdir}/ansible-lint-helper.sh post

[testenv:ansible-lint-collection]
changedir = {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}
allowlist_externals = podman
bash
cp
commands = bash {lsr_scriptdir}/setup_module_utils.sh
{[lsr_config]commands_pre}
cp {toxinidir}/.ansible-lint {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}
{env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \
-v {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}:/workdir \
--workdir /workdir \
--entrypoint /usr/local/bin/ansible-lint \
{env:LSR_ANSIBLE_LINT_CONTAINER} \
{env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs}
{[lsr_config]commands_post}

[testenv:ansible-test]
basepython = python3
deps = {env:LSR_ANSIBLE_TEST_DEP:ansible-core==2.14.*}
Expand Down