Skip to content
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
22 changes: 20 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
ansible-lint -v --force-color
antsibull-changelog lint

ansible-test-sanity:
ansible-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -53,8 +53,26 @@ jobs:
run: |
ansible-test sanity --verbose --docker --junit

- name: Run ansible-test units
working-directory: ansible_collections/stackhpc/cephadm
run: |
ansible-test units --verbose --docker --coverage
ansible-test coverage xml
ansible-test coverage html

- name: Print coverage report
working-directory: ansible_collections/stackhpc/cephadm
run: |
ansible-test coverage report

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure() # always run even if the previous step fails
with:
report_paths: '**/tests/output/junit/*.xml'
report_paths: '**/tests/output/*/*.xml'

- name: Upload HTML report
uses: actions/upload-artifact@v3
with:
name: coverage-html
path: ansible_collections/stackhpc/cephadm/tests/output/reports/coverage/
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# antsibull-changelog cache
/changelogs/.plugin-cache.yaml

# ansible-test output
/tests/output

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
5 changes: 5 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
ansible>=2.9
ansible-lint<7
antsibull-changelog
coverage<=6.5.0
mock
pytest
pytest-forked
pytest-xdist
Empty file.
29 changes: 29 additions & 0 deletions tests/unit/modules/cephadm_test_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
import json


def set_module_args(args):
if '_ansible_remote_tmp' not in args:
args['_ansible_remote_tmp'] = '/tmp'
if '_ansible_keep_remote_files' not in args:
args['_ansible_keep_remote_files'] = False

args = json.dumps({'ANSIBLE_MODULE_ARGS': args})
basic._ANSIBLE_ARGS = to_bytes(args)


class AnsibleExitJson(Exception):
pass


class AnsibleFailJson(Exception):
pass


def exit_json(*args, **kwargs):
raise AnsibleExitJson(kwargs)


def fail_json(*args, **kwargs):
raise AnsibleFailJson(kwargs)
Loading