From 6ce4e47b4c2bc4e9f76d625fd549af14d5f6b8d3 Mon Sep 17 00:00:00 2001 From: Robert de Bock Date: Sun, 21 Jul 2024 12:18:44 +0200 Subject: [PATCH] Test multiple versions of Python. --- .ansible-lint | 1 + .github/workflows/molecule.yml | 108 ++++++++++++++++++++++++++++++--- .gitlab-ci.yml | 20 +++++- requirements.txt | 8 +-- tox.ini | 56 +++++++++++++++++ 5 files changed, 175 insertions(+), 18 deletions(-) create mode 100644 tox.ini diff --git a/.ansible-lint b/.ansible-lint index 8115c55..f179ac0 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -3,6 +3,7 @@ # Ansible managed # exclude_paths: + - meta/preferences.yml - molecule/default/prepare.yml - molecule/default/converge.yml - molecule/default/verify.yml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 7f178df..8706be7 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -21,10 +21,57 @@ jobs: uses: actions/checkout@v4 - name: ansible-lint uses: ansible-community/ansible-lint-action@main - test: + + python-3-8: + needs: + - lint + runs-on: ubuntu-20.04 + container: + image: python:3.8 + strategy: + fail-fast: false + matrix: + config: + - image: "alpine" + tag: "latest" + - image: "enterpriselinux" + tag: "latest" + - image: "debian" + tag: "latest" + - image: "debian" + tag: "bullseye" + - image: "fedora" + tag: "39" + - image: "fedora" + tag: "latest" + - image: "fedora" + tag: "rawhide" + - image: "ubuntu" + tag: "latest" + - image: "ubuntu" + tag: "jammy" + - image: "ubuntu" + tag: "focal" + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: molecule + run: | + apt-get update -qq + apt-get -y -qq install yamllint docker.io + pip install --no-cache-dir tox + if [ -f tox.ini ] ; then tox ; fi + if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi + env: + image: ${{ matrix.config.image }} + tag: ${{ matrix.config.tag }} + python-3-9: needs: - lint runs-on: ubuntu-20.04 + container: + image: python:3.9 strategy: fail-fast: false matrix: @@ -55,18 +102,59 @@ jobs: - name: checkout uses: actions/checkout@v4 - - name: Set up Python 3. - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - - name: Install dependencies + - name: molecule run: | - python -m pip install --upgrade pip - pip install -r requirements.txt + apt-get update -qq + apt-get -y -qq install yamllint docker.io + pip install --no-cache-dir tox + if [ -f tox.ini ] ; then tox ; fi + if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi + env: + image: ${{ matrix.config.image }} + tag: ${{ matrix.config.tag }} + python-3-10: + needs: + - lint + runs-on: ubuntu-20.04 + container: + image: python:3.10 + strategy: + fail-fast: false + matrix: + config: + - image: "alpine" + tag: "latest" + - image: "amazonlinux" + tag: "latest" + - image: "enterpriselinux" + tag: "latest" + - image: "debian" + tag: "latest" + - image: "debian" + tag: "bullseye" + - image: "fedora" + tag: "39" + - image: "fedora" + tag: "latest" + - image: "fedora" + tag: "rawhide" + - image: "ubuntu" + tag: "latest" + - image: "ubuntu" + tag: "jammy" + - image: "ubuntu" + tag: "focal" + steps: + - name: checkout + uses: actions/checkout@v4 - name: molecule - run: molecule converge + run: | + apt-get update -qq + apt-get -y -qq install yamllint docker.io + pip install --no-cache-dir tox + if [ -f tox.ini ] ; then tox ; fi + if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi env: image: ${{ matrix.config.image }} tag: ${{ matrix.config.tag }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f74f133..c00da63 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,39 +1,53 @@ --- -image: "robertdebock/github-action-molecule:6.0.1" variables: - PY_COLORS: 1 + DEBIAN_FRONTEND: noninteractive molecule: + image: $python script: + - apt-get update -qq + - apt-get -y -qq install yamllint docker.io + - pip install --no-cache-dir tox - if [ -f tox.ini ] ; then tox ; fi - - if [ ! -f tox.ini ] ; then molecule test ; fi + - if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi rules: - if: $CI_COMMIT_REF_NAME == "master" parallel: matrix: - image: "alpine" tag: "latest" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "amazonlinux" tag: "latest" + python: ['python:3.9', 'python:3.10'] - image: "enterpriselinux" tag: "latest" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "debian" tag: "latest" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "debian" tag: "bullseye" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "fedora" tag: "39" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "fedora" tag: "latest" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "fedora" tag: "rawhide" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "ubuntu" tag: "latest" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "ubuntu" tag: "jammy" + python: ['python:3.8', 'python:3.9', 'python:3.10'] - image: "ubuntu" tag: "focal" + python: ['python:3.8', 'python:3.9', 'python:3.10'] galaxy: script: diff --git a/requirements.txt b/requirements.txt index 4d7adb3..e377941 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,3 @@ -ansible-compat == 24.* -molecule == 24.* -molecule-plugins[docker] == 23.* -ansible-lint == 24.* -paramiko == 3.* +molecule +molecule-plugins[docker] +paramiko diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e698e87 --- /dev/null +++ b/tox.ini @@ -0,0 +1,56 @@ +[tox] +envlist = ansible-2.{12,13,14,15,16,17} +skipsdist = true + +[testenv] +commands = molecule test + +setenv = + TOX_ENVNAME={envname} + PY_COLORS=1 + ANSIBLE_FORCE_COLOR=1 + ANSIBLE_ROLES_PATH=../ + +passenv = namespace, image, tag, DOCKER_HOST + +[testenv:ansible-2.12] +basepython = python3.8 +deps = + -rrequirements.txt + ansible-core==2.12.* + ansible-lint==5.* + +[testenv:ansible-2.13] +basepython = python3.8 +deps = + -rrequirements.txt + ansible-core==2.13.* + ansible-lint==5.* + +[testenv:ansible-2.14] +basepython = python3.9 +deps = + -rrequirements.txt + ansible-core==2.14.* + ansible-lint==6.* + +[testenv:ansible-2.15] +basepython = python3.9 +deps = + -rrequirements.txt + ansible-core==2.15.* + ansible-lint==6.* + +[testenv:ansible-2.16] +basepython = python3.10 +deps = + -rrequirements.txt + ansible-core==2.16.* + ansible-lint==24.* + +[testenv:ansible-2.17] +basepython = python3.10 +deps = + -rrequirements.txt + ansible-core==2.17.* + ansible-lint==24.*