feat!(tasks): move tasks to include; move dependencies installation to a task;...

This commit is contained in:
NaeiKinDus 2025-01-26 22:52:14 +00:00
parent 846f5e693e
commit 35d72db683
8 changed files with 161 additions and 103 deletions

View file

@ -1,5 +1,9 @@
version: '3'
includes:
setup: ./tasks/setup_{{OS}}.yml
test: ./tasks/tests.yml
env:
DOCKER_REPOSITORY: pouncetech/molecule
@ -9,71 +13,13 @@ vars:
COLLECTIONS_DIR: '{{.ROOT_DIR}}/collections/ansible_collections'
tasks:
setup:venv:
desc: install a Python3 virtualenv and all the required ansible / molecule dependencies.
cmds:
- |
set -e
rm -rf ./venv || true
python3 -m virtualenv --download venv
./venv/bin/python3 -m pip install --upgrade -r requirements.txt
status:
- test -d venv
setup:ansible:
desc: install ansible galaxy collections
cmds:
- '{{.PYTHON_WRAPPER}} ansible-galaxy collection install -r ansible_galaxy-requirements.yml'
setup:
desc: set up environment for Python virtualenv and ansible dependencies
desc: install requirements, set up a Python virtualenv and install ansible dependencies
cmds:
- task: 'setup:requirements'
- task: 'setup:venv'
- task: 'setup:ansible'
test:modules:
desc: run `ansible-test sanity` on collections to find common issues for modules and collections
dir: collections/ansible_collections
vars:
ANSIBLE_COLLECTIONS:
sh: find -mindepth 2 -maxdepth 2 -type d
cmds:
- for: { var: ANSIBLE_COLLECTIONS }
task: 'test:module:sanity'
vars:
COLLECTION_PATH: 'collections/ansible_collections/{{.ITEM}}'
test:module:sanity:
internal: true
dir: '{{.COLLECTION_PATH}}'
cmds:
- 'test -d tests && {{.PYTHON_WRAPPER}} ansible-test sanity --venv || echo - ignored $(pwd)'
test:collections:
desc: run molecule tests for all roles and collections.
dir: collections/ansible_collections
vars:
ANSIBLE_COLLECTIONS:
sh: find -mindepth 2 -maxdepth 2 -type d
cmds:
- for: { var: ANSIBLE_COLLECTIONS }
task: 'test:collection:molecule'
vars:
COLLECTION_PATH: 'collections/ansible_collections/{{.ITEM}}'
test:collection:molecule:
internal: true
dir: '{{.COLLECTION_PATH}}/extensions'
cmds:
- 'test -d molecule && {{.PYTHON_WRAPPER}} molecule test || echo - ignored $(pwd)'
module:github_artifact:
desc: run a module from the collection for testing purposes
vars:
PLUGINS_DIR: '{{.ROOT_DIR}}/collections/ansible_collections/nullified/infrastructure/plugins'
cmd: |
{{.PYTHON_WRAPPER}} python3 {{.PLUGINS_DIR}}/modules/github_artifact.py {{.PLUGINS_DIR}}/tests/github_artifact.json |
{{.PYTHON_WRAPPER}} python3 -m json.tool | {{.PYTHON_WRAPPER}} pygmentize -l json
- task: 'setup:galaxy'
docker:build:
desc: build docker images locally.