Skip to content

Update plugins to work with new python versions #130

Update plugins to work with new python versions

Update plugins to work with new python versions #130

Workflow file for this run

---
name: Test Plugins
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
pull_request:
branches:
- 'main'
paths:
- 'plugins/**'
- 'tests/**'
- 'molecule/plugins/**'
- '.github/workflows/test_plugins.yml'
jobs:
sanity_ansible_18_19:
runs-on: ubuntu-latest
env:
COLLECTION_NAMESPACE: netways
COLLECTION_NAME: elasticstack
strategy:
fail-fast: false
matrix:
python_version:
- "3.11"
- "3.12"
- "3.13"
ansible_version:
- "ansible-core>=2.18,<2.19" #Correspond ansible>=11.0,<12.0
- "ansible-core>=2.19,<2.20" #Correspond ansible>=12.0,<13.0
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
- name: Install Ansible
run: |
python3 -m pip install --upgrade pip
python3 -m pip install "${{ matrix.ansible_version }}"
- name: Install collection
run: |
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- name: Run sanity tests
run: |
cd ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
ansible-test sanity --python "${{ matrix.python_version }}" -v
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
sanity_ansible_20:
runs-on: ubuntu-latest
env:
COLLECTION_NAMESPACE: netways
COLLECTION_NAME: elasticstack
strategy:
fail-fast: false
matrix:
python_version:
- "3.12"
- "3.13"
- "3.14"
ansible_version:
- "ansible-core>=2.20,<2.21" #Correspond ansible>=13.0,<14.0
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
- name: Install Ansible
run: |
python3 -m pip install --upgrade pip
python3 -m pip install "${{ matrix.ansible_version }}"
- name: Install collection
run: |
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- name: Run sanity tests
run: |
cd ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
ansible-test sanity --python "${{ matrix.python_version }}" -v
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
unit-test:
needs:
- sanity_ansible_18_19
- sanity_ansible_20
runs-on: ubuntu-latest
env:
COLLECTION_NAMESPACE: netways
COLLECTION_NAME: elasticstack
strategy:
fail-fast: false
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install "ansible-core>=2.19,<2.20"
- name: Install collection
run: |
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- name: Test `cert_info` module
run: |
PYTHONPATH=$HOME/.ansible/collections python3 tests/unit/plugins/modules/test_cert_info.py
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
- name: Test `certs` module util
run: |
PYTHONPATH=$HOME/.ansible/collections python3 tests/unit/plugins/module_utils/test_certs.py
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
molecule_plugins:
needs: unit-test
runs-on: ubuntu-latest
env:
COLLECTION_NAMESPACE: netways
COLLECTION_NAME: elasticstack
strategy:
fail-fast: false
matrix:
distro:
- ubuntu2204
scenario:
- plugins
release:
- 8
# - 9 # add when elasticsearch>=9 is supported by this collection
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install "ansible-core>=2.19,<2.20"
python3 -m pip install -r requirements-test.txt
- name: Install collection
run: |
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- name: Test with molecule
run: |
ansible --version
molecule --version
molecule test -s ${{ matrix.scenario }}
env:
MOLECULE_DISTRO: ${{ matrix.distro }}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
ELASTIC_RELEASE: ${{ matrix.release }}
python-cryptography:
needs: unit-test
runs-on: ubuntu-latest
env:
COLLECTION_NAMESPACE: netways
COLLECTION_NAME: elasticstack
strategy:
fail-fast: false
matrix:
python_cryptography_version:
- "38.0.0"
- "40.0.1"
- "41.0.0"
- "42.0.0"
- "43.0.0"
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: 3.11
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install "ansible-core>=2.19,<2.20"
python3 -m pip install "cryptography==${{ matrix.python_cryptography_version }}"
- name: Install collection
run: |
mkdir -p ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE
cp -a ../ansible-collection-$COLLECTION_NAME ~/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME
- name: Test cert_info with cryptography ${{ matrix.python_cryptography_version }}
run: |
PYTHONPATH=$HOME/.ansible/collections python3 tests/unit/plugins/modules/test_cert_info.py
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'