Skip to content

Commit

Permalink
Merge branch 'master' into add-fqcn-for-become-method
Browse files Browse the repository at this point in the history
  • Loading branch information
jadacyrus authored Jan 28, 2025
2 parents 7917f63 + 45472c6 commit a4f04ec
Show file tree
Hide file tree
Showing 248 changed files with 3,536 additions and 1,790 deletions.
14 changes: 7 additions & 7 deletions .ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# `.ci`

This directory contains scripts for Continuous Integration platforms. Currently
Azure Pipelines, but they will also happily run on any Debian-like machine.
GitHub Actions, but ideally they will also run on any Debian-like machine.

The scripts are usually split into `_install` and `_test` steps. The `_install`
step will damage your machine, the `_test` step will just run the tests the way
Expand All @@ -28,15 +28,15 @@ for doing `setup.py install` while pulling a Docker container, for example.

### Environment Variables

* `TARGET_COUNT`: number of targets for `debops_` run. Defaults to 2.
* `DISTRO`: the `mitogen_` tests need a target Docker container distro. This
name comes from the Docker Hub `mitogen` user, i.e. `mitogen/$DISTRO-test`
* `DISTROS`: the `ansible_` tests can run against multiple targets
simultaneously, which speeds things up. This is a space-separated list of
DISTRO names, but additionally, supports:
* `MITOGEN_TEST_DISTRO_SPECS`: a space delimited list of distro specs to run
the tests against. (e.g. `centos6 ubuntu2004-py3*4`). Each spec determines
the Linux distribution, target Python interepreter & number of instances.
Only distributions with a pre-built Linux container image can be used.
* `debian-py3`: when generating Ansible inventory file, set
`ansible_python_interpreter` to `python3`, i.e. run a test where the
target interpreter is Python 3.
* `debian*16`: generate 16 Docker containers running Debian. Also works
with -py3.

* `MITOGEN_TEST_IMAGE_TEMPLATE`: specifies the Linux container image name,
and hence the container registry used for test targets.
11 changes: 0 additions & 11 deletions .ci/ansible_install.py

This file was deleted.

48 changes: 16 additions & 32 deletions .ci/ansible_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import os
import signal
import sys
import textwrap

import jinja2

import ci_lib


TEMPLATES_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible/templates')
TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible')
HOSTS_DIR = os.path.join(ci_lib.TMP, 'hosts')

Expand All @@ -33,13 +35,13 @@ def pause_if_interactive():


with ci_lib.Fold('docker_setup'):
containers = ci_lib.make_containers()
containers = ci_lib.container_specs(ci_lib.DISTRO_SPECS.split())
ci_lib.start_containers(containers)


with ci_lib.Fold('job_setup'):
os.chdir(TESTS_DIR)
os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7))
os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 8))

ci_lib.run("mkdir %s", HOSTS_DIR)
for path in glob.glob(TESTS_DIR + '/hosts/*'):
Expand All @@ -52,37 +54,19 @@ def pause_if_interactive():
distros[container['distro']].append(container['name'])
families[container['family']].append(container['name'])

jinja_env = jinja2.Environment(
loader=jinja2.FileSystemLoader(searchpath=TEMPLATES_DIR),
lstrip_blocks=True, # Remove spaces and tabs from before a block
trim_blocks=True, # Remove first newline after a block
)
inventory_template = jinja_env.get_template('test-targets.j2')
inventory_path = os.path.join(HOSTS_DIR, 'target')

with open(inventory_path, 'w') as fp:
fp.write('[test-targets]\n')
fp.writelines(
"%(name)s "
"ansible_host=%(hostname)s "
"ansible_port=%(port)s "
"ansible_python_interpreter=%(python_path)s "
"ansible_user=mitogen__has_sudo_nopw "
"ansible_password=has_sudo_nopw_password"
"\n"
% container
for container in containers
)

for distro, hostnames in sorted(distros.items(), key=lambda t: t[0]):
fp.write('\n[%s]\n' % distro)
fp.writelines('%s\n' % name for name in hostnames)

for family, hostnames in sorted(families.items(), key=lambda t: t[0]):
fp.write('\n[%s]\n' % family)
fp.writelines('%s\n' % name for name in hostnames)

fp.write(textwrap.dedent(
'''
[linux:children]
test-targets
[linux_containers:children]
test-targets
'''
fp.write(inventory_template.render(
containers=containers,
distros=distros,
families=families,
))

ci_lib.dump_file(inventory_path)
Expand Down
96 changes: 0 additions & 96 deletions .ci/azure-pipelines-steps.yml

This file was deleted.

165 changes: 0 additions & 165 deletions .ci/azure-pipelines.yml

This file was deleted.

Loading

0 comments on commit a4f04ec

Please sign in to comment.