Skip to content

Commit

Permalink
Fix molecule tests (#21)
Browse files Browse the repository at this point in the history
* Bring workflow versions up to date

* Update molecule config

* Remove redundant (and malfunctioning) task from test

* Move preparation tasks to where they should live

* Switch to systemd-friendly images

* Fix older version scenarios too!

* Ditch redundant task

* Fix broken scenarios

* Fix failing verify stage

* Add requirements for setting up molecule venv

* Clarify
  • Loading branch information
dale-c-anderson authored Jan 24, 2023
1 parent ffbff38 commit 84a8fa7
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 53 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: molecule
uses: robertdebock/molecule-action@2.6.3
uses: robertdebock/molecule-action@4.0.9
with:
command: lint
test:
Expand All @@ -29,19 +29,18 @@ jobs:
scenario:
- php7.4
- php8.0
- default # aka php81modern. Only uses 8.1 style lists for all php versions.
- default # PHP 8.1 and beyond. Only uses 8.1 style lists for all php versions.
- php81legacy # Mixes new 8.1 style list and keeps pre-8.1 module lists.
image:
- geerlingguy/docker-ubuntu2204-ansible:latest
- geerlingguy/docker-ubuntu2004-ansible:latest
- geerlingguy/docker-ubuntu1804-ansible:latest
- registry.gitlab.com/aussielunix/ansible/molecule-containers/ubuntu:jammy
- registry.gitlab.com/aussielunix/ansible/molecule-containers/ubuntu:focal
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: "${{ github.repository }}"
- name: molecule
uses: robertdebock/molecule-action@2.6.3
uses: robertdebock/molecule-action@4.0.9
with:
options: parallel
scenario: "${{ matrix.scenario }}"
Expand Down
14 changes: 0 additions & 14 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,5 @@

vars_files: ./vars.yml

pre_tasks:

- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
changed_when: false

- name: Ensure dirmngr is installed (gnupg dependency).
apt:
name: dirmngr
state: present

- name: Add repository for PHP
apt_repository: repo='ppa:ondrej/php'

roles:
- role: ansible-role-php
20 changes: 14 additions & 6 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
---
role_name_check: 1
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: ${MOLECULE_DOCKER_IMAGE:-'geerlingguy/docker-ubuntu2204-ansible:latest'}
# command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
image: "registry.gitlab.com/aussielunix/ansible/molecule-containers/${MOLECULE_DISTRO:-ubuntu:jammy}"
privileged: true
pre_build_image: true
# instance_raw_config_args:
# - "vm.network 'forwarded_port', guest: 80, host: 8088"
override_command: false
tmpfs:
- /run
- /tmp
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
env:
ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
verifier:
name: ansible
# env:
# ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
scenario:
name: default
17 changes: 17 additions & 0 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Prepare
hosts: all
become: true

vars_files: ./vars.yml

tasks:

- name: Update apt cache.
apt: update_cache=true cache_valid_time=600
changed_when: false

- name: Ensure dirmngr is installed (gnupg dependency).
apt:
name: dirmngr
state: present
22 changes: 14 additions & 8 deletions molecule/php7.4/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
---
role_name_check: 1
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: ${MOLECULE_DOCKER_IMAGE:-'geerlingguy/docker-ubuntu1804-ansible:latest'}
# command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
image: "registry.gitlab.com/aussielunix/ansible/molecule-containers/${MOLECULE_DISTRO:-ubuntu:jammy}"
privileged: true
pre_build_image: true
override_command: false
tmpfs:
- /run
- /tmp
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
env:
ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
verifier:
name: ansible
lint: |
set -e
yamllint -d relaxed .
# ansible-lint . @TODO uncomment and address issues, which are out of scope for this feature branch.
# env:
# ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
scenario:
name: php7.4
22 changes: 14 additions & 8 deletions molecule/php8.0/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
---
role_name_check: 1
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: ${MOLECULE_DOCKER_IMAGE:-'geerlingguy/docker-ubuntu1804-ansible:latest'}
# command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
image: "registry.gitlab.com/aussielunix/ansible/molecule-containers/${MOLECULE_DISTRO:-ubuntu:jammy}"
privileged: true
pre_build_image: true
override_command: false
tmpfs:
- /run
- /tmp
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
env:
ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
verifier:
name: ansible
lint: |
set -e
yamllint -d relaxed .
# ansible-lint . @TODO uncomment and address issues, which are out of scope for this feature branch.
# env:
# ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
scenario:
name: php8.0
3 changes: 0 additions & 3 deletions molecule/php81legacy/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@
name: dirmngr
state: present

- name: Add repository for PHP
apt_repository: repo='ppa:ondrej/php'

roles:
- role: ansible-role-php
20 changes: 14 additions & 6 deletions molecule/php81legacy/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
---
role_name_check: 1
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: ${MOLECULE_DOCKER_IMAGE:-'geerlingguy/docker-ubuntu2204-ansible:latest'}
# command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
image: "registry.gitlab.com/aussielunix/ansible/molecule-containers/${MOLECULE_DISTRO:-ubuntu:jammy}"
privileged: true
pre_build_image: true
# instance_raw_config_args:
# - "vm.network 'forwarded_port', guest: 80, host: 8088"
override_command: false
tmpfs:
- /run
- /tmp
provisioner:
name: ansible
playbooks:
converge: ${MOLECULE_PLAYBOOK:-converge.yml}
env:
ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
verifier:
name: ansible
# env:
# ANSIBLE_VERBOSITY: ${MOLECULE_ANSIBLE_VERBOSITY:-0}
# PY_COLORS: '1'
# ANSIBLE_FORCE_COLOR: '1'
scenario:
name: php81legacy
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# pip requirements for testing
molecule[docker]

0 comments on commit 84a8fa7

Please sign in to comment.