From d37972021e41b4311b4c0c1a5766daa0b30508d8 Mon Sep 17 00:00:00 2001 From: Toni Kangas Date: Wed, 6 Sep 2023 18:04:48 +0300 Subject: [PATCH 1/3] chore: update versions in CI, do not run on all push events --- .github/workflows/build-and-release.yml | 7 +++---- .github/workflows/sanity-test.yml | 27 +++++++++++++------------ .github/workflows/unit-tests.yml | 25 ++++++++++++----------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 5ecb1a6..8f04805 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -2,15 +2,14 @@ name: Build and release new version on: push: tags: - - 'v*' + - "v*" env: NAMESPACE: community COLLECTION_NAME: upcloud - ANSIBLE_VERSION: stable-2.11 + ANSIBLE_VERSION: stable-2.15 jobs: - units: runs-on: ubuntu-latest name: Build and release @@ -22,7 +21,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.11 - name: Install ansible-base (${{env.ANSIBLE_VERSION}}) run: pip install https://github.com/ansible/ansible/archive/${{env.ANSIBLE_VERSION}}.tar.gz --disable-pip-version-check diff --git a/.github/workflows/sanity-test.yml b/.github/workflows/sanity-test.yml index 0ffa523..1d9527a 100644 --- a/.github/workflows/sanity-test.yml +++ b/.github/workflows/sanity-test.yml @@ -1,24 +1,25 @@ name: sanity on: - - push - - pull_request + push: + branches: + - main + pull_request: env: NAMESPACE: community COLLECTION_NAME: upcloud jobs: sanity: - name: Sanity test (${{ matrix.ansible }}) + name: Sanity test (${{ matrix.version.ansible }}) strategy: matrix: - ansible: - - stable-2.9 - - stable-2.10 - - stable-2.11 - - devel + version: + - { ansible: stable-2.13, python: "3.10" } + - { ansible: stable-2.14, python: "3.11" } + - { ansible: stable-2.15, python: "3.11" } + - { ansible: devel, python: "3.11" } runs-on: ubuntu-latest steps: - - name: Check out code uses: actions/checkout@v1 with: @@ -27,13 +28,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: ${{ matrix.version.python }} - - name: Install ansible-base (${{ matrix.ansible }}) - run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + - name: Install ansible-base (${{ matrix.version.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.version.ansible }}.tar.gz --disable-pip-version-check - name: Run sanity tests run: ansible-test sanity --docker -v --color - name: Test building a release - run: ansible-galaxy collection build \ No newline at end of file + run: ansible-galaxy collection build diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 374e621..bcc351a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -1,25 +1,26 @@ name: unit on: - - push - - pull_request + push: + branches: + - main + pull_request: env: NAMESPACE: community COLLECTION_NAME: upcloud jobs: - units: runs-on: ubuntu-latest - name: Unit tests (${{ matrix.ansible }}) + name: Unit tests (${{ matrix.version.ansible }}) strategy: fail-fast: true matrix: - ansible: - - stable-2.9 - - stable-2.10 - - stable-2.11 - - devel + version: + - { ansible: stable-2.13, python: "3.10" } + - { ansible: stable-2.14, python: "3.11" } + - { ansible: stable-2.15, python: "3.11" } + - { ansible: devel, python: "3.11" } steps: - name: Check out code @@ -32,10 +33,10 @@ jobs: with: # it is just required to run that once as "ansible-test units" in the docker image # will run on all python versions it supports. - python-version: 3.8 + python-version: ${{ matrix.version.python }} - - name: Install ansible-base (${{ matrix.ansible }}) - run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check + - name: Install ansible-base (${{ matrix.version.ansible }}) + run: pip install https://github.com/ansible/ansible/archive/${{ matrix.version.ansible }}.tar.gz --disable-pip-version-check # Run the unit tests - name: Run unit test From 5be0820d82538133b3e5d695488b345e2c6d0fe4 Mon Sep 17 00:00:00 2001 From: Toni Kangas Date: Wed, 6 Sep 2023 18:48:48 +0300 Subject: [PATCH 2/3] fix: resolve pylint errors --- plugins/inventory/upcloud.py | 1 - tests/unit/plugins/inventory/test_upcloud.py | 1 - 2 files changed, 2 deletions(-) diff --git a/plugins/inventory/upcloud.py b/plugins/inventory/upcloud.py index 91e8b0a..99730f1 100644 --- a/plugins/inventory/upcloud.py +++ b/plugins/inventory/upcloud.py @@ -97,7 +97,6 @@ try: import upcloud_api - from upcloud_api import Server from upcloud_api.errors import UpCloudAPIError UC_AVAILABLE = True except ImportError: diff --git a/tests/unit/plugins/inventory/test_upcloud.py b/tests/unit/plugins/inventory/test_upcloud.py index fa7d5e4..27b8ca5 100644 --- a/tests/unit/plugins/inventory/test_upcloud.py +++ b/tests/unit/plugins/inventory/test_upcloud.py @@ -2,7 +2,6 @@ import pytest -from ansible.errors import AnsibleParserError from ansible.inventory.data import InventoryData from .....plugins.inventory.upcloud import InventoryModule From 6ff94e5fda71bfdf87ac2ab0327e0e7e1ad6064b Mon Sep 17 00:00:00 2001 From: Toni Kangas Date: Wed, 6 Sep 2023 19:09:00 +0300 Subject: [PATCH 3/3] fix: resolve `validate-modules` errors --- .gitignore | 3 +++ plugins/inventory/upcloud.py | 4 +++- tests/sanity/ignore-2.10.txt | 2 -- tests/sanity/ignore-2.11.txt | 2 -- tests/sanity/ignore-2.13.txt | 1 + tests/sanity/ignore-2.14.txt | 1 + tests/sanity/ignore-2.15.txt | 1 + tests/sanity/ignore-2.16.txt | 1 + tests/sanity/ignore-2.9.txt | 2 -- 9 files changed, 10 insertions(+), 7 deletions(-) delete mode 100644 tests/sanity/ignore-2.10.txt delete mode 100644 tests/sanity/ignore-2.11.txt create mode 100644 tests/sanity/ignore-2.13.txt create mode 100644 tests/sanity/ignore-2.14.txt create mode 100644 tests/sanity/ignore-2.15.txt create mode 100644 tests/sanity/ignore-2.16.txt delete mode 100644 tests/sanity/ignore-2.9.txt diff --git a/.gitignore b/.gitignore index cd85481..46a6855 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,6 @@ venv.bak/ .mypy_cache/ .dmypy.json dmypy.json + +# ansible-test +tests/output/ diff --git a/plugins/inventory/upcloud.py b/plugins/inventory/upcloud.py index 99730f1..133f613 100644 --- a/plugins/inventory/upcloud.py +++ b/plugins/inventory/upcloud.py @@ -2,7 +2,6 @@ DOCUMENTATION = r''' name: upcloud - plugin_type: inventory author: - Antti Myyrä (@ajmyyra) short_description: Ansible dynamic inventory plugin for UpCloud. @@ -48,16 +47,19 @@ description: Populate inventory with instances in these zones. default: [] type: list + elements: str required: false tags: description: Populate inventory with instances with these tags. default: [] type: list + elements: str required: false states: description: Populate inventory with instances with these states. default: [] type: list + elements: str required: false network: description: Populate inventory with instances which are attached to this network name or UUID. diff --git a/tests/sanity/ignore-2.10.txt b/tests/sanity/ignore-2.10.txt deleted file mode 100644 index ba61552..0000000 --- a/tests/sanity/ignore-2.10.txt +++ /dev/null @@ -1,2 +0,0 @@ -plugins/inventory/upcloud.py future-import-boilerplate -tests/unit/plugins/inventory/test_upcloud.py future-import-boilerplate \ No newline at end of file diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt deleted file mode 100644 index ba61552..0000000 --- a/tests/sanity/ignore-2.11.txt +++ /dev/null @@ -1,2 +0,0 @@ -plugins/inventory/upcloud.py future-import-boilerplate -tests/unit/plugins/inventory/test_upcloud.py future-import-boilerplate \ No newline at end of file diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt new file mode 100644 index 0000000..c37f47d --- /dev/null +++ b/tests/sanity/ignore-2.13.txt @@ -0,0 +1 @@ +plugins/inventory/upcloud.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt new file mode 100644 index 0000000..c37f47d --- /dev/null +++ b/tests/sanity/ignore-2.14.txt @@ -0,0 +1 @@ +plugins/inventory/upcloud.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt new file mode 100644 index 0000000..c37f47d --- /dev/null +++ b/tests/sanity/ignore-2.15.txt @@ -0,0 +1 @@ +plugins/inventory/upcloud.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt new file mode 100644 index 0000000..c37f47d --- /dev/null +++ b/tests/sanity/ignore-2.16.txt @@ -0,0 +1 @@ +plugins/inventory/upcloud.py validate-modules:missing-gplv3-license diff --git a/tests/sanity/ignore-2.9.txt b/tests/sanity/ignore-2.9.txt deleted file mode 100644 index ba61552..0000000 --- a/tests/sanity/ignore-2.9.txt +++ /dev/null @@ -1,2 +0,0 @@ -plugins/inventory/upcloud.py future-import-boilerplate -tests/unit/plugins/inventory/test_upcloud.py future-import-boilerplate \ No newline at end of file