Skip to content
Closed
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
85 changes: 22 additions & 63 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ name: CI
on:
# Run CI against all pushes (direct commits, also merged PRs), Pull Requests
push:
branches:
- main
- dev
pull_request:
# Run CI once per day (at 06:00 UTC)
# This ensures that even if there haven't been commits that we are still testing against latest version of ansible-test for each ansible-base version
schedule:
- cron: '0 6 * * *'
workflow_dispatch:
env:
NAMESPACE: community
COLLECTION_NAME: sap_libs
Expand All @@ -17,8 +21,6 @@ jobs:
strategy:
matrix:
ansible:
- stable-2.13
- stable-2.14
- stable-2.15
- stable-2.16
- stable-2.17
Expand All @@ -35,7 +37,7 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Perform sanity testing with ansible-test
- name: Perform sanity testing
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
Expand All @@ -52,73 +54,30 @@ jobs:
# As soon as the first unit test fails, cancel the others to free up the CI queue
fail-fast: true
matrix:
ansible:
- stable-2.13
- stable-2.14
- stable-2.15
- stable-2.16
- stable-2.17
- stable-2.18
- stable-2.19
- devel
include:
- ansible: stable-2.15
python: '3.11'
- ansible: stable-2.16
python: '3.11'
- ansible: stable-2.17
python: '3.12'
- ansible: stable-2.18
python: '3.12'
- ansible: stable-2.19
python: '3.13'
- ansible: devel
python: '3.13'

steps:

- name: Check out code
uses: actions/checkout@v4

- name: Perform unit testing with ansible-test
- name: Perform unit testing
uses: ansible-community/ansible-test-gh-action@release/v1
with:
ansible-core-version: ${{ matrix.ansible }}
target-python-version: ${{ matrix.python }}
testing-type: units
# test-deps: >-
# ansible.netcommon
# ansible.utils

# Please consult the Readme for information on why we disabled integration tests temporarily.

# integration:
# runs-on: ubuntu-latest
# name: I (Ⓐ${{ matrix.ansible }}+py${{ matrix.python }})
# strategy:
# fail-fast: false
# matrix:
# ansible:
# - stable-2.9 # Only if your collection supports Ansible 2.9
# - stable-2.10
# - stable-2.11
# - stable-2.12
# - stable-2.13
# - devel
# python:
# - 2.6
# - 2.7
# - 3.5
# - 3.6
# - 3.7
# - 3.8
# - 3.9
# exclude:
# # Because ansible-test doesn't support python3.9 for Ansible 2.9
# - ansible: stable-2.9
# python: 3.9
# - ansible: devel
# python: 2.6

# steps:
# - name: Check out code
# uses: actions/checkout@v3

# - name: Perform integration testing with ansible-test
# uses: ansible-community/ansible-test-gh-action@release/v1
# with:
# ansible-core-version: ${{ matrix.ansible }}
# python-version: 3.8
# pre-test-cmd: >-
# mkdir -p tests/output/
# touch tests/output/coverage
# target-python-version: ${{ matrix.python }}
# testing-type: integration
# test-deps: >-
# ansible.netcommon
# ansible.utils
# Please consult the Readme for information on why we disabled integration tests temporarily.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@ Every voice is important. If you have something on your mind, create an issue or
## Tested with Ansible and the following Python versions

Tested Ansible versions:
- 2.13
- 2.14
- 2.15
- 2.16
- 2.17
- 2.18
- 2.19
- devel

Tested Python versions:
- 3.6
- 3.7
- 3.8
- 3.9
- 3.10
- 3.11
- 3.12
- 3.13

Due to SAP licensing and hardware requirements, integration tests are momentarily not feasible.
The modules are tested manually against SAP systems until we found a solution or have some
Expand Down
2 changes: 1 addition & 1 deletion changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ releases:
in this collection that have been made after the previous release.
fragments:
- 30-fix-lint-issues.yml
release_date: '2024-23-01'
release_date: '2024-01-23'
2 changes: 1 addition & 1 deletion plugins/modules/sap_hdbsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@

import csv
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import StringIO
from io import StringIO
from ansible.module_utils.common.text.converters import to_native


Expand Down
3 changes: 1 addition & 2 deletions tests/sanity/ignore-2.17.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed u
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
3 changes: 1 addition & 2 deletions tests/sanity/ignore-2.18.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed u
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
tests/unit/compat/mock.py pylint:use-yield-from # suggested construct does not work with Python 2
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9 changes: 9 additions & 0 deletions tests/sanity/ignore-2.19.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
9 changes: 9 additions & 0 deletions tests/sanity/ignore-2.20.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plugins/modules/sap_pyrfc.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_company.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_control_exec.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_hdbsql.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_snote.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_system_facts.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_task_list_execute.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sap_user.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
plugins/modules/sapcar_extract.py validate-modules:missing-gplv3-license # Licensed under Apache 2.0
6 changes: 2 additions & 4 deletions tests/unit/compat/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def _iterate_read_data(read_data):
# newline that our naive format() added
data_as_list[-1] = data_as_list[-1][:-1]

for line in data_as_list:
yield line
yield from data_as_list

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you replace for ... yield by yield from, then it won't work with Python 2 anymore. You have to decide whether you actively want to break support for Python 2 in tests.


def mock_open(mock=None, read_data=''):
"""
Expand Down Expand Up @@ -80,8 +79,7 @@ def _readline_side_effect():
if handle.readline.return_value is not None:
while True:
yield handle.readline.return_value
for line in _data:
yield line
yield from _data

global file_spec
if file_spec is None:
Expand Down
15 changes: 3 additions & 12 deletions tests/unit/mock/procenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from contextlib import contextmanager
from io import BytesIO, StringIO
from ansible_collections.community.general.tests.unit.compat import unittest
from ansible.module_utils.six import PY3
from ansible.module_utils.common.text.converters import to_bytes


Expand All @@ -24,12 +23,8 @@ def swap_stdin_and_argv(stdin_data='', argv_data=tuple()):
real_stdin = sys.stdin
real_argv = sys.argv

if PY3:
fake_stream = StringIO(stdin_data)
fake_stream.buffer = BytesIO(to_bytes(stdin_data))
else:
fake_stream = BytesIO(to_bytes(stdin_data))

fake_stream = StringIO(stdin_data)
fake_stream.buffer = BytesIO(to_bytes(stdin_data))
try:
sys.stdin = fake_stream
sys.argv = argv_data
Expand All @@ -47,11 +42,7 @@ def swap_stdout():
"""
old_stdout = sys.stdout

if PY3:
fake_stream = StringIO()
else:
fake_stream = BytesIO()

fake_stream = StringIO()
try:
sys.stdout = fake_stream

Expand Down
27 changes: 6 additions & 21 deletions tests/unit/mock/yaml_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io
import yaml

from ansible.module_utils.six import PY3
from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.parsing.yaml.dumper import AnsibleDumper

Expand All @@ -21,17 +20,11 @@ def _loader(self, stream):

def _dump_stream(self, obj, stream, dumper=None):
"""Dump to a py2-unicode or py3-string stream."""
if PY3:
return yaml.dump(obj, stream, Dumper=dumper)
else:
return yaml.dump(obj, stream, Dumper=dumper, encoding=None)
return yaml.dump(obj, stream, Dumper=dumper)

def _dump_string(self, obj, dumper=None):
"""Dump to a py2-unicode or py3-string"""
if PY3:
return yaml.dump(obj, Dumper=dumper)
else:
return yaml.dump(obj, Dumper=dumper, encoding=None)
return yaml.dump(obj, Dumper=dumper)

def _dump_load_cycle(self, obj):
# Each pass though a dump or load revs the 'generation'
Expand Down Expand Up @@ -89,25 +82,17 @@ def _old_dump_load_cycle(self, obj):
stream_obj_from_stream = io.StringIO()
stream_obj_from_string = io.StringIO()

if PY3:
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
else:
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper, encoding=None)
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper, encoding=None)
yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)

yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue()
yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue()

stream_obj_from_stream.seek(0)
stream_obj_from_string.seek(0)

if PY3:
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
else:
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper, encoding=None)
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper, encoding=None)
yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)

assert yaml_string == yaml_string_obj_from_stream
assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string
Expand Down
Loading