Skip to content

Commit

Permalink
Unbreak CI (#260)
Browse files Browse the repository at this point in the history
* Unbreak CI

- Upgrade containers and boxes to use newer versions
- Remove create.yml/destroy.yml templates copied by molecule with molecule init for unlucky plugins
- Rename vagrant tests to avoid "import vagrant" in the test importing the
  test module instead of importing the vagrant module.
- Move the vagrant box_url testing to its own test to avoid failures in multi-node
  where it would be hard to know if the issue is with the test or with the box_url test.

Signed-off-by: Arnaud Patard <arnaud.patard@collabora.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Arnaud Patard <arnaud.patard@collabora.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
apatard and pre-commit-ci[bot] authored Sep 19, 2024
1 parent 9943538 commit 5ab90a0
Show file tree
Hide file tree
Showing 43 changed files with 59 additions and 19 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,10 @@ src/molecule_plugins/_version.py

# Ignore generated files
test/roles

# Quilt/Patch generated files
.pc
patches
*.patch
*.orig
*.rej
2 changes: 1 addition & 1 deletion molecule/test-podman/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ driver:
name: podman
platforms:
- name: instance
image: docker.io/pycontribs/centos:8
image: quay.io/centos/centos:stream9
pre_build_image: true
published_ports:
- 127.0.0.1:2080:80
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# platforms supported as being managed by molecule/ansible, this does
# not mean molecule itself can run on them.
- image: alpine:edge
- image: quay.io/centos/centos:stream8
- image: quay.io/centos/centos:stream9
- image: ubuntu:latest
- image: debian:latest
tags:
Expand Down
5 changes: 2 additions & 3 deletions src/molecule_plugins/podman/playbooks/validate-dockerfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
# platforms supported as being managed by molecule/ansible, this does
# not mean molecule itself can run on them.
- image: alpine:edge
- image: centos:7
# - image: centos:8
- image: quay.io/centos/centos:stream9
- image: ubuntu:latest
- image: debian:latest
tasks:
- name: Create isolated build directories for each image
ansible.builtin.tempfile:
prefix: "molecule-dockerfile-{{ item.image }}"
prefix: "molecule-dockerfile-{{ item.image | replace('/', '-') }}"
state: directory
register: temp_image_dirs
with_items: "{{ platforms }}"
Expand Down
3 changes: 3 additions & 0 deletions test/azure/functional/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def test_azure_command_init_scenario(temp_dir):

assert os.path.isdir(scenario_directory)

os.unlink(os.path.join(scenario_directory, "create.yml"))
os.unlink(os.path.join(scenario_directory, "destroy.yml"))

# temporary trick to pass on CI/CD
if "AZURE_SECRET" in os.environ:
cmd = ["molecule", "test", "-s", "test-scenario"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ driver:
name: docker
platforms:
- name: instance-${DOES_NOT_EXIST:-local}
image: ${MOLECULE_ROLE_IMAGE:-centos:7}
image: ${MOLECULE_ROLE_IMAGE:-quay.io/centos/centos:stream9}
pre_build_image: false
provisioner:
name: ansible
2 changes: 2 additions & 0 deletions test/ec2/functional/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def test_ec2_command_init_scenario(temp_dir):
assert run_command(cmd).returncode == 0

assert os.path.isdir(scenario_directory)
os.unlink(os.path.join(scenario_directory, "create.yml"))
os.unlink(os.path.join(scenario_directory, "destroy.yml"))

cmd = ["molecule", "test", "-s", "test-scenario"]
assert run_command(cmd).returncode == 0
2 changes: 2 additions & 0 deletions test/gce/functional/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def test_gce_command_init_scenario(temp_dir):
assert run_command(cmd).returncode == 0

assert os.path.isdir(scenario_directory)
os.unlink(os.path.join(scenario_directory, "create.yml"))
os.unlink(os.path.join(scenario_directory, "destroy.yml"))

cmd = ["molecule", "test", "-s", "test-scenario"]
assert run_command(cmd).returncode == 0
2 changes: 2 additions & 0 deletions test/openstack/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def test_openstack_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) -
assert result.returncode == 0

assert scenario_directory.exists()
os.unlink(os.path.join(scenario_directory, "create.yml"))
os.unlink(os.path.join(scenario_directory, "destroy.yml"))

confpath = os.path.join(scenario_directory, "molecule.yml")
testconf = os.path.join(
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import shutil

import pytest

import vagrant

from conftest import change_dir_to
from molecule import logger, util
from molecule.scenario import ephemeral_directory
Expand Down Expand Up @@ -63,6 +63,11 @@ def test_vagrant_command_init_scenario(temp_dir):
assert result.returncode == 0

assert os.path.isdir(scenario_directory)

# Clean unwanted default create/destroy files from molecule init
os.unlink(os.path.join(scenario_directory, "create.yml"))
os.unlink(os.path.join(scenario_directory, "destroy.yml"))

confpath = os.path.join(scenario_directory, "molecule.yml")
conf = util.safe_load_file(confpath)
env = os.environ
Expand All @@ -71,7 +76,6 @@ def test_vagrant_command_init_scenario(temp_dir):
if "vagrant-libvirt" in [x.name for x in vagrant.Vagrant().plugin_list()]:
conf["driver"]["provider"] = {"name": "libvirt"}
util.write_file(confpath, util.safe_dump(conf))

cmd = ["molecule", "--debug", "test", "-s", "test-scenario"]
result = run_command(cmd)
assert result.returncode == 0
Expand Down Expand Up @@ -108,6 +112,7 @@ def test_invalid_settings(temp_dir):
("provider_config_options"),
("default"),
("default-compat"),
("box_url"),
("network"),
("hostname"),
],
Expand Down
15 changes: 15 additions & 0 deletions test/vagrant-plugin/scenarios/molecule/box_url/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: libvirt
platforms:
- name: instance
box: centos/stream9
box_url: "https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-Vagrant-9-20230704.1.x86_64.vagrant-libvirt.box"
box_download_checksum: "8a9fe7e8083421047e5404131daa007b4c1bcc466f3d9b29d0e7c7e432891a0e"
box_download_checksum_type: "sha256"
provisioner:
name: ansible
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ driver:
name: libvirt
platforms:
- name: instance-1
box: ${TESTBOX:-debian/jessie64}
box: ${TESTBOX:-debian/bookworm64}
memory: 256
cpus: 1
- name: instance-2
hostname: instance.example.com
box: ${TESTBOX:-debian/jessie64}
box: ${TESTBOX:-debian/bookworm64}
memory: 256
cpus: 1
- name: instance-3
hostname: false
box: ${TESTBOX:-debian/jessie64}
box: ${TESTBOX:-debian/bookworm64}
memory: 256
cpus: 1
provisioner:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ driver:
name: libvirt
platforms:
- name: instance-1
box: ${TESTBOX:-debian/stretch64}
box: ${TESTBOX:-debian/bookworm64}
interfaces:
- network_name: private_network
ip: 192.168.56.2
Expand All @@ -24,7 +24,7 @@ platforms:
instance_raw_config_args:
- 'vm.synced_folder ".", "/vagrant", type: "rsync"'
- name: instance-2
box: ${TESTBOX:-centos/7}
box: ${TESTBOX:-debian/bookworm64}
interfaces:
- network_name: private_network
ip: 192.168.56.3
Expand All @@ -38,11 +38,5 @@ platforms:
qemu_use_session: false
instance_raw_config_args:
- 'vm.synced_folder ".", "/vagrant", type: "rsync"'
# https://blog.centos.org/2020/05/updated-centos-vagrant-images-available-v2004-01/
# curl http://cloud.centos.org/centos/7/vagrant/x86_64/images/sha256sum.txt.asc -o sha256sum.txt.asc
box_url: "https://cloud.centos.org/centos/7/vagrant/x86_64/images/CentOS-7-x86_64-Vagrant-2004_01.VirtualBox.box"
box_version: "2004.01"
box_download_checksum: "7e83943defcb5c4e9bebbe4184cce4585c82805a15e936b01b1e893b63dee2c5"
box_download_checksum_type: "sha256"
provisioner:
name: ansible
10 changes: 10 additions & 0 deletions test/vagrant-plugin/scenarios/molecule/vagrant_root/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Converge
hosts: all
gather_facts: false
become: true
tasks:
- name: Sample task # noqa command-instead-of-shell
ansible.builtin.shell:
cmd: uname
changed_when: false
File renamed without changes.
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ setenv =
# This should pass these args to molecule, no effect here as this is the default
# but it validates that it accepts extra params.
MOLECULE_OPTS=--destroy always
TESTBOX={env:TESTBOX:testbox}
passenv =
CI
CURL_CA_BUNDLE
Expand Down

0 comments on commit 5ab90a0

Please sign in to comment.