From d667b79021980bb7f517181e02d2f172bffb274a Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Tue, 2 Jun 2026 12:20:02 +0300 Subject: [PATCH 1/9] rebase --- .github/workflows/all_green_check.yml | 18 +-- .github/workflows/ansible-test.yml | 135 ++++++++++++++++++ .github/workflows/sanity.yml | 84 ----------- .github/workflows/units.yml | 83 ----------- CI.md | 18 +-- ...60528-ansible-test-gh-action-migration.yml | 3 + 6 files changed, 154 insertions(+), 187 deletions(-) create mode 100644 .github/workflows/ansible-test.yml delete mode 100644 .github/workflows/sanity.yml delete mode 100644 .github/workflows/units.yml create mode 100644 changelogs/fragments/20260528-ansible-test-gh-action-migration.yml diff --git a/.github/workflows/all_green_check.yml b/.github/workflows/all_green_check.yml index b25c228..80ee592 100644 --- a/.github/workflows/all_green_check.yml +++ b/.github/workflows/all_green_check.yml @@ -25,10 +25,6 @@ jobs: linters: if: github.event_name == 'pull_request' uses: ./.github/workflows/linters.yml # use the callable linters job to run tests - sanity: - uses: ./.github/workflows/sanity.yml # use the callable sanity job to run tests - units: - uses: ./.github/workflows/units.yml # use the callable units job to run tests coverage: name: Unit test coverage runs-on: ubuntu-latest @@ -74,28 +70,28 @@ jobs: with: name: coverage path: ${{ github.workspace }}/coverage.xml + ansible-test: + uses: ./.github/workflows/ansible-test.yml all_green: if: ${{ always() }} needs: - linters - - sanity - - units - coverage + - ansible-test runs-on: ubuntu-latest steps: - run: | python -c " import sys - required = ['sanity', 'units', 'coverage'] + required = ['coverage', 'ansible-test'] if '${{ github.event_name }}' == 'pull_request': - required = ['linters', 'sanity', 'units', 'coverage'] + required = ['linters', 'coverage', 'ansible-test'] results = { 'linters': '${{ needs.linters.result }}', - 'sanity': '${{ needs.sanity.result }}', - 'units': '${{ needs.units.result }}', 'coverage': '${{ needs.coverage.result }}', + 'ansible-test': '${{ needs.ansible-test.result }}', } for name in required: @@ -137,4 +133,4 @@ jobs: && github.event.pull_request.head.repo.full_name == github.repository)) }} uses: ./.github/workflows/sonarcloud.yml secrets: - ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT: ${{ secrets.ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT }} + ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT: ${{ secrets.ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT }} \ No newline at end of file diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml new file mode 100644 index 0000000..72e87ed --- /dev/null +++ b/.github/workflows/ansible-test.yml @@ -0,0 +1,135 @@ +# Ansible collection testing with ansible-test-gh-action +# +# Note: Integration tests are handled separately in integration.yml due to +# their complexity and AWS credential requirements. + +name: ansible-test + +on: [workflow_call] # allow this workflow to be called from other workflows + +jobs: + sanity: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ansible-core-version: + - stable-2.17 + - stable-2.18 + - stable-2.19 + - stable-2.20 + - stable-2.21 + - milestone + - devel + python-version: + - "3.10" + - "3.11" + - "3.12" + - "3.13" + - "3.14" + exclude: + # Collection does not support ansible-core == 2.16 (omitted from matrix) + # devel and milestone don't support older Python versions + - ansible-core-version: devel + python-version: "3.10" + - ansible-core-version: devel + python-version: "3.11" + - ansible-core-version: milestone + python-version: "3.10" + - ansible-core-version: milestone + python-version: "3.11" + # stable-2.21 excludes + - ansible-core-version: stable-2.21 + python-version: "3.10" + - ansible-core-version: stable-2.21 + python-version: "3.11" + # stable-2.20 excludes + - ansible-core-version: stable-2.20 + python-version: "3.10" + - ansible-core-version: stable-2.20 + python-version: "3.14" + # stable-2.19 excludes + - ansible-core-version: stable-2.19 + python-version: "3.10" + - ansible-core-version: stable-2.19 + python-version: "3.14" + # stable-2.18 excludes + - ansible-core-version: stable-2.18 + python-version: "3.10" + - ansible-core-version: stable-2.18 + python-version: "3.14" + # stable-2.17 excludes + - ansible-core-version: stable-2.17 + python-version: "3.13" + - ansible-core-version: stable-2.17 + python-version: "3.14" + steps: + - name: Perform sanity testing + uses: ansible-community/ansible-test-gh-action@d3a8ec7a59694e25e210fcd44738910149537f0e # v1.17.0 + with: + ansible-core-version: ${{ matrix.ansible-core-version }} + testing-type: sanity + target-python-version: ${{ matrix.python-version }} + + units: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ansible-core-version: + - stable-2.17 + - stable-2.18 + - stable-2.19 + - stable-2.20 + - stable-2.21 + - milestone + - devel + python-version: + - "3.10" + - "3.11" + - "3.12" + - "3.13" + - "3.14" + exclude: + # Collection does not support ansible-core == 2.16 (omitted from matrix) + # devel and milestone don't support older Python versions + - ansible-core-version: devel + python-version: "3.10" + - ansible-core-version: devel + python-version: "3.11" + - ansible-core-version: milestone + python-version: "3.10" + - ansible-core-version: milestone + python-version: "3.11" + # stable-2.21 excludes + - ansible-core-version: stable-2.21 + python-version: "3.10" + - ansible-core-version: stable-2.21 + python-version: "3.11" + # stable-2.20 excludes + - ansible-core-version: stable-2.20 + python-version: "3.10" + - ansible-core-version: stable-2.20 + python-version: "3.14" + # stable-2.19 excludes + - ansible-core-version: stable-2.19 + python-version: "3.10" + - ansible-core-version: stable-2.19 + python-version: "3.14" + # stable-2.18 excludes + - ansible-core-version: stable-2.18 + python-version: "3.10" + - ansible-core-version: stable-2.18 + python-version: "3.14" + # stable-2.17 excludes + - ansible-core-version: stable-2.17 + python-version: "3.13" + - ansible-core-version: stable-2.17 + python-version: "3.14" + steps: + - name: Perform unit testing + uses: ansible-community/ansible-test-gh-action@d3a8ec7a59694e25e210fcd44738910149537f0e # v1.17.0 + with: + ansible-core-version: ${{ matrix.ansible-core-version }} + testing-type: units + target-python-version: ${{ matrix.python-version }} diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml deleted file mode 100644 index 4cf4d8b..0000000 --- a/.github/workflows/sanity.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- -name: sanity tests - -on: [workflow_call] # allow this workflow to be called from other workflows - -jobs: - sanity: - uses: ansible-network/github_actions/.github/workflows/sanity.yml@main - with: - # Collection does not support ansible-core == 2.16 - matrix_exclude: >- - [ - { - "ansible-version": "devel", - "python-version": "3.11" - }, - { - "ansible-version": "devel", - "python-version": "3.14" - }, - { - "ansible-version": "milestone", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.20", - "python-version": "3.14" - }, - { - "ansible-version": "devel", - "python-version": "3.10" - }, - { - "ansible-version": "milestone", - "python-version": "3.11" - }, - { - "ansible-version": "milestone", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.21", - "python-version": "3.11" - }, - { - "ansible-version": "stable-2.21", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.20", - "python-version": "3.11" - }, - { - "ansible-version": "stable-2.20", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.19", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.19", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.18", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.18", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.17", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.17", - "python-version": "3.13" - }, - { - "ansible-version": "stable-2.16" - } - ] \ No newline at end of file diff --git a/.github/workflows/units.yml b/.github/workflows/units.yml deleted file mode 100644 index 5607d74..0000000 --- a/.github/workflows/units.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: unit tests - -on: [workflow_call] # allow this workflow to be called from other workflows - -jobs: - unit-source: - uses: ansible-network/github_actions/.github/workflows/unit_source.yml@main - with: - # Collection does not support ansible-core == 2.16 - matrix_exclude: >- - [ - { - "ansible-version": "devel", - "python-version": "3.11" - }, - { - "ansible-version": "devel", - "python-version": "3.14" - }, - { - "ansible-version": "milestone", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.20", - "python-version": "3.14" - }, - { - "ansible-version": "devel", - "python-version": "3.10" - }, - { - "ansible-version": "milestone", - "python-version": "3.11" - }, - { - "ansible-version": "milestone", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.21", - "python-version": "3.11" - }, - { - "ansible-version": "stable-2.21", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.20", - "python-version": "3.11" - }, - { - "ansible-version": "stable-2.20", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.19", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.19", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.18", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.18", - "python-version": "3.10" - }, - { - "ansible-version": "stable-2.17", - "python-version": "3.14" - }, - { - "ansible-version": "stable-2.17", - "python-version": "3.13" - }, - { - "ansible-version": "stable-2.16" - } - ] \ No newline at end of file diff --git a/CI.md b/CI.md index 4d4dc20..7cd8396 100644 --- a/CI.md +++ b/CI.md @@ -12,21 +12,21 @@ The following tests run on every pull request: | --- | ----------- | --------------- | --------------------- | | [Changelog](.github/workflows/changelog.yml) | Checks for the presence of changelog fragments | 3.9 | devel | | [Linters](.github/workflows/linters.yml) | Runs `black` and `flake8` on plugins and tests | 3.9 | N/A | -| [Sanity](.github/workflows/sanity.yml) | Runs ansible sanity checks | See compatibility table below | devel, stable-2.17, stable-2.18, stable-2.19, stable-2.20, stable-2.21 | -| [Unit tests](.github/workflows/units.yml) | Executes unit test cases | See compatibility table below | devel, stable-2.17, stable-2.18, stable-2.19, stable-2.20, stable-2.21 | +| [ansible-test](.github/workflows/ansible-test.yml) | Runs ansible sanity and unit tests | See compatibility table below | devel, milestone, stable-2.17, stable-2.18, stable-2.19, stable-2.20, stable-2.21 | | [Integration](.github/workflows/integration.yml) | Executes integration test suites | 3.11 | milestone | **Note:** Integration tests require manual approval via the `protected` environment and AWS credentials from ansible-core-ci. ### Python Version Compatibility by ansible-core Version -These are outlined in the collection's [tox.ini](tox.ini) file (`envlist`) and GitHub Actions workflow exclusions. +These are outlined in the [.github/workflows/ansible-test.yml](.github/workflows/ansible-test.yml) matrix exclusions. | ansible-core Version | Sanity Tests | Unit Tests | | -------------------- | ------------ | ---------- | -| devel | 3.10, 3.11, 3.14 | 3.10, 3.11, 3.14 | -| stable-2.21 | 3.10, 3.11 | 3.10, 3.11 | -| stable-2.20 | 3.10, 3.11, 3.14 | 3.10, 3.11, 3.14 | -| stable-2.19 | 3.10, 3.14 | 3.10, 3.14 | -| stable-2.18 | 3.10, 3.14 | 3.10, 3.14 | -| stable-2.17 | 3.13, 3.14 | 3.13, 3.14 | +| devel | 3.12, 3.13, 3.14 | 3.12, 3.13, 3.14 | +| milestone | 3.12, 3.13, 3.14 | 3.12, 3.13, 3.14 | +| stable-2.21 | 3.12, 3.13, 3.14 | 3.12, 3.13, 3.14 | +| stable-2.20 | 3.11, 3.12, 3.13 | 3.11, 3.12, 3.13 | +| stable-2.19 | 3.11, 3.12, 3.13 | 3.11, 3.12, 3.13 | +| stable-2.18 | 3.11, 3.12, 3.13 | 3.11, 3.12, 3.13 | +| stable-2.17 | 3.10, 3.11, 3.12 | 3.10, 3.11, 3.12 | diff --git a/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml b/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml new file mode 100644 index 0000000..e5dd507 --- /dev/null +++ b/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml @@ -0,0 +1,3 @@ +--- +trivial: + - Migrate CI workflows to use ansible-community/ansible-test-gh-action for unified sanity and unit testing. From d47f722d12d0342158c73dc4aef5f005340c0761 Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Tue, 2 Jun 2026 12:22:31 +0300 Subject: [PATCH 2/9] rebase --- .github/workflows/ansible-test.yml | 1 + .../fragments/20260528-ansible-test-gh-action-migration.yml | 2 +- tests/sanity/requirements.yml | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/sanity/requirements.yml diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 72e87ed..63b3998 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -70,6 +70,7 @@ jobs: ansible-core-version: ${{ matrix.ansible-core-version }} testing-type: sanity target-python-version: ${{ matrix.python-version }} + test-deps: -r ansible_collections/amazon/cloud/tests/sanity/requirements.yml units: runs-on: ubuntu-latest diff --git a/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml b/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml index e5dd507..51bba44 100644 --- a/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml +++ b/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml @@ -1,3 +1,3 @@ --- trivial: - - Migrate CI workflows to use ansible-community/ansible-test-gh-action for unified sanity and unit testing. + - Migrate CI workflows to use ansible-community/ansible-test-gh-action for unified sanity and unit testing.(https://github.com/ansible-collections/amazon.cloud/pull/142) diff --git a/tests/sanity/requirements.yml b/tests/sanity/requirements.yml new file mode 100644 index 0000000..99ce82a --- /dev/null +++ b/tests/sanity/requirements.yml @@ -0,0 +1,5 @@ +--- +collections: + - name: https://github.com/ansible-collections/amazon.aws.git + type: git + version: main From 92c96aceda86af731459d452341d2bbf0efb9183 Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Thu, 28 May 2026 13:45:23 +0300 Subject: [PATCH 3/9] Fix CI unit issues --- .github/workflows/ansible-test.yml | 1 + tests/unit/requirements.yml | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 tests/unit/requirements.yml diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 63b3998..b37822a 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -134,3 +134,4 @@ jobs: ansible-core-version: ${{ matrix.ansible-core-version }} testing-type: units target-python-version: ${{ matrix.python-version }} + test-deps: -r ansible_collections/amazon/cloud/tests/unit/requirements.yml diff --git a/tests/unit/requirements.yml b/tests/unit/requirements.yml new file mode 100644 index 0000000..99ce82a --- /dev/null +++ b/tests/unit/requirements.yml @@ -0,0 +1,5 @@ +--- +collections: + - name: https://github.com/ansible-collections/amazon.aws.git + type: git + version: main From 2fda4cff5275e0c9733b70a10f74ebfc134dc8ee Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Thu, 28 May 2026 14:02:18 +0300 Subject: [PATCH 4/9] Install unit tests python requirements --- .github/workflows/ansible-test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index b37822a..f59cece 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -135,3 +135,4 @@ jobs: testing-type: units target-python-version: ${{ matrix.python-version }} test-deps: -r ansible_collections/amazon/cloud/tests/unit/requirements.yml + pre-test-cmd: python -m pip install -r ansible_collections/amazon/cloud/tests/test-requirements.txt From 74354cda15572a7dfc2aa3e52dcaeeb4931767d5 Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Thu, 28 May 2026 14:28:44 +0300 Subject: [PATCH 5/9] correct unit tests python requirements path --- .github/workflows/ansible-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index f59cece..67885f6 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -135,4 +135,4 @@ jobs: testing-type: units target-python-version: ${{ matrix.python-version }} test-deps: -r ansible_collections/amazon/cloud/tests/unit/requirements.yml - pre-test-cmd: python -m pip install -r ansible_collections/amazon/cloud/tests/test-requirements.txt + pre-test-cmd: python -m pip install -r test-requirements.txt From d77df3d6c5d9633de62c4b9a040adf9a5b346d0e Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Mon, 1 Jun 2026 14:01:34 +0300 Subject: [PATCH 6/9] update sanity tests requirements --- .github/workflows/ansible-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 67885f6..9276806 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -135,4 +135,4 @@ jobs: testing-type: units target-python-version: ${{ matrix.python-version }} test-deps: -r ansible_collections/amazon/cloud/tests/unit/requirements.yml - pre-test-cmd: python -m pip install -r test-requirements.txt + pre-test-cmd: python -m pip install -r tests/unit/constraints.txt -r tests/unit/requirements.txt From 91dbdd001c8ea404b94c9f9de5b2baf13f3f4633 Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Mon, 1 Jun 2026 16:10:11 +0300 Subject: [PATCH 7/9] fix unit tests failures --- .github/workflows/ansible-test.yml | 2 +- ...60528-ansible-test-gh-action-migration.yml | 3 ++ test-requirements.txt | 2 ++ tests/unit/constraints.txt | 3 ++ tests/unit/module_utils/test_core.py | 35 +++++++++++++++---- tests/unit/requirements.txt | 5 +++ 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 9276806..241a587 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -135,4 +135,4 @@ jobs: testing-type: units target-python-version: ${{ matrix.python-version }} test-deps: -r ansible_collections/amazon/cloud/tests/unit/requirements.yml - pre-test-cmd: python -m pip install -r tests/unit/constraints.txt -r tests/unit/requirements.txt + pre-test-cmd: python -m pip install -r tests/unit/constraints.txt -r tests/unit/requirements.txt -r test-requirements.txt diff --git a/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml b/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml index 51bba44..7460f15 100644 --- a/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml +++ b/changelogs/fragments/20260528-ansible-test-gh-action-migration.yml @@ -1,3 +1,6 @@ --- trivial: - Migrate CI workflows to use ansible-community/ansible-test-gh-action for unified sanity and unit testing.(https://github.com/ansible-collections/amazon.cloud/pull/142) + - Add jsonpatch to test-requirements.txt and tests/unit/requirements.txt.(https://github.com/ansible-collections/amazon.cloud/pull/143) + - Fix unit test failures in tests/unit/module_utils/test_core.py.(https://github.com/ansible-collections/amazon.cloud/pull/144) + diff --git a/test-requirements.txt b/test-requirements.txt index 82fa807..ed7e6a0 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,3 +7,5 @@ mock pytest pytest-xdist pytest-ansible + +jsonpatch diff --git a/tests/unit/constraints.txt b/tests/unit/constraints.txt index e69de29..dd5e0a1 100644 --- a/tests/unit/constraints.txt +++ b/tests/unit/constraints.txt @@ -0,0 +1,3 @@ +# Specifically run tests against the oldest versions that we support +boto3==1.25.0 +botocore==1.28.0 \ No newline at end of file diff --git a/tests/unit/module_utils/test_core.py b/tests/unit/module_utils/test_core.py index 6d824f7..5bc0300 100644 --- a/tests/unit/module_utils/test_core.py +++ b/tests/unit/module_utils/test_core.py @@ -19,11 +19,28 @@ def ccr(): class NotFound(Exception): pass - resource = CloudControlResource(Mock()) - resource.module.check_mode = False - resource.module.params = {"wait_timeout": 5} + module = Mock() + module.check_mode = False + module.params = {"wait_timeout": 5, "bucket_name": "test_bucket"} + + def _fail(*args, **kwargs): + raise Exception("module exit") + + module.fail_json.side_effect = _fail + module.fail_json_aws.side_effect = _fail + + resource = CloudControlResource(module) resource.client = MagicMock() resource.client.exceptions.ResourceNotFoundException = NotFound + resource.client.list_resource_requests.return_value = { + "ResourceRequestStatusSummaries": [] + } + resource.client.update_resource.return_value = { + "ProgressEvent": { + "OperationStatus": "IN_PROGRESS", + "RequestToken": "test-token", + } + } return resource @@ -55,8 +72,10 @@ def test_present_updates_resource(ccr): ccr.client.get_resource.return_value = resource create_only_params = [] params = {"BucketName": "test_bucket", "Tags": [{"Key": "k", "Value": "v"}]} - changed = ccr.present("AWS::S3::Bucket", "test_bucket", params, create_only_params) - assert changed + results = ccr.present( + "AWS::S3::Bucket", ["bucket_name"], params, create_only_params + ) + assert results["changed"] ccr.client.update_resource.assert_called_with( TypeName="AWS::S3::Bucket", Identifier="test_bucket", @@ -75,7 +94,8 @@ def test_absent_deletes_resource(ccr): }, } ccr.client.get_resource.return_value = resource - changed = ccr.absent("AWS::S3::Bucket", "test_bucket") + ccr.module.params = {"wait_timeout": 5, "bucket_name": "test_bucket"} + changed = ccr.absent("AWS::S3::Bucket", ["bucket_name"]) assert changed ccr.client.delete_resource.assert_called_with( TypeName="AWS::S3::Bucket", @@ -90,7 +110,8 @@ def test_absent_deletes_resource_NotFound(ccr): ccr.client.get_resource.side_effect = ( ccr.client.exceptions.ResourceNotFoundException() ) - changed = ccr.absent("AWS::S3::Bucket", "test_bucket") + ccr.module.params = {"wait_timeout": 5, "bucket_name": "test_bucket"} + changed = ccr.absent("AWS::S3::Bucket", ["bucket_name"]) assert changed is False ccr.client.delete_resource.assert_not_called() ccr.client.create_resource.assert_not_called() diff --git a/tests/unit/requirements.txt b/tests/unit/requirements.txt index e69de29..f7ef542 100644 --- a/tests/unit/requirements.txt +++ b/tests/unit/requirements.txt @@ -0,0 +1,5 @@ +# Installed by ansible-test into the unit test container. +# Keep in sync with requirements.txt. +boto3>=1.25.0 +botocore>=1.28.0 +jsonpatch From 366bf6d05629582a37a77f61d8dfc669c46fa510 Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Mon, 1 Jun 2026 18:13:00 +0300 Subject: [PATCH 8/9] fix SonarQube --- tests/unit/module_utils/test_core.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/module_utils/test_core.py b/tests/unit/module_utils/test_core.py index 5bc0300..32d4fb3 100644 --- a/tests/unit/module_utils/test_core.py +++ b/tests/unit/module_utils/test_core.py @@ -14,6 +14,10 @@ ) +class ModuleFailure(Exception): + """Simulates Ansible module exit via fail_json.""" + + @pytest.fixture def ccr(): class NotFound(Exception): @@ -24,7 +28,7 @@ class NotFound(Exception): module.params = {"wait_timeout": 5, "bucket_name": "test_bucket"} def _fail(*args, **kwargs): - raise Exception("module exit") + raise ModuleFailure("module exit") module.fail_json.side_effect = _fail module.fail_json_aws.side_effect = _fail From a9e776ddce78040f0ddfa18a27108eb78abf1fba Mon Sep 17 00:00:00 2001 From: Benny Rahmanim Date: Tue, 2 Jun 2026 16:27:22 +0300 Subject: [PATCH 9/9] fix CI secret issue --- .github/workflows/all_green_check.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/all_green_check.yml b/.github/workflows/all_green_check.yml index 80ee592..463c0cc 100644 --- a/.github/workflows/all_green_check.yml +++ b/.github/workflows/all_green_check.yml @@ -29,8 +29,7 @@ jobs: name: Unit test coverage runs-on: ubuntu-latest needs: - - sanity - - units + - ansible-test env: ANSIBLE_CORE_REF: "stable-2.17" steps: @@ -127,7 +126,6 @@ jobs: - coverage if: >- ${{ needs.all_green.result == 'success' - && secrets.ANSIBLE_COLLECTIONS_ORG_SONAR_TOKEN_CICD_BOT != '' && (github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) }}