Refactoring molecule scenarios and GitHub workflows #147
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Test Plugins | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| logLevel: | |
| description: 'Log level' | |
| required: true | |
| default: 'warning' | |
| type: choice | |
| options: | |
| - info | |
| - warning | |
| - debug | |
| pull_request: | |
| paths: | |
| - 'plugins/**' | |
| - 'tests/**' | |
| - 'molecule/plugins/**' | |
| - '.github/workflows/test_plugins.yml' | |
| jobs: | |
| sanity_ansible_18_19: | |
| if: github.event.pull_request.draft == false | |
| 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: | |
| if: github.event.pull_request.draft == false | |
| 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: | |
| - debian13 | |
| 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: | |
| - "3.4.8" # Test loading certificate with 3 parameter (old way). | |
| - "41.0.7" # Last version before not_valid_after() and not_valid_before() deprecation. | |
| - "42.0.0" # First release with deprecation https://cryptography.io/en/latest/changelog/ | |
| - "46.0.5" # Latest release | |
| 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' |